T09 · Insecure Skill Coding Practices
- Location
SKILL.md:17- Finding
Shell Injection Through Unescaped Skill Hook Variables
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:17-23
Vulnerability Type: Command injection through shell-based template interpolation
Risk Level: HighVulnerable Code
yaml hooks: - event: "message.audio.receive" action: "bash process.sh \"{{MediaPath}}\" \"{{Target}}\" \"{{MessageID}}\"" triggers: - command: "/voz" description: "Configurar voz ou processar áudio manualmente" action: "bash process.sh \"{{args}}\""Technical Analysis
Dynamic hook values are interpolated directly into a shell command string. Quoting a template expression with double quotes does not make it safe if the substituted value itself can contain a double quote, command substitution, a newline, or shell control operators.
The
/voztrigger is especially exposed because{{args}}can contain directly user-controlled message content. Unless OpenClaw guarantees context-aware shell escaping before expansion, an attacker can terminate the quoted argument and introduce additional shell syntax.Although
process.shgenerally passes its arguments safely to subprocesses, that protection occurs only after the shell has parsed the hook action. Injection therefore happens beforeprocess.shreceives the arguments.Attack Path
- An attacker invokes
/vozwith content containing a closing quote and shell control syntax. - OpenClaw substitutes the content into the
actionstring. - The generated action is passed to a shell for parsing.
- The injected syntax escapes the intended argument and starts an additional command.
- That command executes with the operating-system identity and environment of the OpenClaw gateway or Agent process.
The same issue may be reachable through
MediaPath,Target, orMessageIDif any upstream integration permits attacker-controlled characters in those fields.Impact Assessment
Successful exploitation permits arbitrary command execution with the ...[truncated 363 chars]
- An attacker invokes
- Remediation
View remediation
Remediation Suggestions
- Replace string-based shell actions with an API that accepts an executable and argument array without invoking a shell.
- Use a fixed wrapper entry point and pass dynamic values through stdin, a structured JSON file, or separately populated environment variables.
- If the host only supports shell action strings, require and document a host-provided shell-escaping primitive rather than inserting raw template values.
- Apply strict allowlists:
- Require
MediaPathto resolve beneath an approved media directory. - Restrict
TargetandMessageIDto their documented identifier character sets. - Parse
/vozas a voice command and accept only known values such asjeff,cadu,faber, ormiro.
- Require
- Add integration tests with quotes, command substitutions, semicolons, newlines, and shell metacharacters to confirm they are treated exclusively as data.
