T09 · Insecure Skill Coding Practices
- Location
SKILL.md:192- Finding
Unsafe Cross-Session Temporary Audio File Discovery
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 192-195
Vulnerability Type: Unsafe temporary-file handling and file substitution
Risk Level: MediumVulnerable Code
markdown **2. Find the LATEST file (⚠️ CRITICAL - always use the newest file!):** ```bash find /tmp/openclaw/tts-* /tmp/tts-* -name "*.opus" -o -name "*.mp3" -o -name "*.ogg" 2>/dev/null | xargs ls -t | head -1text ### Technical Analysis The documented workflow locates generated audio by scanning broad, predictable paths under `/tmp` and selecting whichever matching file has the newest timestamp. It does not bind the selected file to the current `tts` invocation or verify its owner, permissions, canonical path, session directory, or provenance. This creates a time-of-check/file-substitution weakness in environments where another user, process, or concurrent session can create files or directories matching `/tmp/openclaw/tts-*` or `/tmp/tts-*`. The legacy `/tmp/tts-*` search path further expands the trust boundary despite the document warning that old files may exist there. The `find` expression also lacks parentheses around its alternative filename conditions. Because `find` operators have precedence rules, the intended path behavior is ambiguous and the error-redirection action is not consistently associated with every alternative. Passing results through non-null-delimited `xargs` additionally mishandles filenames containing whitespace, quotes, or newlines. The selected path is subsequently copied into the workspace and sent through the `message` tool. Consequently, file discovery is security-sensitive rather than merely an audio-selection reliability issue. ### Attack Path 1. The attacker or a concurrent untrusted process gains the ability to create a matching temporary directory or file under `/tmp/openclaw/tts-*` or `/tmp/tts-*`. 2. The attacker places an `.opus`, `.mp3`, or `.ogg` file in that location and gives it a modification time newer than the leg ...[truncated 961 chars]- Remediation
View remediation
Remediation Suggestions
- Use the exact output path returned by the current
ttsinvocation instead of searching global or cross-session temporary locations. - Create a unique private directory for each operation using a secure facility such as
mktemp -d, and set its permissions to0700. - Restrict all discovery, conversion, copying, and cleanup operations to that private directory.
- Before sending the file, validate that:
- Its canonical path remains inside the expected session directory.
- It is a regular file and not a symbolic link.
- It is owned by the expected user.
- It was created as part of the current operation.
- Its extension and actual media format are expected.
- Do not include the legacy
/tmp/tts-*path in discovery. - If enumeration is unavoidable, group the
findconditions and use null-delimited processing, for example:
bash find "$PRIVATE_TTS_DIR" -type f \ \( -name '*.opus' -o -name '*.mp3' -o -name '*.ogg' \) \ -print0- Pass the validated path directly to
ffmpeg,cp, and the messaging operation without reparsing it through whitespace-delimitedxargs. - Correct the separate malformed copy example at
SKILL.md:208so that it uses a valid, explicitly quoted workspace path.
- Use the exact output path returned by the current
