T09 · Insecure Skill Coding Practices
- Location
scripts/reel-digest.py:25- Finding
Shell Command Injection Through User-Controlled URL and Output Paths
- Content
View full analysis
/dev/null') if os.path.exists(out_path): paths.append(out_path) return paths ``` ```python def extract_audio(video_path, output_path): run(f'ffmpeg -y -i "{video_path}" -vn -acodec pcm_s16le -ar 16000 -ac 1 "{output_path}" 2>/dev/null') return os.path.exists(output_path) ``` ### Technical Analysis The program constructs shell command strings using externally controlled values and invokes them with `shell=True`. Placing a value inside double quotes does no ...[truncated 2045 chars]- Remediation
View remediation
/dev/null`; use `stderr=subprocess.DEVNULL` instead. 4. Validate URLs before use: - Permit only required schemes such as `https`. - Reject control characters. - Consider restricting hosts where the use case permits it. 5. Validate and normalize output directories. Where user-selected paths are unnecessary, create a private temporary directory internally. 6. Add regression tests containing shell metacharacters, command substitutions, quotes, spaces, and newline characters to confirm that they are treated only as literal argument data. ]]>
