CVE-2024-35198: TorchServe vulnerable to bypass of allowed_urls configuration
TorchServe before 0.11.0 can be tricked past its `allowed_urls` check by a model URL containing `..`. The server rejects the request but still downloads the model archive into the model store, and the file can then be loaded by name with no URL. Upgrade to torchserve 0.11.0. Amazon SageMaker and EKS PyTorch inference containers are not affected.
Published Jul 18, 2024 · Updated Aug 7, 2024 · Analysis Nov 1, 2026
What an attacker can do
The allowed_urls setting limits which locations a model archive (.mar) may be fetched from when someone registers a model. The check failed for URLs with relative path pieces. In the pull request's test, a request for file:///../... returned Relative path is not allowed in url: with a 404, but the file was already copied into model_store.
Once the archive sits in the model store, a second registration call can name it without any URL, so the allow-list is never consulted. An attacker who can reach the management API can therefore bring in a model archive from a source the operator forbade. A model archive carries handler code that TorchServe runs, so this can become code execution on the inference host. That is why the vector is critical: network access, no privileges, no interaction. The attack needs access to the management API, which defaults to port 8081.
Who is affected
Affected: torchserve < 0.11.0. Servers that expose the management API to untrusted networks, or that use allowed_urls as their only control over what can be registered, are most at risk. Amazon SageMaker and EKS inference deep learning containers are stated as not affected.
pip show torchserve
torchserve --versionReview the allowed_urls line in your config.properties as well.
torchserve
- Ecosystem
- PyPI
- Affected
- < 0.11.0
- Fixed in
- 0.11.0
- Check
pip show torchserve
How to fix it
Upgrade to torchserve 0.11.0.
pip install --upgrade "torchserve>=0.11.0"The fix, pull request 3082, validates the URL for characters such as .. before anything is downloaded, so a rejected request no longer leaves a file in model_store. The allowed_urls pattern itself is unchanged. The advisory gives no workaround; limit access to the management API in the meantime.
How to tell if you were hit
Inspect the model store directory for .mar files you did not put there, especially ones with recent timestamps. Search TorchServe logs for Relative path is not allowed in url: entries, which mark attempts, and for model registrations that follow without a URL. Review who called the management API's register endpoint and from which address.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Impact
TorchServe's check on allowed_urls configuration can be by-passed if the URL contains characters such as ".." but it does not prevent the model from being downloaded into the model store. Once a file is downloaded, it can be referenced without providing a URL the second time, which effectively bypasses the allowed_urls security check. Customers using PyTorch inference Deep Learning Containers (DLC) through Amazon SageMaker and EKS are not affected.
Patches
This issue in TorchServe has been fixed by validating the URL without characters such as ".." before downloading: #3082.
TorchServe release 0.11.0 includes the fix to address this vulnerability.
References
Thank Kroll Cyber Risk for for responsibly disclosing this issue.
If you have any questions or comments about this advisory, we ask that you contact AWS Security via our vulnerability reporting page or directly via email to [[email protected]](mailto:[email protected]). Please do not create a public GitHub issue.
Questions
- Why does a rejected request still matter in CVE-2024-35198?
The 404 was returned after the download had already happened. The archive stayed in the model store, and a later registration by file name skips the URL check.
- Are SageMaker and EKS deployments affected?
The advisory says customers using PyTorch inference Deep Learning Containers through Amazon SageMaker and EKS are not affected.
- Does this need access to the management API?
Yes, the attacker must be able to send registration requests. Restricting that API to trusted hosts reduces exposure, but upgrading to 0.11.0 is the fix.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More TorchServe vulnerabilities
All TorchServe entriesCVE-2024-6577
TorchServe script references S3 bucket without ensuring ownership or confirming accessibility
medium6.3No fixMar 20, 2025CVE-2024-35199
TorchServe gRPC Port Exposure
high8.2Jul 18, 2024CVE-2023-48299
TorchServe ZipSlip
medium5.3Nov 21, 2023CVE-2023-43654
TorchServe Server-Side Request Forgery vulnerability
critical9.8Oct 2, 2023GHSA-4mqg-h5jf-j9m7
TorchServe Pre-Auth Remote Code Execution
critical9.9Oct 2, 2023
