subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_cmd(cmd: str, timeout: int = 30) -> tuple[bool, str]: try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) return result.returncode == 0, result.stdout + result.stderr except Exception as e: return False, str(e)- Confidence
- 92% confidence
- Finding
- The helper executes shell commands with shell=True, which is dangerous because any future untrusted input interpolated into cmd can trigger command injection. In this file, open_page builds a shell command using a URL argument, so the unsafe wrapper is not purely theoretical even if the current caller passes a constant URL.
