T09 · Insecure Skill Coding Practices
- Location
scripts/speak.sh:284- Finding
Sensitive speech text may persist after local TTS failure
- Content
View full analysis
Vulnerability Details
File Location:
scripts/speak.sh:284-295
Vulnerability Type: Incomplete temporary-file cleanup
Risk Level: MediumVulnerable Code
bash if [[ "$detected" == "kokoro" ]]; then input_path="$(mktemp /tmp/tts_input_XXXXXX.txt)" printf '%s' "$text" > "$input_path" cmd=(kokoro-tts "$input_path" "$output" --format "$format") [[ -n "$voice" ]] && cmd+=(--voice "$voice") [[ -n "$lang" ]] && cmd+=(--lang "$lang") cmd+=(--speed "$speed") "${cmd[@]}" rm -f "$input_path" exit 0 fiTechnical Analysis
The Kokoro backend writes the complete user-supplied speech text to a temporary file. Although
mktempprovides an unpredictable name and generally creates the file with restrictive permissions, cleanup occurs only afterkokoro-ttscompletes successfully.Because the script enables
set -e, a nonzero exit fromkokoro-ttsterminates the script beforerm -f "$input_path"executes. Process interruption or termination can produce the same result. Notrapis registered to provide cleanup on error or signal.The temporary file is therefore not inherently unsafe at creation time, but its lifecycle is not failure-safe. Speech input can include confidential or personal information and may remain as plaintext under
/tmpafter an unsuccessful invocation.Attack Path
- A user invokes the Skill with sensitive text and selects or automatically reaches the Kokoro backend.
- The script writes the complete text to
/tmp/tts_input_XXXXXX.txt. kokoro-ttsfails, is interrupted, or is deliberately terminated before returning successfully.- Due to
set -e, the script exits before executing the explicit removal command. - The plaintext file remains on disk.
- An actor who later obtains sufficient local access, or a privileged diagnostic, backup, or forensic process, can recover the speech content.
This does not directly grant elevated privileges. Exploitation requires local access compatibl ...[truncated 572 chars]
- Remediation
View remediation
Remediation Suggestions
Register cleanup immediately after creating the temporary file so it runs during normal exit, command failure, and common termination signals:
bash if [[ "$detected" == "kokoro" ]]; then input_path="$(mktemp "${TMPDIR:-/tmp}/tts_input_XXXXXX.txt")" cleanup_input() { rm -f -- "$input_path" } trap cleanup_input EXIT HUP INT TERM printf '%s' "$text" > "$input_path" cmd=(kokoro-tts "$input_path" "$output" --format "$format") [[ -n "$voice" ]] && cmd+=(--voice "$voice") [[ -n "$lang" ]] && cmd+=(--lang "$lang") cmd+=(--speed "$speed") "${cmd[@]}" cleanup_input trap - EXIT HUP INT TERM exit 0 fiAdditional hardening should include:
- Respecting
${TMPDIR:-/tmp}rather than hardcoding/tmp. - Explicitly applying restrictive permissions with
chmod 600 "$input_path"as defense in depth. - Avoiding disk-backed plaintext entirely if
kokoro-ttssupports standard input, pipes, or secure file descriptors. - Documenting that local processing can temporarily place speech text on disk.
- Respecting
