subprocess module call
- Category
- Dangerous Code Execution
- Confidence
- 91% confidence
- Finding
This code builds a Python program as an f-string and passes user-influenced file paths into that code for execution via
python -c. Becauseimg_pathandseg_pathare embedded directly inside a generated code string, crafted path contents containing quotes or Python syntax could break out of the string literal and lead to arbitrary Python code execution.- Content
python sys.exit(r.returncode) """ ] result = subprocess.run(cmd, capture_output=True) if result.returncode == 0: size = os.path.getsize(seg_path) print(f" ✅ seg_{i:02d} ({dur}s)")
