subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_cmd(cmd, timeout=60): """Run a shell command and return output.""" try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) return result.stdout.strip() except subprocess.TimeoutExpired: return ""- Confidence
- 99% confidence
- Finding
- The helper executes arbitrary shell strings with shell=True, and multiple callers interpolate user- or config-controlled values directly into those strings, including network CIDR, DNS server, and detected interface names. This creates direct command injection risk, and because scans may be prefixed with sudo, successful injection could execute attacker-controlled commands with elevated privileges.
