T09 · Insecure Skill Coding Practices
- Location
scripts/transcribe.sh:117- Finding
Python Code Injection Through the User-Controlled Output Path
- Content
View full analysis
', '', line) # Remove HTML tags line = re.sub(r'<[^>]+>', '', line) # Deduplicate if line not in seen: seen.add(line) lines.append(line) text = ' '.join(lines) # Clean up whitespace text = re.sub(r'\s+', ' ', text).strip() with open('$OUT_FILE', 'w') as f: f.write(text + '\n') print(f'Transcript saved ({len(text)} chars)', file=sys.stderr) " 2>&1 ``` ### Technical Analysis The `--out` option is accepted as user-controlled input and stored in `OUT_FILE`. The value is subsequently interpolated directly into the source text passed to `python3 -c`. Shell quoting does not make this value safe in the generated Python program. An output path containing a single quote and additional Python syntax can terminate the string literal in: ```python with open('$OUT_FILE', 'w') as f: ``` The remainder of the supplied value can then introduce arbitrary Python statements. The injected Python runs with the same operating-system identity, filesystem permissions, environment, and network access as the transcription script. The vulnerability is reached when the subtitle fast path successfully downloads a nonempty VTT file. It does not require the OpenAI fallback path. ### ...[truncated 1016 chars]- Remediation
View remediation
