T09 · Insecure Skill Coding Practices
- Location
SKILL.md:29- Finding
Predictable Shared Temporary File Enables Symlink and Data-Tampering Attacks
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 29-40
Vulnerability Type: Predictable and insecure temporary-file handling
Risk Level: MediumVulnerable Code:
markdown Write the problem definition + selected method to a temp file, read it back, then execute the investigation. 1. Define the problem in writing 2. Select 1-3 methods from the 20-method catalog below 3. Write problem + method + plan to a temp file 4. Read it back 5. Execute the plan step by step ## Phase 1: Define the Problem Write to `/tmp/debug-rca.md`:Technical Analysis
The Skill requires every invocation to use the fixed path
/tmp/debug-rca.md. On multi-user systems,/tmpis normally shared and writable by unprivileged local users. A predictable filename can be created in advance by another process or replaced with a symbolic link.Because the workflow writes the investigation plan and then reads it back as instructions to execute, the issue presents two distinct risks:
- A symbolic link may redirect the write operation to another file accessible under the Agent's privileges.
- Another process may replace or modify the temporary file between the write and read operations, causing the Agent to consume attacker-controlled investigation instructions.
Debugging records may also contain internal paths, error messages, configuration details, input data, or credentials copied from diagnostic output. The instructions do not require restrictive permissions, ownership validation, secret redaction, atomic access, or cleanup.
Attack Path
- A local attacker predicts that the Skill will use
/tmp/debug-rca.md. - Before invocation, the attacker creates that path as a symbolic link to a file writable by the Agent, or creates a regular file that the attacker can subsequently modify.
- The Skill writes diagnostic information to the attacker-controlled path.
- In a symlink attack, the target file is o ...[truncated 1139 chars]
- Remediation
View remediation
Remediation Suggestions
- Create a unique temporary directory or file for every invocation using a cryptographically unpredictable name.
- Use a secure temporary-file API that creates the file atomically with exclusive-create semantics.
- Set permissions to owner-only access, such as mode
0600for a file and0700for a directory. - Do not close and reopen the file by pathname between writing and reading; retain the securely opened file descriptor when possible.
- Reject symbolic links and verify that the file is a regular file owned by the expected account.
- Redact credentials, tokens, personal information, and other secrets before writing diagnostic content.
- Delete the temporary file in a guaranteed cleanup step after the investigation.
- If persistence is unnecessary, keep the investigation plan in Agent-local memory rather than writing it to a shared file.
