T09 · Insecure Skill Coding Practices
- Location
validation.md:40- Finding
Predictable Temporary Files Permit Symlink-Based File Clobbering
- Content
View full analysis
Vulnerability Details
File Location:
validation.md, lines 40–41
Vulnerability Type: Predictable temporary-file creation and unsafe shell redirection
Risk Level: MediumVulnerable Code
bash extract_entities "$original" > /tmp/orig_ents extract_entities "$reconstructed" > /tmp/recon_entsTechnical Analysis
The documented validation commands write to fixed, globally predictable paths in
/tmp. On a shared system, an attacker can pre-create either path as a symbolic link to another file writable by the user running the skill.Standard shell output redirection follows symbolic links and opens the linked target with truncation enabled. Consequently, running either command can overwrite the symlink target with the output of
extract_entities. The fixed names also allow concurrent validation runs to overwrite one another, potentially corrupting or manipulating validation results.Although these commands appear in documentation rather than an executable script, an agent or user following the skill instructions may execute them directly.
Attack Path
- The attacker has local access to the same host and can write to
/tmp. - The attacker predicts the documented path, such as
/tmp/orig_ents. - Before validation begins, the attacker creates a symbolic link:
bash ln -s /path/to/victim-writable-file /tmp/orig_ents - The victim or agent executes the documented validation command.
- Shell redirection follows the symbolic link and truncates or overwrites the linked file using the victim's privileges.
- Alternatively, the attacker races or replaces the temporary files to inject fabricated entity data and influence the subsequent comparison.
Impact Assessment
Successful exploitation permits file clobbering within the permissions of the account running the validation procedure. It does not independently grant higher privileges, but it can corrupt user-owned data, application configuration, or other writable ...[truncated 318 chars]
- The attacker has local access to the same host and can write to
- Remediation
View remediation
Remediation Suggestions
Create a unique private temporary directory, store all intermediate files inside it, and ensure cleanup occurs on every exit path:
bash tmpdir="$(mktemp -d)" || { printf '%s\n' "Failed to create a temporary directory" >&2 exit 1 } chmod 700 "$tmpdir" trap 'rm -rf -- "$tmpdir"' EXIT HUP INT TERM extract_entities "$original" > "$tmpdir/orig_ents" extract_entities "$reconstructed" > "$tmpdir/recon_ents" diff -- "$tmpdir/orig_ents" "$tmpdir/recon_ents"Additional hardening measures:
- Do not use fixed filenames in shared temporary directories.
- Check the exit status of
mktemp, extraction commands, anddiff. - Run the validation process with least privilege.
- Prefer in-memory pipelines where persistent intermediate files are unnecessary.
- If direct file creation is unavoidable, use exclusive creation semantics and reject symbolic links.
