T09 · Insecure Skill Coding Practices
- Location
prompts/workspace-prep.md:16- Finding
Shell Command Injection Through User-Controlled Document Paths
- Content
View full analysis
" ``` ### 2. Prepare the Markdown requirement document Check the requirement document format: **If it is a `.md` file**: - Use the Shell tool to copy the file to the output path ```bash cp "" "/" ``` ``` The original prompt uses localized placeholder names, but the operative commands are the `mkdir -p` and `cp` invocations shown above. ### Technical Analysis The workspace-preparation prompt instructs a subagent to interpolate the user-provided requirement path and derived document name directly into shell commands. Enclosing a value in double quotes does not make it safe for shell evaluation. Command substitutions using `$()` or backticks remain active inside double-quoted strings. Shell metacharacters that are interpreted during expansion can therefore result in command execution if an attacker-controlled path is inserted into the command without robust escaping. The source document path originates from user input, while the output directory is derived from the source filename. Consequently, both commands can process attacker-controlled text. The prompt does not require: - Canonicalization of the supplied path. - Validation of the filename against an allowlist. - Rejection of shell substitution syntax. - Argument-safe filesystem APIs. - Verification that the resolved destination remains under the intended `results/` directory. ### Attack Path 1. An attacker supplies a requirement document whose path or filename contains shell substitution syntax, such as: ```text docs/spec$(touch /tmp/skill-pwned).md ``` 2. The main Skill derives the output directory from this filename and passes the v ...[truncated 1420 chars]- Remediation
View remediation
