T09 · Insecure Skill Coding Practices
- Location
scripts/pdf-extract.sh:73- Finding
Caller-Controlled Output Path Allows Arbitrary File Overwrite
- Content
View full analysis
"$OUTPUT" echo "[pdf-extract] Output written to: $OUTPUT" >&2 else cat fi } ``` ### Technical Analysis The `--output` argument is caller-controlled and is not subject to path canonicalization, destination-directory restrictions, existing-file checks, file-type validation, or symbolic-link protection. The redirection `cat > "$OUTPUT"` creates the destination if it does not exist and truncates it if it does. Quoting the variable prevents shell command injection but does not prevent unsafe filesystem access. Shell redirection also follows symbolic links, so a path that appears to be an ordinary output file may resolve to another file elsewhere on the system. The data written to the target is extracted from the supplied PDF. An attacker who can influence both the input PDF and the script arguments can therefore control, at least substantially, the content written to the selected file. ### Attack Path 1. An attacker supplies or identifies a PDF whose extracted text contains content suitable for a targeted text-based file. 2. The attacker induces the agent or another caller to run the Skill with `--output` or `-o` pointing to: - an existing file writable by the Skill process, - a sensitive path writable under the process privileges, or - a symbolic link that resolves to such a file. 3. The script processes the PDF and passes the extracted text to `output_text`. 4. `cat > "$OUTPUT"` follows any symbolic link and truncates or creates the resolved dest ...[truncated 1202 chars]- Remediation
View remediation
