T09 · Insecure Skill Coding Practices
- Location
SKILL.md:73- Finding
Command Injection Through Unquoted User-Controlled File Paths
- Content
View full analysis
) && cp ~/.writing-style-iterator/drafts/ && git -C ~/.writing-style-iterator add . && git -C ~/.writing-style-iterator commit -m "draft: " ``` ### Technical Analysis The command template inserts a user file path and filename directly into shell syntax without quoting or separating the values from the command. The path is used inside command substitution, as a `cp` argument, as part of a destination path, and in a Git commit message. If an agent replaces these placeholders with an untrusted path and submits the resulting string to a shell, spaces and shell metacharacters can change the command's meaning. Characters such as semicolons, redirections, command substitutions, and option prefixes can produce additional commands or alter the behavior of `dirname`, `cp`, or `git`. Using `&&` does not provide atomicity and does not prevent injection. It only controls whether the following command runs based on the preceding command's exit status. ### Attack Path 1. An attacker supplies, creates, or induces the use of a crafted output filename or absolute path. 2. The agent substitutes the path into the documented command template. 3. The agent executes the constructed command through a shell. 4. The shell interprets metacharacters embedded in the path as syntax rather than as literal filename characters. 5. Attacker-selected commands execute with the same operating-system privileges as the agent process. For example, a path containing a shell command separator could terminate the intended `cp` argument and append another command when the agent builds a raw sh ...[truncated 686 chars]- Remediation
View remediation
