# CVE-2024-35198: TorchServe bypass allowed_urls configuration

> Attackers can bypass URL restrictions in TorchServe to download arbitrary models, undermining security controls for model serving.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 18 Jul 2024
- **Updated:** 7 Aug 2024
- **Also known as:** GHSA-wxcx-gg9c-fwp2, PYSEC-2026-554

## What is CVE-2024-35198?

CVE-2024-35198 is a critical vulnerability in pytorch serve, published on 18 Jul 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

TorchServe is a flexible and easy-to-use tool for serving and scaling PyTorch models in production. 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. This issue in TorchServe has been fixed by validating the URL without characters such as ".." before downloading see PR #3082. TorchServe release 0.11.0 includes the fix to address this vulnerability. Users are advised to upgrade. There are no known workarounds for this vulnerability.

Weakness: CWE-706 (Use of Incorrectly-Resolved Name or Reference)

## Which versions are affected by CVE-2024-35198?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `torchserve` | PyPI | All versions | 0.11.0 |
| `torchserve` | PyPI | All versions | 0.11.0 |
| `torchserve` | PyPI | All versions | 0.11.0 |

Products: Pytorch Torchserve.

## How do I fix CVE-2024-35198?

Upgrade torchserve to 0.11.0 or later.

## Is CVE-2024-35198 being exploited?

There is no known exploitation of CVE-2024-35198 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-35199](https://insights.sbomify.com/CVE-2024-35199/): TorchServe gRPC Port Exposure (high 8.2)
- [CVE-2023-48299](https://insights.sbomify.com/CVE-2023-48299/): TorchServe ZipSlip (medium 5.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-35198 and fix it if it is affected.

What it is: CVE-2024-35198 is a critical vulnerability in pytorch serve, published on 18 Jul 2024. 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-2024-35198 in the wild and no public exploit code.

Affected packages and fixed versions:
- torchserve (PyPI): affected all versions; fixed in 0.11.0
- torchserve (PyPI): affected all versions; fixed in 0.11.0
- torchserve (PyPI): affected all versions; fixed in 0.11.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-2024-35198/ (Markdown: https://insights.sbomify.com/CVE-2024-35198/index.md)
```

## Sources

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

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