# CVE-2023-48299: TorchServe ZipSlip

> Attackers can upload malicious archives to TorchServe to extract files to arbitrary locations, potentially executing code or modifying data.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 21 Nov 2023
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-m2mj-pr4f-h9jp, PYSEC-2026-1972

## What is CVE-2023-48299?

CVE-2023-48299 is a medium-severity path traversal vulnerability in pytorch serve, published on 21 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

TorchServe is a tool for serving and scaling PyTorch models in production. Starting in version 0.1.0 and prior to version 0.9.0, 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. The ZipSlip issue in TorchServe has been fixed by validating the paths of files contained within a zip archive before extracting them. TorchServe release 0.9.0 includes fixes to address the ZipSlip vulnerability.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

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

3 open source packages ship an affected version, including torchserve. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `torchserve` | PyPI | From 0.1.0 | 0.9.0 |
| `torchserve` | PyPI | From 0.1.0 | 0.9.0 |
| `torchserve` | PyPI | From 0.1.0 | 0.9.0 |

Products: Pytorch Torchserve.

## How do I fix CVE-2023-48299?

Upgrade torchserve to 0.9.0 or later.

## Is CVE-2023-48299 being exploited?

There is no known exploitation of CVE-2023-48299 in the wild and no public exploit code.

## Other vulnerabilities in pytorch serve

- [CVE-2023-43654](https://insights.sbomify.com/CVE-2023-43654/): TorchServe Server-Side Request Forgery (critical 10.0)
- [CVE-2024-35198](https://insights.sbomify.com/CVE-2024-35198/): TorchServe bypass allowed_urls configuration (critical 9.8)
- [CVE-2024-35199](https://insights.sbomify.com/CVE-2024-35199/): TorchServe gRPC Port Exposure (high 8.2)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-48299 and fix it if it is affected.

What it is: CVE-2023-48299 is a medium-severity path traversal vulnerability in pytorch serve, published on 21 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-48299 in the wild and no public exploit code.

Affected packages and fixed versions:
- torchserve (PyPI): affected from 0.1.0; fixed in 0.9.0
- torchserve (PyPI): affected from 0.1.0; fixed in 0.9.0
- torchserve (PyPI): affected from 0.1.0; fixed in 0.9.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-48299/ (Markdown: https://insights.sbomify.com/CVE-2023-48299/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-48299
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-48299
- OSV: https://osv.dev/vulnerability/CVE-2023-48299

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-48299/
Summaries are generated and may contain mistakes; the official description above is the record.
