subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
"""Execute command on IAP via SSH""" try: cmd = f'echo "{self.password}" | sshpass -p stdin ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 {self.username}@{self.ap_ip} "{command}"' result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=60) return result.stdout except subprocess.TimeoutExpired: return "ERROR: Connection timeout"- Confidence
- 99% confidence
- Finding
- The script builds a shell command from untrusted values including username, password, AP IP, and command, then executes it with shell=True. This creates a command injection path and also exposes credentials through shell invocation and process arguments, making compromise of the host running the backup plausible.
