T09 · Insecure Skill Coding Practices
- Location
SKILL.md:55- Finding
Shell Command Injection Through an Interpolated PDF Path
- Content
View full analysis
" "./output/extracted" ``` ### Technical Analysis The workflow instructs the agent to substitute the user-provided PDF path directly into a shell command. Although the path is enclosed in double quotes, no shell-safe encoding or validation of shell metacharacters is required. A filename containing a double quote can terminate the quoted argument. Subsequent shell operators can then introduce additional commands. Merely checking that the original path exists does not make it safe to interpolate into a shell command. For example, a path containing a sequence conceptually equivalent to: ```text /tmp/report"; id; #.pdf ``` could cause the generated shell command to be interpreted as multiple commands rather than as one Python invocation. The PDF extraction may fail, but the injected command can still execute. The flaw arises in the agent-facing workflow rather than in `extract_pdf.py`, which reads its path from `sys.argv` without invoking a shell. ### Attack Path 1. An attacker creates or supplies a PDF whose path contains a quotation mark and shell-control characters. 2. The attacker invokes the Skill with that path as the first non-option argument. 3. The workflow verifies that the attacker-controlled path exists. 4. The agent substitutes the path into the documented Bash command without shell-safe encoding. 5. The embedded quotation mark terminates the intended argument. 6. The shell interprets the remaining text as additional commands. 7. The injected commands execute with the same operating-system privileges and environment available to the agent. ### Impact Assessment Successful exploitation permits arbitrary command execution under the account running the agent. Depending on that acco ...[truncated 528 chars]- Remediation
View remediation
