subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
with open(PID_FILE, 'r') as f: pid = f.read().strip() try: subprocess.run(['kill', pid], check=False) PID_FILE.unlink() print(f"✅ 服务已停止 (PID: {pid})") except Exception as e:- Confidence
- 88% confidence
- Finding
- The script reads a PID from a writable file and passes it to kill without validating that it is numeric, current, and belongs to the expected child process. An attacker who can modify .service.pid could cause termination of an unintended local process, creating a denial-of-service condition.
