T09 · Insecure Skill Coding Practices
- Location
index.mjs:6- Finding
Predictable Temporary Files Allow Symlink-Based File Overwrite
- Content
View full analysis
/tmp/reddit_tiodopave.json PIADA=$(python3 << 'PYEOF' import json, random try: with open('/tmp/reddit_tiodopave.json', 'r') as f: data = json.load(f) ``` ### Technical Analysis Both implementations use fixed, attacker-predictable paths inside the shared `/tmp` directory. Neither implementation securely creates the destination with exclusive semantics nor verifies that the path is a regular file owned by the current user. The Node.js `writeFileSync` operation and the shell redirection both follow symbolic links. A local attacker who can create one of these predictable paths before the skill runs may replace it with a symbolic link to another file writable by the victim account. Running the skill then truncates or overwrites the symlink target. The shell implementation has an additional time-of-check/time-of-use exposure because it writes the response and subsequently reopens the same shared path from Python. Another local process could replace or modify the file between those operations. ### Attack Path 1. A local attacker predicts that the victim will execute the skill. 2. The attacker creates `/tmp/last-joke.txt` or `/tmp/reddit_tiodopave.json` as a symbolic link to a file writable by the victim. 3. The victim invokes the Node.js or shell implementation. 4. The skill opens the predictable path while following the symbolic link. 5. The linked target is truncated and overwritten with a Reddit post ID or downloaded JSON. 6. For the shell implementation, an attacker may alternatively replace the J ...[truncated 984 chars]- Remediation
View remediation
