T09 · Insecure Skill Coding Practices
- Location
video-summary.sh:374- Finding
Predictable Temporary Transcript Path Allows Symlink-Based File Overwrite
- Content
View full analysis
"$temp_file" TEMP_FILES+=("$temp_file") ``` ### Technical Analysis The script writes potentially sensitive transcript content to a predictable path based only on the process ID. It does not use atomic temporary-file creation, exclusive-open semantics, a private temporary directory, or a symlink check. On systems that do not enforce protections such as `fs.protected_symlinks`, another local user can predict or observe the process ID and create the expected path as a symbolic link before the redirection occurs. Shell redirection follows the link and writes the transcript into the linked destination. The permissions of the created file are also governed only by the caller's current `umask`. The script does not ensure that transcripts are readable only by the current user. ### Attack Path 1. A local attacker predicts or observes the PID of an upcoming `video-summary.sh` process. 2. The attacker creates `/tmp/video-summary-transcript-` as a symbolic link to a file writable by the victim. 3. The victim invokes the Skill and requests a summary. 4. `call_llm` executes `echo "$transcript" > "$temp_file"`. 5. The shell follows the attacker-created symbolic link. 6. The linked target is truncated and overwritten with transcript content. Modern operating-system symlink protections may block this attack in some configurations, but the script must not rely on optional host-level mitigation. ### Impact Assessment A local attacker may overwrite or corrupt an arbitrary file that the victim account is authorized to write. The attack does not directly grant root privileges unless the Skill is already running with elevated privileges, but its impact inherits all filesystem permissions of t ...[truncated 145 chars]- Remediation
View remediation
"$temp_file" ``` Additional hardening should include: 1. Use one `mktemp -d` workspace for all temporary artifacts. 2. Ensure the directory has mode `0700` and files have mode `0600`. 3. Never construct temporary paths from only `$$`, timestamps, or other predictable values. 4. Do not follow user-controlled symbolic links. 5. Use `printf` instead of `echo` when writing untrusted or arbitrary transcript data. 6. Remove the private workspace recursively during exit handling. ]]>
