T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:41
- Finding
- Command Injection Through Unsafely Interpolated TTS Text<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 41-64 **Vulnerability Type**: Shell command injection through unsafe user-input interpolation **Risk Level**: High ### Vulnerable Code ```bash # Slow version (speed 0.75) curl -s -X POST https://api.senseaudio.cn/v1/t2a_v2 \ -H "Authorization: Bearer $SENSEAUDIO_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"model\": \"SenseAudio-TTS-1.0\", \"text\": \"<TEXT>\", \"stream\": false, \"voice_setting\": { \"voice_id\": \"<VOICE_ID>\", \"speed\": 0.75 }, \"audio_setting\": { \"format\": \"mp3\" } }" -o slow.json jq -r '.data.audio' slow.json | xxd -r -p > standard_slow.mp3 # Normal version (speed 1.0) curl -s -X POST https://api.senseaudio.cn/v1/t2a_v2 \ -H "Authorization: Bearer $SENSEAUDIO_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"model\": \"SenseAudio-TTS-1.0\", \"text\": \"<TEXT>\", \"stream\": false, \"voice_setting\": { \"voice_id\": \"<VOICE_ID>\", \"speed\": 1.0 }, \"audio_setting\": { \"format\": \"mp3\" } }" -o normal.json jq -r '.data.audio' normal.json | xxd -r -p > standard_normal.mp3 ``` ### Technical Analysis The practice text originates from the user and is placed inside a double-quoted shell argument. The instructions do not require JSON-safe serialization or shell-safe handling before replacing `<TEXT>`. A quotation mark in the supplied text can terminate the surrounding shell string. Shell operators, substitutions, or additional commands following that quotation mark may then be interpreted by the command shell. Ordinary text containing quotation marks or backslashes can also produce malformed JSON even when it is not intentionally malicious. The same issue applies to `<VOICE_ID>` if that value ever becomes externally controllable. This vulnerability is present when an agent or runner implements the documented command by directly replacing the placeholders and invokes it through a shell. ## ...[truncated 912 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Never construct JSON by concatenating user-controlled text into a shell command. - Store the text in a shell variable and use `jq` to serialize it: ```bash payload="$( jq -n \ --arg text "$TEXT" \ --arg voice_id "$VOICE_ID" \ --argjson speed 0.75 \ '{ model: "SenseAudio-TTS-1.0", text: $text, stream: false, voice_setting: {voice_id: $voice_id, speed: $speed}, audio_setting: {format: "mp3"} }' )" curl --fail-with-body --silent --show-error \ -X POST 'https://api.senseaudio.cn/v1/t2a_v2' \ -H "Authorization: Bearer $SENSEAUDIO_API_KEY" \ -H 'Content-Type: application/json' \ --data-binary "$payload" \ --output "$output_file" ``` - Execute commands using an argument-array API rather than constructing a command string for `sh -c`. - Keep voice identifiers on an explicit allowlist. - Check the HTTP status and validate the response schema before decoding audio. - Apply reasonable input-length limits to prevent resource exhaustion and unexpectedly large API requests. ]]>
