T09 · Insecure Skill Coding Practices
- Location
scripts/audit.sh:181- Finding
Predictable Temporary Output File Allows Symlink-Based File Overwrite
- Content
View full analysis
Vulnerability Details
File Location:
scripts/audit.sh, lines 181–182
Vulnerability Type: Predictable temporary file and symlink-following file overwrite
Risk Level: MediumVulnerable Code:
bash local output_file="/tmp/skill-audit-${skill_name}-suspicious.txt" cp "$SUSPICIOUS_CODE" "$output_file"Technical Analysis
The script constructs an output path in the shared
/tmpdirectory using a predictable filename derived fromskill_name. It then copies suspicious source content to that path without securely creating the destination, checking whether it is a symbolic link, or restricting its permissions.Because
cpfollows a destination symbolic link, another local user may pre-create the predictable path as a symlink to a file writable by the account running the audit. When suspicious code is found, the copy operation overwrites the symlink target.The generated output is not included in the script's cleanup trap, so scanned source lines may also remain in
/tmpafter execution. Depending on the process umask and existing destination, this can expose potentially sensitive source content to other local users.Attack Path
- The attacker predicts the output path from the audited directory or skill name, such as
/tmp/skill-audit-example-suspicious.txt. - The attacker creates that path as a symbolic link to a target file writable by the audit user's account.
- The attacker causes or waits for the user to audit a skill containing a pattern that is copied into
SUSPICIOUS_CODE. - During LLM analysis, the script executes
cp "$SUSPICIOUS_CODE" "$output_file". cpfollows the attacker-created symbolic link and overwrites the target with the collected source lines.
Exploitation requires local access sufficient to create entries in
/tmp, knowledge or prediction of the skill name, and a target file writable by the account running the scanner.Impact Assessment
A succes ...[truncated 652 chars]
- The attacker predicts the output path from the audited directory or skill name, such as
- Remediation
View remediation
Remediation Suggestions
- Create the output with
mktemprather than deriving a predictable path from the skill name:bash local output_file output_file=$(mktemp "${TMPDIR:-/tmp}/skill-audit-suspicious.XXXXXX") || return 1 chmod 600 "$output_file" cp -- "$SUSPICIOUS_CODE" "$output_file" - Prefer a private temporary directory created with
mktemp -d, verify that creation succeeds, and store all audit artifacts inside it. - Add every generated artifact to the exit cleanup routine unless the user explicitly requests retention.
- If retained output is required, create it atomically with restrictive permissions and refuse to use an existing path or symbolic link.
- Do not execute this scanner as root or another privileged account unless strictly necessary.
- Avoid incorporating attacker-controlled skill names into filesystem paths. If a display-oriented name must be retained, sanitize it and keep it separate from the securely generated filename.
- Create the output with
