T09 · Insecure Skill Coding Practices
- Location
SKILL.md:32- Finding
Shell Command Injection Through Interpolated User Question
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:32
Vulnerability Type: Command injection caused by unsafe shell-command construction
Risk Level: HighVulnerable Code
text 7. If you had to fall back to `find.sh` or `search.sh`, or if the user corrects your routing, log the miss: `scripts/record_miss.sh "<user question>" "<path you used>"`The corresponding script expects the question as a command-line argument:
bash # Record mode: # record_miss.sh "<user question>" "<path you ended up fetching>"Technical Analysis
The Skill instructs the agent to insert an attacker-controlled user question directly into a textual shell command surrounded by double quotes. Double quotes do not safely encode arbitrary data for a shell: an embedded double quote can terminate the argument, after which shell metacharacters, command substitutions, or additional commands can be interpreted.
The implementation of
record_miss.shtreats already-separated arguments as data, but this protection occurs only after shell parsing. It does not protect the command-construction step prescribed bySKILL.md.Exploitability depends on the host agent executing the documented command through a shell rather than passing a structured argument vector. Under that execution model, a crafted question such as a quote followed by a command separator could introduce an additional command.
Attack Path
- An attacker submits an OpenClaw-related question containing shell syntax and an embedded double quote.
- The question causes routing to fall back to
find.shorsearch.sh, or the attacker corrects the routing. - The Behavior Contract requires the agent to run the documented miss-logging command.
- The agent substitutes the raw question into the quoted shell command.
- Shell parsing terminates the intended argument at the attacker-supplied quote.
- The remaining attacker-controlled ...[truncated 583 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct shell command strings by interpolating user-controlled questions.
- Invoke
record_miss.shthrough an API that accepts a structured argument array, without an intervening shell. - Prefer accepting the question through standard input, for example by adding a mode in which
record_miss.shreads one bounded record from stdin. - If shell invocation is unavoidable, apply a trusted shell-escaping routine to each argument rather than relying on double quotes.
- Add tests containing embedded quotes, backticks, command substitutions, semicolons, newline characters, and shell redirection operators.
- Consider removing the raw question from the logging interface entirely and recording only a sanitized routing keyword or event identifier.
