T09 · Insecure Skill Coding Practices
- Location
SKILL.md:156- Finding
Command Injection Through a Fixed Shell Heredoc Delimiter
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 156–176
Vulnerability Type: Shell command injection through generated content
Risk Level: Highbash # 1. Define the output path using a temporary directory and timestamp OUTDIR=$(mktemp -d) OUTFILE="$OUTDIR/podcast_$(date +%Y%m%d_%H%M%S).mp3" SCRIPTFILE="$OUTDIR/script.txt" # 2. Write the generated script cat > "$SCRIPTFILE" << 'SCRIPT' <generated script content> SCRIPT # 3. Locate the xfyun-tts script TTS_SCRIPT=$(openclaw skills path xfyun-tts 2>/dev/null || find ~/.openclaw -name "tts.py" -path "*/xfyun-tts/*" 2>/dev/null | head -1) # 4. Synthesize the audio python3 "$TTS_SCRIPT" \ --voice <selected VCN> \ --output "$OUTFILE" \ --speed 48 \ --volume 55 \ --file "$SCRIPTFILE" echo "$OUTFILE"Technical Analysis
The Skill instructs the agent to interpolate generated podcast text directly into a shell heredoc with the fixed delimiter
SCRIPT. Quoting the opening delimiter prevents parameter expansion, command substitution, and backslash processing within ordinary heredoc content. It does not, however, prevent a line containing onlySCRIPTfrom ending the heredoc.Podcast text is derived from user input and externally fetched search results. An attacker-controlled topic or prompt-injected search result could therefore cause the generated content to contain the terminator on its own line. Any subsequent generated lines would be parsed by the shell as commands rather than written to the script file.
The use of
mktemp -dand quoted file variables protects the temporary paths but does not address injection into the shell program itself.Attack Path
- An attacker supplies a crafted podcast request, or places malicious instructions in content retrieved by the Skill from a search engine.
- The untrusted content influences the generated podcast script.
- The resulting script includes a l ...[truncated 1003 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not interpolate model-generated or externally influenced content into executable shell source.
- Write the podcast text with a structured file-writing API that accepts the destination path and content as separate data values.
- If a subprocess must perform the write, pass the content through standard input to a fixed command rather than constructing a shell script around it.
- Avoid treating random or dynamically selected heredoc delimiters as the primary defense; delimiter collision checks are fragile and still leave generated content embedded in shell syntax.
- Keep the temporary directory creation through
mktemp -d, quote every path, and set restrictive permissions such asumask 077before creating files that may contain sensitive user content. - Treat fetched web content as untrusted data. Do not follow instructions embedded in search results, and ensure source material can influence only the podcast content—not tool selection, shell commands, file paths, or execution flow.
- Invoke the resolved TTS program using a direct process-execution API with an argument array rather than through a shell.
- Validate that the resolved TTS path points to the expected installed Skill directory and an approved regular file before execution.
