T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:16
- Finding
- Shell Command Injection Through Unescaped Template Placeholders<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:16-19` and `SKILL.md:54` **Vulnerability Type**: Shell command injection caused by unsafe string interpolation **Risk Level**: High ### Vulnerable Code ```bash | Short task | `bash -lc 'cd <project> && claude --bare -p "<task>" --max-turns 10'` | | Long streaming task | `bash -lc 'cd <project> && claude --bare -p "<task>" --output-format stream-json --verbose --include-partial-messages --max-turns 30'` | | Full permissions | `bash -lc 'cd <project> && claude --bare -p "<task>" --dangerously-skip-permissions --output-format stream-json --verbose --include-partial-messages --max-turns 30'` | | Read-only analysis | `bash -lc 'cd <project> && claude --bare -p "<task>" --permission-mode plan --allowedTools "Read,Glob,Grep,LSP" --max-turns 10'` | ``` ```json { "command": "bash -lc 'cd <project> && claude --bare -p \"<task>\" --max-turns 10'", "host": "node", "node": "<your-node-id>", "background": true, "timeout": 600 } ``` ### Technical Analysis The documented templates insert `<project>` and `<task>` directly into a command interpreted by `bash -lc`. The project path is not quoted, while the task is placed inside nested shell and JSON quotation contexts without a defined escaping mechanism. If either value originates from an untrusted or insufficiently validated source, shell metacharacters, quote characters, command substitutions, or separators can escape the intended argument context. The shell then interprets the injected content as additional commands on the remote Node. Nested quoting does not provide a security boundary. In particular, inserting a double quote into the task can terminate the intended prompt argument, while an unquoted project value can directly introduce shell operators. ### Attack Path 1. An attacker influences the project path or delegated task supplied to the documented command template. 2. The attacker includes shell syntax that escapes the intended `cd` p ...[truncated 1043 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not construct shell commands through direct interpolation of project paths or task text. - Prefer a structured process-execution API that accepts an executable and argument array without invoking a shell. - If `bash -lc` is unavoidable, pass dynamic values as positional parameters rather than embedding them in the command: ```bash bash -lc 'cd -- "$1" && exec claude --bare -p "$2" --max-turns 10' bash "$project" "$task" ``` - Ensure the process API passes `"$project"` and `"$task"` as separate arguments rather than concatenating them into one command string. - Canonicalize the project path and require it to remain beneath an explicitly approved root directory. - Reject null bytes and other invalid path input, but do not rely on character denylisting as the primary shell-injection defense. - Keep the default agent permission set read-only or explicitly allowlisted. - Run remote agents in isolated, disposable environments with restricted filesystem and network access. ]]>
