NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · TorchServe

CVE-2023-48299: TorchServe ZipSlip

mediumCVSS 3.1 5.3GHSA-m2mj-pr4f-h9jp

TorchServe from 0.1.0 up to 0.9.0 has a ZipSlip flaw in its model and workflow management API. A crafted archive can write files to any location the process can write to. TorchServe 0.9.0 validates archive paths before extraction.

Published Nov 21, 2023 · Analysis Nov 2, 2026

What an attacker can do

Through the model and workflow management API, a user can register an archive. TorchServe extracted its contents without checking each entry's path, so entries such as ../../x land outside the extraction directory, anywhere the TorchServe process has permission to write. This is the classic ZipSlip pattern (CWE-22).

The attacker needs to reach the management API, or to get the victim to load a booby-trapped model. The advisory stresses the second route: harmful code can hide inside open-source or public models downloaded from the internet, and run against machines serving them. The CVSS vector rates the network path as low complexity with no privileges or interaction, and the impact as low integrity only.

In practice, an arbitrary file write by a model server can overwrite configuration or scripts that are later executed, so the effect can go beyond the rated score. The advisory does not describe code execution or a specific chain. Oligo Security reported the flaw.

Who is affected

The pip package torchserve from 0.1.0 up to but not including 0.9.0. The risk is highest where the management API (the model and workflow registration endpoints) is reachable by untrusted users, or where you load models from public sources. Check your version:

pip show torchserve

torchserve

Ecosystem
PyPI
Affected
>= 0.1.0, < 0.9.0
Fixed in
0.9.0
Check
pip show torchserve

How to fix it

Upgrade to torchserve 0.9.0.

pip install -U "torchserve>=0.9.0"

The fix is pull request 2634, "fix zip slip". It validates the paths of files inside a zip archive before extracting them. The advisory lists no workaround. Until you upgrade, keep the management API off untrusted networks and load only models from sources you trust.

How to tell if you were hit

The advisory gives no indicators. Check files written outside the model store and temporary extraction directories by the TorchServe process, and recently changed files in locations the service account can write to. Inspect model archives with unzip -l and look for entries beginning with / or containing ../. Review management API logs for registration of models or workflows from unfamiliar sources.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Impact

Using the model/workflow management API, there is a chance of uploading potentially harmful archives that contain files that are extracted to any location on the filesystem that is within the process permissions. Leveraging this issue could aid third-party actors in hiding harmful code in open-source/public models, which can be downloaded from the internet, and take advantage of machines running Torchserve.

Patches

The ZipSlip issue in TorchServe has been fixed by validating the paths of files contained within a zip archive before extracting them: https://github.com/pytorch/serve/pull/2634

TorchServe release 0.9.0 includes fixes to address the ZipSlip vulnerability: https://github.com/pytorch/serve/releases/tag/v0.9.0

References

https://github.com/pytorch/serve/pull/2634 https://github.com/pytorch/serve/releases/tag/v0.9.0

Credit

We would like to thank Oligo Security 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

Which TorchServe versions are affected by CVE-2023-48299?

From 0.1.0 up to but not including 0.9.0. Version 0.9.0 is the first patched release.

How does the attack reach a server?

Through an archive passed to the model or workflow management API, or a malicious public model that someone downloads and registers. Paths inside the archive escape the extraction directory.

Can it execute code?

The advisory describes arbitrary file writes within process permissions and hiding harmful code in public models. It does not describe a code execution chain, though overwriting executed files could lead to one.

Is it exploited in the wild?

No source I read says so, and the entry has no CISA KEV 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 entries