T09 · Insecure Skill Coding Practices
- Location
SKILL.md:32- Finding
Predictable Shared Temporary File Enables Cross-Session Audio Replacement
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 32–36
Vulnerability Type: Predictable and insecure temporary file usage
Risk Level: MediumVulnerable Code
bash ## Manual Execution (Internal) To respond with voice manually: ```bash bin/sherpa-onnx-tts /tmp/reply.ogg "Tu mensaje aquí"Then send
/tmp/reply.oggviamessagetool withfilePath.text ### Technical Analysis The manual workflow directs every invocation to write synthesized audio to the same predictable path, `/tmp/reply.ogg`, and subsequently sends that file to the user. Because `/tmp` is ordinarily shared and the filename is neither unique nor isolated per request, concurrent or malicious local activity can interfere with the output. Two principal exploitation conditions may arise: 1. **Request collision:** Concurrent skill executions can overwrite the same file. One conversation may consequently receive audio generated for another conversation. 2. **Filesystem pre-positioning:** A local attacker able to write in `/tmp` may create or replace the predictable path before generation or before transmission. Depending on how `sherpa-onnx-tts` opens output files and the process privileges, this may permit replacement of the transmitted audio or redirection through a symbolic link. The referenced TTS executable is not included in the audited project, so its symlink-handling behavior cannot be verified. Nevertheless, the documented use of a fixed shared temporary path creates a confirmed collision and file-substitution weakness. ### Attack Path 1. An attacker predicts the documented output path `/tmp/reply.ogg`. 2. The attacker pre-creates, replaces, or repeatedly modifies that path, or causes two skill requests to execute concurrently. 3. The skill invokes `bin/sherpa-onnx-tts` using the shared path. 4. Before the `message` tool reads the output, the attacker or another request replaces or overwrites the file. 5. ...[truncated 858 chars]- Remediation
View remediation
Remediation Suggestions
- Create a private temporary directory for each invocation using a secure facility such as
mktemp -d. - Generate a unique output filename within that directory rather than using a fixed path.
- Restrict directory and file permissions to the executing account, preferably with directory mode
0700and file mode0600. - Open output files using mechanisms that reject symbolic links and fail if a file already exists.
- Keep the unique path associated with the originating request so concurrent conversations cannot share output state.
- Send the file through an already-open descriptor where supported, or validate immediately before transmission that it remains a regular file owned by the expected account.
- Delete the generated audio and private temporary directory after transmission, including cleanup on error or cancellation.
- Pass TTS text as a structured process argument rather than constructing commands through shell interpolation.
A hardened shell workflow could use the following pattern:
bash tmp_dir="$(mktemp -d)" chmod 700 "$tmp_dir" trap 'rm -rf -- "$tmp_dir"' EXIT output_file="$tmp_dir/reply.ogg" bin/sherpa-onnx-tts "$output_file" "$reply_text" chmod 600 "$output_file"The resulting unique
output_fileshould then be supplied directly to the messaging tool for the corresponding request.- Create a private temporary directory for each invocation using a secure facility such as
