T09 · Insecure Skill Coding Practices
- Location
SKILL.md:35- Finding
Predictable Temporary File Enables Symbolic-Link File Clobbering
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 35
Vulnerability Type: Unsafe predictable temporary-file path
Risk Level: MediumVulnerable Code:
bash curl -s "wttr.in/Berlin.png" -o /tmp/weather.pngTechnical Analysis
The documented command writes downloaded content to the fixed path
/tmp/weather.png. Because/tmpis normally shared among local users, another user may create that path before the command runs. If the path is a symbolic link,curl -ofollows the link and writes the response into its target.This creates a time-of-check/time-of-use and predictable-file-name weakness. The command neither creates the destination atomically nor verifies that it is a regular file owned by the invoking user.
Attack Path
- A local attacker anticipates that a user or agent will execute the documented weather-image command.
- Before execution, the attacker creates
/tmp/weather.pngas a symbolic link to a file writable by the victim:bash ln -s /path/to/victim-writable-file /tmp/weather.png - The victim executes:
bash curl -s "wttr.in/Berlin.png" -o /tmp/weather.png curlfollows the symbolic link and replaces the target file's contents with the downloaded PNG response.- The target file is corrupted or replaced within the limits of the victim's filesystem permissions.
Exploitation requires local access, the ability to create the predictable path before the victim, and a useful target writable by the victim.
Impact Assessment
A successful attacker can overwrite or corrupt files writable by the user running the command. The flaw does not independently grant elevated privileges or bypass filesystem permissions; its scope is limited to the invoking user's existing write access. Depending on the selected target, consequences may include data loss, configuration corruption, or modification of user-level files.
- Remediation
View remediation
Remediation Suggestions
Replace the fixed shared path with a securely generated, user-private temporary file:
bash tmp_file="$(mktemp "${TMPDIR:-/tmp}/weather.XXXXXX.png")" || exit 1 trap 'rm -f -- "$tmp_file"' EXIT curl --fail --silent --show-error "https://wttr.in/Berlin.png" -o "$tmp_file"Additional hardening measures:
- Use
mktempso file creation is atomic and the name is unpredictable. - Retain restrictive permissions on the generated file.
- Use an explicit HTTPS URL to make the intended transport unambiguous.
- Use
--fail --show-errorso HTTP failures are reported instead of silently producing an invalid output file. - Remove the temporary file after use with a cleanup trap.
- If persistent output is required, write to a securely created temporary file and atomically move it to a destination in a directory controlled by the user.
- Use
