T09 · Insecure Skill Coding Practices
- Location
douyin-spark.js:55- Finding
Unsafe Shell Command Construction in Browser Command Helper
- Content
View full analysis
Vulnerability Details
File Location:
douyin-spark.js, lines 55-63
Vulnerability Type: OS command injection
Risk Level: LowVulnerable Code
js function runBrowserCommand(args) { try { const cmd = `openclaw browser ${args}`; execSync(cmd, { stdio: 'pipe' }); return true; } catch (error) { console.error('浏览器命令执行失败:', error.message); return false; } }Technical Analysis
The
runBrowserCommandfunction concatenates itsargsparameter directly into a command string and passes the resulting value tochild_process.execSync. By default,execSyncexecutes command strings through a system shell.If an attacker can influence
args, shell metacharacters such as semicolons, command substitutions, pipes, or redirection operators can cause the shell to execute additional commands. For example, an argument containing a legitimate browser operation followed by a shell command could escape the intendedopenclaw browserinvocation.The audited version does not call or export
runBrowserCommand, so no currently reachable exploitation path from the command-line arguments was identified. The vulnerable helper is therefore dormant in the present implementation. It would become exploitable if later connected to CLI parameters, contact data, webpage content, agent-generated values, or other untrusted input without strict validation.Attack Path
A complete exploitation path would require the dormant helper to become reachable:
- An application change or integration passes attacker-controlled data to
runBrowserCommand(args). - The attacker includes shell metacharacters and an additional operating-system command in
args. - The function constructs a single command string:
text openclaw browser <attacker-controlled content> execSyncinvokes the system shell to interpret that string.- The shell executes both the expe ...[truncated 767 chars]
- An application change or integration passes attacker-controlled data to
- Remediation
View remediation
Remediation Suggestions
- Remove
runBrowserCommandif it is not required. - If command execution is required, avoid invoking a shell. Use
execFileSyncorspawnSyncwith an argument array:js const { execFileSync } = require('child_process'); function runBrowserCommand(args) { if (!Array.isArray(args)) { throw new TypeError('Browser arguments must be an array'); } execFileSync('openclaw', ['browser', ...args], { stdio: 'pipe', shell: false }); return true; } - Define a strict allowlist of supported browser actions and reject unknown flags, control characters, and unexpected value formats.
- Do not pass contact names, webpage text, agent-generated strings, or raw CLI parameters into process-execution functions.
- Prefer a direct OpenClaw API or structured browser-tool interface over spawning a command-line process.
- Add tests containing shell metacharacters to verify that user-controlled values are treated exclusively as literal arguments.
- Remove
