subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_cmd(cmd, cwd=None): print(f"Running: {cmd}") result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True) if result.returncode != 0: print(f"Error executing {cmd}:\n{result.stderr}") return result.stdout.strip()- Confidence
- 91% confidence
- Finding
- The helper executes shell commands with shell=True, which turns any string passed into run_cmd into shell-interpreted input. In this file the current call sites are hardcoded git commands, but the design is unsafe and becomes exploitable if any repo path, command fragment, or future parameter is influenced by untrusted input or environment state.
