T09 · Insecure Skill Coding Practices
- Location
fetch-data.sh:10- Finding
Predictable CoinGecko data file permits symlink-based overwrite
- Content
View full analysis
/tmp/coins.json # 检查数据是否获取成功 if [ -s /tmp/coins.json ]; then echo "数据获取成功" ``` ### Technical Analysis The script writes API data to the fixed, globally predictable path `/tmp/coins.json`. Shell output redirection follows symbolic links and overwrites an existing target. On a multi-user system, another local user can create `/tmp/coins.json` as a symbolic link before the Skill runs. If the linked target is writable by the account executing the Skill, the script overwrites that target with the CoinGecko response. The nonempty-file check does not verify ownership, file type, or whether the path is a symbolic link. The same unsafe behavior is prescribed in `SKILL.md:17-22`, where fixed `/tmp/coins_part1.json` and `/tmp/coins_part2.json` paths are used. ### Attack Path 1. A local attacker predicts that the Skill will write `/tmp/coins.json`. 2. The attacker creates that path as a symbolic link to a file writable by the victim: ```bash ln -s /path/to/victim-writable-file /tmp/coins.json ``` 3. The victim executes `fetch-data.sh`. 4. The shell follows the symbolic link during `echo "$DATA" > /tmp/coins.json`. 5. The linked file is truncated and replaced with the API response. ### Impact Assessment An attacker can overwrite or corrupt files writable by the account running the Skill. This may cause denial of service, application configuration corruption, or report-data manipulation. The flaw does not independently allow overwriting files that the executing account lacks permission to modify, and no privilege escalation beyond that account was demonstrated. ]]>- Remediation
View remediation
