subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run(cmd, capture=True, timeout=30): try: r = subprocess.run(cmd, shell=True, capture_output=capture, text=True, timeout=timeout) return r.returncode, r.stdout.strip() if capture else "", r.stderr.strip() if capture else "" except subprocess.TimeoutExpired: return 1, "", "timeout"- Confidence
- 92% confidence
- Finding
- The helper wraps subprocess.run with shell=True, which means any string passed into run() is interpreted by the system shell. Even though current call sites use hardcoded commands, this creates a latent command-injection sink and normalizes unsafe process execution that could become exploitable if any future input reaches cmd.
