subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def check_command(cmd): try: subprocess.run(["command", "-v", cmd], check=True, capture_output=True, shell=True) return True except subprocess.CalledProcessError: return False- Confidence
- 96% confidence
- Finding
- The call to subprocess.run uses shell=True while passing a command lookup operation, which unnecessarily invokes a shell and creates command-injection risk if the command argument ever becomes attacker-controlled. Even though the current requirements list is hardcoded, this is still an unsafe pattern in setup code because future changes or refactoring could expose it, and the current invocation is also semantically incorrect for reliably checking shell builtins across platforms.
