T09 · Insecure Skill Coding Practices
- Location
scripts/owner-push-forwarder.mjs:223- Finding
Configurable Forwarding Command Is Executed Through a Shell
- Content
View full analysis
Vulnerability Details
File Location:
scripts/owner-push-forwarder.mjs, lines 223-227; configuration source at line 10
Vulnerability Type: OS command injection through an unvalidated environment variable
Risk Level: HighVulnerable code:
js const OWNER_FORWARD_CMD = String(process.env.OPENCLAW_OWNER_FORWARD_CMD || "").trim();js const child = spawn(OWNER_FORWARD_CMD, { shell: true, stdio: ["pipe", "inherit", "inherit"], env: process.env, });Technical Analysis
The complete value of
OPENCLAW_OWNER_FORWARD_CMDis passed tospawn()withshell: true. Consequently, the operating-system shell interprets command separators, substitutions, pipelines, redirections, and other shell syntax contained in the environment variable.The value is neither validated nor separated into a trusted executable and an explicit argument array. Although the documented value is
node scripts/send-to-owner-via-openclaw.mjs, any party or configuration mechanism able to influence the environment variable can replace it with an arbitrary shell expression. Execution occurs when a qualifying broadcast is dispatched.Attack Path
- An attacker gains influence over the forwarder's runtime environment, service configuration, launch script, or another source defining
OPENCLAW_OWNER_FORWARD_CMD. - The attacker sets the variable to a command containing an additional shell payload.
- The forwarder polls the bridge and identifies a broadcast containing a default or configured high-signal term.
dispatchToOwner()passes the attacker-controlled string tospawn()with shell interpretation enabled.- The shell executes the injected command with the same operating-system identity and environment as the forwarder.
This issue is configuration-mediated and does not permit broadcast content itself to alter the command string.
Impact Assessment
Successful exploitation provides arbit ...[truncated 546 chars]
- An attacker gains influence over the forwarder's runtime environment, service configuration, launch script, or another source defining
- Remediation
View remediation
Remediation Suggestions
- Remove
shell: trueand invoke a fixed, trusted executable using an explicit argument array. - Prefer directly launching the bundled forwarding script, for example by spawning
process.execPathwith the resolved script path as an argument. - If configurability is required, define the executable and arguments in separate configuration fields rather than accepting a shell command string.
- Resolve and validate configurable executable paths against a narrow allowlist of approved binaries or scripts.
- Do not attempt to secure shell execution by escaping selected metacharacters; avoiding the shell is the reliable control.
- Run the forwarder under a dedicated least-privilege account with minimal filesystem, credential, and network access.
- Add tests proving that shell metacharacters and command substitutions are treated as literal arguments and cannot execute secondary commands.
- Remove
