subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
async def action_shutdown(): """Shutdown the system.""" try: subprocess.Popen(["sudo", "shutdown", "-h", "now"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) return {"status": "ok", "message": "System is shutting down..."} except Exception as e: raise HTTPException(500, f"Failed to shutdown: {e}")- Confidence
- 99% confidence
- Finding
- This endpoint launches sudo shutdown -h now from an HTTP route, enabling remote triggering of a host power-off if the route is reachable and authorized insufficiently elsewhere. In a monitoring app, exposing destructive OS control is especially dangerous because it exceeds the stated purpose and can cause immediate denial of service.
