T09 · Insecure Skill Coding Practices
- Location
SKILL.md:22- Finding
Predictable Shared Temporary Paths Permit Symlink and Race Attacks
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:22
Vulnerability Type: Predictable temporary-file usage
Risk Level: MediumVulnerable Code
markdown 2. **Write scripts to /tmp** - NEVER write test files to skill directory; always use `/tmp/playwright-test-*.js`The document also supplies predictable examples such as
/tmp/playwright-test-page.js,/tmp/screenshot.png, and/tmp/quick-screenshot.png, which are subsequently written or executed.Technical Analysis
The Skill mandates storing executable JavaScript and browser artifacts directly in the shared
/tmpdirectory using predictable names. It does not require a private randomized directory, exclusive file creation, ownership validation, restrictive permissions, or protection against symbolic links.On a multi-user system, another local process can predict these paths and pre-create a symbolic link or race the agent between file creation and execution. For executable test files, an attacker may replace or redirect the script before it is passed to
node run.js. For screenshots and other output files, a symbolic link may redirect the write to another file writable by the agent.Exploitation requires local access to the same host and permission to create entries in the shared temporary directory.
Attack Path
- The attacker observes the documented naming convention or predicts a filename such as
/tmp/playwright-test-page.js. - The attacker creates that path as a symbolic link, or repeatedly replaces it during the interval between the agent writing and executing the file.
- The agent follows the Skill instructions and writes a generated script to the predictable path.
- The agent executes that path through
node run.js. - Depending on the race outcome, attacker-controlled JavaScript may execute with the agent's privileges, or the generated content may be redirected to another writable target.
- A similar pre-creation att ...[truncated 639 chars]
- The attacker observes the documented naming convention or predicts a filename such as
- Remediation
View remediation
Remediation Suggestions
- Create a private randomized working directory with
fs.mkdtemp()rather than placing files directly under predictable/tmppaths. - Set directory permissions to
0700and script permissions to0600. - Create files atomically with exclusive-create semantics such as
O_CREAT | O_EXCL. - Reject symbolic links and verify file ownership and type with
lstat()before writing or executing a file. - Keep an open file descriptor from creation through writing where possible to reduce time-of-check/time-of-use races.
- Generate cryptographically random filenames for scripts, screenshots, traces, and downloads.
- Delete the private directory and all generated artifacts explicitly after execution.
- Do not execute a temporary script if its ownership, permissions, inode, or resolved path changes after creation.
- Create a private randomized working directory with
