T09 · Insecure Skill Coding Practices
- Location
handler.js:10- Finding
Shell Command Injection and Bypassable Destructive-Command Controls
- Content
View full analysis
lower.includes(k)); } // MAIN ENTRYPOINT // OpenClaw will call this function when using the skill tool async function claw_shell_run(input) { const { command } = input; if (!command || typeof command !== "string") { return { error: "command is required" }; } if (isDangerous(command)) { return { error: "dangerous_command", message: `Command looks dangerous. Ask the user for explicit approval before running: ${command}` }; } ``` ### Technical Analysis The `command` value is controlled through the Skill input and is interpolated directly into a string passed to `execSync`. Because `execSync` executes the constructed string through a system shell, shell syntax in the input is interpreted before `tmux` receives the intended command. The implementation only escapes double-quote characters: ```js const escaped = cmd.replace(/"/g, '\\"'); ``` This does not neutralize shell command-substitution constructs such as `$()` or backticks. Shell expansion can therefore execute an injected command in the process used to invoke `tmux`, outside the documented `claw` tmux session. Backslash and quote combinations may also interfere with the intended quoting boundary. The `isDangerous` control does not adequately mitigate thi ...[truncated 2324 chars]- Remediation
View remediation
