GHSA-4mqg-h5jf-j9m7: TorchServe Pre-Auth Remote Code Execution
TorchServe 0.3.0 through 0.8.1 bundles SnakeYAML 1.31, a library with known unsafe deserialization problems. The advisory says this could let third parties run arbitrary code on the server. Pull request 2523 replaces it, and TorchServe 0.8.2 includes the change.
Published Oct 2, 2023 · Analysis Nov 2, 2026
What an attacker can do
TorchServe's Java frontend uses the SnakeYAML library to parse YAML. SnakeYAML 1.31 can construct arbitrary Java objects from YAML input, which is the classic route to remote code execution when an attacker controls the YAML. The advisory states the exposure as potential: the vulnerable library is present, and it could allow third parties to execute arbitrary code on the target system.
The CVSS 3.1 vector (AV:N, AC:L, PR:L, S:C) rates this 9.9 and shows a network attacker with low privileges and no user interaction, with a changed scope and full impact on confidentiality, integrity and availability. The advisory title calls it pre-auth, which differs from the low-privilege vector. Treat any TorchServe endpoint reachable by untrusted parties as at risk.
The sources do not name the exact request or YAML input that triggers deserialization. A successful attack would run code as the TorchServe process, which holds the loaded models, the model store and often cloud credentials for inference infrastructure.
Who is affected
The pip package torchserve from 0.3.0 up to, but not including, 0.8.2. Check the installed version:
pip show torchserveContainers built from AWS Deep Learning Container images also carry TorchServe, so check the TorchServe version inside the image. Deployments that expose the inference or management ports beyond a trusted network are the most exposed.
torchserve
- Ecosystem
- PyPI
- Affected
- >= 0.3.0, < 0.8.2
- Fixed in
- 0.8.2
- Check
pip show torchserve
How to fix it
Upgrade torchserve to 0.8.2:
pip install --upgrade torchserve==0.8.2The advisory also lists patched AWS Deep Learning Container image tags that ship TorchServe 0.8.2, including v1.9-pt-ec2-2.0.1-inf-gpu-py310 for x86 GPU. It gives no workaround besides upgrading, so until then restrict network access to the TorchServe ports.
How to tell if you were hit
Check which TorchServe version runs on each host and in each container image, and list any below 0.8.2 that listen on non-loopback addresses. For compromise signs, look for unexpected child processes of the TorchServe Java process, new files in the model store or temp directories, and outbound connections from the serving host to unknown addresses. The sources give no TorchServe log line that marks an exploit attempt.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Impact
Use of Open Source Library potentially exposed to RCE Issue: Use of a version of the SnakeYAML v1.31 open source library with multiple issues that potentially exposes the user to unsafe deserialization of Java objects. This could allow third parties to execute arbitrary code on the target system. This issue is present in versions 0.3.0 to 0.8.1. Mitigation: A pull request to address this issue has been merged - https://github.com/pytorch/serve/pull/2523. TorchServe release 0.8.2 includes this fix.
Patches
TorchServe release 0.8.2 includes fixes to address the previously listed issue:
https://github.com/pytorch/serve/releases/tag/v0.8.2
Tags for upgraded DLC release User can use the following new image tags to pull DLCs that ship with patched TorchServe version 0.8.2: x86 GPU
- v1.9-pt-ec2-2.0.1-inf-gpu-py310
- v1.8-pt-sagemaker-2.0.1-inf-gpu-py310
x86 CPU
- v1.8-pt-ec2-2.0.1-inf-cpu-py310
- v1.7-pt-sagemaker-2.0.1-inf-cpu-py310
Graviton
- v1.7-pt-graviton-ec2-2.0.1-inf-cpu-py310
- v1.5-pt-graviton-sagemaker-2.0.1-inf-cpu-py310
Neuron
- 1.13.1-neuron-py310-sdk2.13.2-ubuntu20.04
- 1.13.1-neuronx-py310-sdk2.13.2-ubuntu20.04
- 1.13.1-neuronx-py310-sdk2.13.2-ubuntu20.04
The full DLC image URI details can be found at: https://github.com/aws/deep-learning-containers/blob/master/available_images.md#available-deep-learning-containers-images
References
https://github.com/pytorch/serve/pull/2523 https://github.com/pytorch/serve/releases/tag/v0.8.2 https://github.com/aws/deep-learning-containers/blob/master/available_images.md#available-deep-learning-containers-images
Credit
We would like to thank Oligo Security for responsibly disclosing this issue and working with us on its resolution. If you have any questions or comments about this advisory, we ask that you contact AWS/Amazon Security via our vulnerability reporting page](https://aws.amazon.com/security/vulnerability-reporting)) or directly via email to [[email protected]](mailto:[email protected]). Please do not create a public GitHub issue.
Questions
- Is there a CVE id for this advisory?
This entry carries only the GitHub advisory id GHSA-4mqg-h5jf-j9m7. The data shows no CVE assigned.
- Is the flaw in TorchServe code or in a dependency?
In a dependency. TorchServe 0.3.0 to 0.8.1 ships SnakeYAML 1.31, which has unsafe Java object deserialization problems.
- Which version fixes it?
TorchServe 0.8.2, which includes pull request 2523.
- Is it exploited in the wild?
The sources do not say so, and the entry has no CISA catalog data.
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-35198
TorchServe vulnerable to bypass of allowed_urls configuration
critical9.8Jul 18, 2024CVE-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, 2023
