T09 · Insecure Skill Coding Practices
- Location
hooks/security-validator/handler.ts:78- Finding
Shell command injection in the pre-tool security validator
- Content
View full analysis
`"${arg}"`).join(' ')}`; const result = execSync(fullCommand, { encoding: 'utf8', timeout: 5000 }); ``` ### Technical Analysis The hook constructs a shell command by placing untrusted tool arguments between double quotes. Double quotes do not provide safe shell argument escaping when the input itself can contain quotation marks, command substitutions, backticks, or other shell syntax. Because `execSync()` receives a string, Node.js invokes a shell to interpret it. An argument containing a double quote can terminate the intended quoted argument and append a new shell command. This is especially dangerous because the vulnerable operation runs as part of a security check before the original tool call is approved. The validator is explicitly intended to process hostile command strings, making attacker-controlled shell metacharacters an expected input rather than an edge case. ### Attack Path 1. An attacker supplies a command argument such as: ```text "; touch /tmp/security-hook-pwned; # ``` 2. The hook constructs a command equivalent to: ```bash "/home/user/.clawdbot/skills/security/security" validate-command ""; touch /tmp/security-hook-pwned; #" ``` 3. The shell closes the quoted validator argument at the attacker-supplied quotation mark. 4. The injected `touch` command executes during validation. 5. More damaging commands could access files, launch processes, or make network connections with the same privileges as the Clawdbot process. ### Impact Assessment Successful exploitation provides arbitrary command execution under the account running Clawdbot. The attacker could read or modify workspace data, agent configuration, cre ...[truncated 415 chars]- Remediation
View remediation
