T09 · Insecure Skill Coding Practices
- Location
SKILL.md:403- Finding
Command Injection Through Unsafe Shell and tmux Prompt Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 403 and 426
Vulnerability Type: Command injection through untrusted string interpolation
Risk Level: MediumVulnerable Code
bash tmux send-keys -t <SESSION_NAME> "<PROMPT>" Enterpython terminal(command="cd <PROJECT_DIR> && <AGENT_CMD> <FLAGS> '<PROMPT>'", background=True, notify_on_complete=True)Technical Analysis
The documented command templates directly interpolate prompt text, paths, session names, executable names, and flags into shell command strings or tmux keystrokes.
In the
terminalexample, a prompt containing a single quote followed by shell syntax can terminate the quoted argument and append an unintended command. Shell metacharacters in other interpolated fields, includingPROJECT_DIR,AGENT_CMD, orFLAGS, can similarly alter command structure.The tmux example sends the interpolated prompt as terminal input followed by
Enter. Embedded newlines or terminal control sequences could cause the target shell or interactive CLI to receive additional commands rather than one literal prompt. Although the document warns that quotes and newlines must be escaped, it does not provide or enforce a safe encoding mechanism.This is an insecure orchestration pattern rather than an embedded malicious payload. Exploitation occurs if an implementation follows these templates with attacker-controlled or insufficiently validated values.
Attack Path
- An attacker supplies a crafted task prompt, project path, session name, agent command, or flags value.
- Hermes inserts that value into one of the documented command templates without robust argument separation or validation.
- The shell interprets injected quotes, substitutions, separators, or redirections as command syntax; alternatively, tmux transmits injected newlines as additional terminal submissions.
- The injected ...[truncated 1355 chars]
- Remediation
View remediation
Remediation Suggestions
-
Avoid shell command construction
- Invoke processes with an argument array rather than a shell-formatted string.
- Pass the working directory through a dedicated
cwdparameter instead of constructingcd ... && .... - Disable shell interpretation whenever the execution API supports it.
-
Pass prompts through safe channels
- Supply prompts as a distinct process argument when the process API preserves argument boundaries.
- For large or multiline prompts, use standard input or a securely created temporary file.
- Create temporary files with restrictive permissions and remove them after use.
-
Harden tmux dispatch
- Do not interpolate arbitrary text into
tmux send-keys. - Store the exact prompt in a securely created file and use
tmux load-bufferfollowed bytmux paste-buffer. - Validate tmux target names against a strict allowlist and avoid forwarding terminal control characters.
- Deliberately send
Enteronly after the literal buffer has been pasted and the target pane has been verified.
- Do not interpolate arbitrary text into
-
Validate command components
- Resolve backend executables from a fixed allowlist such as
codex,kimi,claude,opencode, orgemini. - Represent flags as separately validated arguments rather than free-form strings.
- Validate session identifiers using a conservative character allowlist.
- Canonicalize and verify project paths before dispatch.
- Resolve backend executables from a fixed allowlist such as
-
Preserve approval controls
- Keep
--yolo, automatic approval, sandbox bypass, and equivalent options disabled by default. - Require explicit user confirmation immediately before using an approval-bypass mode.
- Display the resolved executable, working directory, session target, and structured arguments before side-effectful execution.
- Keep
-
Add adversarial tests
- Test prompts and paths containing single and double quotes, semicolons, command substituti ...[truncated 203 chars]
-
