CVE-2023-43654
📋 TL;DR
TorchServe versions 0.1.0 to 0.8.1 have a critical vulnerability where the default configuration lacks proper input validation, allowing attackers to trigger remote HTTP download requests and write arbitrary files to disk. This can lead to remote code execution, system compromise, and data theft. All TorchServe deployments using default configurations are affected.
💻 Affected Systems
- PyTorch TorchServe
📦 What is this software?
Torchserve by Pytorch
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution leading to complete system compromise, data exfiltration, and lateral movement within the network.
Likely Case
Arbitrary file write leading to system compromise, model theft, or denial of service.
If Mitigated
Limited impact with proper URL restrictions and network segmentation in place.
🎯 Exploit Status
Public exploit code available via Packet Storm Security. Exploitation requires HTTP access to TorchServe instance.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 0.8.2
Vendor Advisory: https://github.com/pytorch/serve/security/advisories/GHSA-8fxr-qfr9-p34w
Restart Required: Yes
Instructions:
1. Backup current configuration and models. 2. Stop TorchServe service. 3. Upgrade to version 0.8.2 or later using pip: 'pip install torchserve==0.8.2'. 4. Restart TorchServe service.
🔧 Temporary Workarounds
Configure allowed_urls restriction
allManually configure allowed_urls in TorchServe configuration to restrict model download sources.
Edit config.properties and set 'allowed_urls=https://trusted-source.com'
🧯 If You Can't Patch
- Network segmentation: Isolate TorchServe instances from internet and untrusted networks.
- Implement strict firewall rules to limit inbound connections to TorchServe HTTP port.
🔍 How to Verify
Check if Vulnerable:
Check TorchServe version: 'torchserve --version'. If version is between 0.1.0 and 0.8.1 inclusive, system is vulnerable.
Check Version:
torchserve --version
Verify Fix Applied:
Verify version is 0.8.2 or later: 'torchserve --version'. Check config.properties for allowed_urls configuration.
📡 Detection & Monitoring
Log Indicators:
- Unusual model registration from external URLs
- File write operations to unexpected locations
- HTTP requests to model registration endpoint with URL parameters
Network Indicators:
- Outbound HTTP requests from TorchServe to unexpected domains
- Inbound requests to /models endpoint with URL parameters
SIEM Query:
source="torchserve.log" AND ("register-model" OR "model_url") AND NOT allowed_urls IN url
🔗 References
- http://packetstormsecurity.com/files/175095/PyTorch-Model-Server-Registration-Deserialization-Remote-Code-Execution.html
- https://github.com/pytorch/serve/pull/2534
- https://github.com/pytorch/serve/releases/tag/v0.8.2
- https://github.com/pytorch/serve/security/advisories/GHSA-8fxr-qfr9-p34w
- http://packetstormsecurity.com/files/175095/PyTorch-Model-Server-Registration-Deserialization-Remote-Code-Execution.html
- https://github.com/pytorch/serve/pull/2534
- https://github.com/pytorch/serve/releases/tag/v0.8.2
- https://github.com/pytorch/serve/security/advisories/GHSA-8fxr-qfr9-p34w