T09 · Insecure Skill Coding Practices
- Location
scripts/batch_transcribe.sh:150- Finding
Arbitrary Command Injection Through Batch Transcription Arguments and Filenames
- Content
View full analysis
/dev/null; then echo " ✓ 完成: $output_file" SUCCESS_COUNT=$((SUCCESS_COUNT + 1)) else ``` ### Technical Analysis The script builds a shell command as a string using values derived from command-line arguments and audio filenames. It subsequently passes that string to `eval`, which causes the shell to parse all embedded content a second time. The apparent double quotes embedded in `cmd` do not provide a security boundary after attacker-controlled data has already been concatenated into the command string. Shell metacharacters, command substitutions, escaped quotation marks, or separators present in values such as `MODEL`, `LANGUAGE`, `OUTPUT_DIR`, or `audio_file` can become executable shell syntax during the `eval` operation. The affected inputs include: - Model names supplied through `--model` - Language values supplied through `--language` - Device and compute-type values - Output-directory-derived filenames - Audio filenames discovered in the input directory ### Attack Path 1. An attacker creates an audio file with a filename containing shell syntax, or convinces a user to invoke the batch script with a malicious option value. 2. The script accepts the value without restricting it to a safe character set. 3. The value is interpolated into the `cmd` string. 4. `eval "$cmd"` reparses the attacker-controlled content as shell ...[truncated 924 chars]- Remediation
View remediation
/dev/null; then echo " ✓ Complete: $output_file" else echo " ✗ Failed: $filename" fi ``` Additional hardening should include: 1. Validate `MODEL` and `LANGUAGE` against explicit allowlists where practical. 2. Validate `DEVICE` and `COMPUTE_TYPE` against the choices accepted by `transcribe.py`. 3. Use `--` before positional filenames where supported to prevent filenames beginning with a hyphen from being interpreted as options. 4. Add regression tests using filenames containing spaces, quotation marks, semicolons, command substitutions, and newline characters. 5. Do not replace `eval` with an unquoted string expansion; only direct array execution reliably preserves argument boundaries. ]]>
