CVE-2023-43654: TorchServe: SSRF + RCE via unrestricted model URL loading
CRITICAL ACTIVELY EXPLOITED PoC AVAILABLE NUCLEI TEMPLATE CISA: ATTENDTorchServe ≤0.8.1 allows unauthenticated attackers to force the server to fetch arbitrary URLs and write files to disk via the management API—enabling SSRF, cloud metadata exfiltration, and RCE through malicious model deserialization. Upgrade to 0.8.2 immediately and restrict the management API (port 8081) to localhost or trusted internal networks. Audit every production ML serving deployment for external management API exposure now.
Risk Assessment
Severity is maximum: CVSS 9.8 with no authentication, no user interaction, and network-accessible attack vector. The PyTorch ecosystem is deployed in thousands of production ML inference environments. Default TorchServe configurations frequently expose the management API without restriction, making this trivially exploitable at scale. The combination of SSRF (cloud metadata theft, internal network pivoting) plus deserialization RCE elevates this from a configuration issue to a critical infrastructure threat for any organization running ML inference at scale.
Affected Systems
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| torchserve | pip | — | No patch |
Do you use torchserve? You're affected.
Severity & Risk
Attack Surface
Recommended Action
6 steps-
PATCH
Upgrade TorchServe to ≥0.8.2 immediately.
-
NETWORK
Firewall management API port 8081—bind to 127.0.0.1 only or restrict via network ACL. Production API port 8080 is separate and should also be reviewed.
-
CONFIGURE
Explicitly set
allowed_urlsin config.properties to a strict allowlist of trusted model registries—never leave as default wildcard. -
AUDIT
Scan infrastructure for exposed TorchServe management APIs using:
nmap -p 8081 <cidr>or cloud security posture tools. -
DETECT
Alert on outbound HTTP requests from ML serving hosts to unexpected destinations, particularly cloud metadata endpoints (169.254.169.254).
-
ROTATE
If exposure is confirmed, rotate all cloud credentials accessible from the affected host.
CISA SSVC Assessment
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2023-43654?
TorchServe ≤0.8.1 allows unauthenticated attackers to force the server to fetch arbitrary URLs and write files to disk via the management API—enabling SSRF, cloud metadata exfiltration, and RCE through malicious model deserialization. Upgrade to 0.8.2 immediately and restrict the management API (port 8081) to localhost or trusted internal networks. Audit every production ML serving deployment for external management API exposure now.
Is CVE-2023-43654 actively exploited?
Yes, CVE-2023-43654 is confirmed actively exploited and listed in CISA Known Exploited Vulnerabilities catalog.
How to fix CVE-2023-43654?
1. PATCH: Upgrade TorchServe to ≥0.8.2 immediately. 2. NETWORK: Firewall management API port 8081—bind to 127.0.0.1 only or restrict via network ACL. Production API port 8080 is separate and should also be reviewed. 3. CONFIGURE: Explicitly set `allowed_urls` in config.properties to a strict allowlist of trusted model registries—never leave as default wildcard. 4. AUDIT: Scan infrastructure for exposed TorchServe management APIs using: `nmap -p 8081 <cidr>` or cloud security posture tools. 5. DETECT: Alert on outbound HTTP requests from ML serving hosts to unexpected destinations, particularly cloud metadata endpoints (169.254.169.254). 6. ROTATE: If exposure is confirmed, rotate all cloud credentials accessible from the affected host.
What systems are affected by CVE-2023-43654?
This vulnerability affects the following AI/ML architecture patterns: Model serving infrastructure, ML inference pipelines, PyTorch production deployments, Multi-tenant ML platforms, Cloud-hosted AI/ML workloads.
What is the CVSS score for CVE-2023-43654?
CVE-2023-43654 has a CVSS v3.1 base score of 9.8 (CRITICAL). The EPSS exploitation probability is 91.65%.
Technical Details
NVD Description
TorchServe is a tool for serving and scaling PyTorch models in production. TorchServe default configuration lacks proper input validation, enabling third parties to invoke remote HTTP download requests and write files to the disk. This issue could be taken advantage of to compromise the integrity of the system and sensitive data. This issue is present in versions 0.1.0 to 0.8.1. A user is able to load the model of their choice from any URL that they would like to use. The user of TorchServe is responsible for configuring both the allowed_urls and specifying the model URL to be used. A pull request to warn the user when the default value for allowed_urls is used has been merged in PR #2534. TorchServe release 0.8.2 includes this change. Users are advised to upgrade. There are no known workarounds for this issue.
Exploitation Scenario
Adversary discovers an internet-exposed TorchServe management API (port 8081) via Shodan or targeted scanning. Without any credentials, they POST to `/models?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/` to steal AWS IAM role credentials via SSRF. With credentials in hand, they pivot to S3 buckets containing proprietary training data. For full RCE, they host a maliciously crafted PyTorch model file (.mar archive containing pickle payload) on an attacker-controlled server, then force TorchServe to download and load it—executing arbitrary OS commands with the privileges of the model server process, potentially gaining persistent access to the ML serving infrastructure.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H References
- packetstormsecurity.com/files/175095/PyTorch-Model-Server-Registration-Deserialization-Remote-Code-Execution.html Exploit 3rd Party VDB
- github.com/pytorch/serve/pull/2534 Issue
- github.com/pytorch/serve/releases/tag/v0.8.2 Release
- github.com/pytorch/serve/security/advisories/GHSA-8fxr-qfr9-p34w Vendor
- github.com/20142995/nuclei-templates Exploit
- github.com/OligoCyberSecurity/CVE-2023-43654 Exploit
- github.com/OligoCyberSecurity/ShellTorchChecker Exploit
- github.com/cyb3r-w0lf/nuclei-template-collection Exploit
- github.com/exo-exe/vuln-lab-windows Exploit
- github.com/giterlizzi/secdb-feeds Exploit
- github.com/honysyang/eleaipoc Exploit
- github.com/leoambrus/CheckersNomisec Exploit
- github.com/mdisec/mdisec-twitch-yayinlari Exploit
- github.com/nomi-sec/PoC-in-GitHub Exploit
- github.com/tanjiti/sec_profile Exploit
Timeline
Scanner Template Available
A Nuclei vulnerability scanner template exists for this CVE. You can scan your infrastructure for this vulnerability immediately.
View template on GitHubnuclei -t http/cves/2023/CVE-2023-43654.yaml -u https://target.example.com Related Vulnerabilities
CVE-2024-5452 9.8 pytorch-lightning: RCE via deepdiff Delta deserialization
Same package: torch CVE-2024-35198 9.8 TorchServe: URL bypass enables arbitrary model loading
Same package: torch CVE-2022-45907 9.8 PyTorch: RCE via unsafe eval in JIT annotations
Same package: torch CVE-2022-0845 9.8 pytorch-lightning: code injection enables full RCE
Same package: torch CVE-2024-48063 9.8 PyTorch: RCE via RemoteModule deserialization
Same package: torch
AI Threat Alert