T09 · Insecure Skill Coding Practices
- Location
SKILL.md:191- Finding
Predictable Temporary File Path for Sensitive OCR Results
- Content
View full analysis
/.ocr.json` (e.g., `/tmp/receipt.ocr.json`). Use `tempfile.gettempdir()` for cross-platform code. - **Override**: if the user specifies an output path, use it. - **Always print the resolved absolute path** in your response so the user can locate the file. ``` ### Technical Analysis The Skill directs implementations to construct an OCR output path in the shared system temporary directory using the input filename stem. `tempfile.gettempdir()` only identifies a temporary directory; it does not securely create a unique file. The resulting path is predictable. For example, processing `receipt.pdf` would produce `/tmp/receipt.ocr.json`. If an implementation follows this instruction and opens the destination normally, another local process may pre-create the filename or replace it with a symbolic link before the OCR result is written. OCR output can contain the complete text and coordinates extracted from confidential documents. Unless the implementation explicitly creates the output atomically with restrictive permissions, the file may also be exposed through overly permissive process defaults. The unsafe behavior is an instruction in the Skill rather than executable code included in the repository. Exploitation therefore depends on the consuming agent implementing the documented output behavior without additional secure-file protections. ### Attack Path 1. An attacker with access to the same host predicts the output filename from the source document name, such as `/tmp/receipt.ocr.json`. 2. Before OCR processing completes, the attacker creates that file or creates a symbolic link at that path. 3. The agent follows the Skill instructions and writes the OCR response to th ...[truncated 1208 chars]- Remediation
View remediation
