T09 · Insecure Skill Coding Practices
- Location
tts-responder.sh:7- Finding
Predictable Shared Temporary Files Permit Disclosure, Races, and File Clobbering
- Content
View full analysis
Vulnerability Details
File Location:
tts-responder.sh, lines 7–8, 20–23, 29, and 37
Vulnerability Type: Predictable and insecure temporary-file handling
Risk Level: MediumVulnerable Code
bash OUTPUT_WAV="/tmp/tts-output.wav" OUTPUT_OGG="/tmp/tts-output.ogg"bash piper --model "$VOICE" --output_file "$OUTPUT_WAV" --length_scale $(echo "$SPEED" | awk '{print 1/$1}') <<< "$TEXT" ffmpeg -y -i "$OUTPUT_WAV" -c:a libopus -b:a 32k -ar 48000 "$OUTPUT_OGG" > /dev/null 2>&1bash -F "voice=@${OUTPUT_OGG}" \bash rm -f "$OUTPUT_WAV"Technical Analysis
The script stores generated audio under fixed, globally predictable names in the shared
/tmpdirectory. It neither creates a private temporary directory nor securely creates and validates the output files before passing their paths to Piper and FFmpeg.Because the filenames are known in advance, another local user or process can pre-create, replace, inspect, or link these paths. In particular, symbolic-link or race-condition attacks may cause the audio tools to operate on attacker-selected files. The use of
ffmpeg -yexplicitly permits overwriting the destination without confirmation.Every invocation also shares the same filenames. Concurrent runs can overwrite or consume each other's intermediate files, potentially sending audio generated from the wrong input. Only the WAV file is deleted;
/tmp/tts-output.oggremains after execution and may disclose synthesized conversation content depending on file permissions and the process umask.Attack Path
- A local attacker predicts
/tmp/tts-output.wavor/tmp/tts-output.ogg. - Before or during execution, the attacker creates a symbolic link at one of those paths to a file writable by the victim account, or repeatedly replaces the path during processing.
- Piper or FFmpeg follows or operates on the attacker-controlled path. In the OG ...[truncated 1196 chars]
- A local attacker predicts
- Remediation
View remediation
Remediation Suggestions
Create a private temporary directory for each invocation, restrict its permissions, and remove it on every exit path:
bash umask 077 TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/tts-responder.XXXXXX")" trap 'rm -rf -- "$TMP_DIR"' EXIT HUP INT TERM OUTPUT_WAV="$TMP_DIR/output.wav" OUTPUT_OGG="$TMP_DIR/output.ogg"Additional hardening measures should include:
- Never reuse fixed temporary paths across invocations.
- Keep both generated files inside the private directory.
- Remove the entire directory through an
EXITtrap so cleanup also occurs after command failures. - Ensure output files are created with owner-only permissions.
- Avoid operating on paths that may have been replaced by untrusted local processes.
- Do not preserve the final OGG unless persistence is explicitly required; if it must be retained, place it in a private application-owned directory with restrictive permissions and a unique filename.
- Consider serialization or request-specific identifiers if the surrounding integration can launch concurrent jobs.
