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
- 82% confidence
- Finding
- The code extracts a PID from untrusted netstat output using loose string matching and immediately passes it to taskkill. While this is not shell injection, weak parsing could terminate the wrong process if output is malformed, ambiguous, or unexpectedly matched, causing local denial of service or disruption of unrelated applications.
