subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_cmd(cmd): print(f"Running: {cmd}") result = subprocess.run(cmd, shell=True, capture_output=True, text=True) if result.returncode != 0: print(f"Error: {result.stderr}") return result.stdout- Confidence
- 92% confidence
- Finding
- The code invokes subprocess.run with shell=True, which is inherently risky because shell metacharacters are interpreted by the shell. In this file the current commands are hardcoded, so immediate exploitability is limited, but this helper creates an unsafe execution pattern that can become command injection if reused with variable input or modified commands.
