T09 · Insecure Skill Coding Practices
- Location
SKILL.md:9- Finding
Shell Command Injection Through Unsafe Prompt Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 9–13
Vulnerability Type: Shell command injection
Risk Level: HighVulnerable Code
markdown ## Usage Run the following bash command using the `exec` tool, passing the prompt as a string. Note that we rely on `hermes` being in the PATH (e.g., `~/.local/bin/hermes`). ```bash ~/.local/bin/hermes chat -q "your prompt here"text The unsafe command-construction pattern is also demonstrated at lines 17–20: ```markdown 1. Call the `exec` tool: - `command`: `~/.local/bin/hermes chat -q "Write a quick Python script to monitor system load"` 2. Read the stdout of the `exec` result, which contains Hermes's answer, and relay it back to the user.Technical Analysis
The skill instructs the agent to construct a shell command by inserting prompt text into a double-quoted command string. If an agent follows this pattern with user-controlled prompt content, shell quoting does not provide adequate isolation.
Within a double-quoted shell argument, command substitutions such as
$(...)and backticks can still be evaluated. An attacker could also include a double quote to terminate the intended argument and append shell operators or additional commands. Consequently, the shell may interpret part of the prompt as executable syntax rather than passing it entirely as data to Hermes.The package contains documentation and metadata rather than executable scripts, so exploitation depends on an invoking agent following the documented string-based
execpattern. Nevertheless, that pattern defines the skill's operational behavior and creates an unsafe code-execution boundary.Attack Path
- An attacker asks OpenClaw to consult Hermes and supplies a prompt containing shell syntax, such as a command substitution or quote-breaking payload.
- OpenClaw inserts that prompt into the documented command template:
~/.local/bin/hermes chat -q "USER_PROMPT". - The
exectool passes the con ...[truncated 904 chars]
- Remediation
View remediation
Remediation Suggestions
-
Do not concatenate or interpolate prompt text into a shell command string.
-
Invoke Hermes through an API that accepts an executable and argument array separately, with shell interpretation disabled. For example, use the conceptual argument vector:
text ["~/.local/bin/hermes", "chat", "-q", prompt] -
Update
SKILL.mdto explicitly prohibit invoking the command throughsh -c,bash -c, or an equivalent shell-evaluated string. -
If the available
execinterface supports only command strings, replace it with a tool that supports structured arguments. Shell escaping should be treated only as a fallback and must use a well-tested, platform-appropriate quoting implementation rather than manual replacement. -
Apply least privilege to the OpenClaw process and Hermes CLI. Restrict access to sensitive files, credentials, network resources, and administrative commands to reduce the impact of any execution flaw.
-
Add tests using prompts containing embedded quotes, semicolons, newlines, backticks,
$(), redirection operators, and shell logical operators. Verify that every payload reaches Hermes as one literal argument and causes no shell-side execution. -
Consider setting execution timeouts and output-size limits and validating the expected Hermes executable path before invocation.
-
