subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
if system == "Darwin": # macOS subprocess.run(["open", str(abs_path)], check=True) elif system == "Windows": subprocess.run(["start", "", str(abs_path)], shell=True, check=True) else: # Linux subprocess.run(["xdg-open", str(abs_path)], check=True) print(f"\n✓ HTML 报告已自动打开: {abs_path}", file=sys.stderr)- Confidence
- 95% confidence
- Finding
- On Windows, the script uses subprocess.run(..., shell=True) with a path influenced by user input via --output. Because shell=True routes execution through the command interpreter, a specially crafted output filename can trigger command injection or unintended command execution when the script tries to auto-open the generated report.
