subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
for line in result.stdout.splitlines(): if f":{port}" in line and "LISTENING" in line: pid = line.strip().split()[-1] subprocess.run( ["taskkill", "/F", "/PID", pid], capture_output=True, timeout=5 )- Confidence
- 84% confidence
- Finding
- The code parses a PID from `netstat` output using a weak substring match on `:{port}` and then force-kills that PID. If an attacker can cause another process to listen on a matching port or influence ambiguous parsing, this logic may terminate the wrong process, creating a local denial-of-service condition and potentially disrupting unrelated applications.
