# CVE-2025-59152: X-Forwarded-For Header Spoofing Bypasses Litestar Rate Limiting

> Attackers can bypass IP-based rate limiting in Litestar applications by spoofing the X-Forwarded-For header, allowing unlimited requests.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/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:** 6 Oct 2025
- **Updated:** 6 Oct 2025
- **Also known as:** GHSA-hm36-ffrh-c77c, PYSEC-2026-1553

## What is CVE-2025-59152?

CVE-2025-59152 is a high-severity vulnerability in litestar-org litestar, published on 6 Oct 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Litestar is an Asynchronous Server Gateway Interface (ASGI) framework. In version 2.17.0, rate limits can be completely bypassed by manipulating the X-Forwarded-For header. This renders IP-based rate limiting ineffective against determined attackers. Litestar's RateLimitMiddleware uses `cache_key_from_request()` to generate cache keys for rate limiting. When an X-Forwarded-For header is present, the middleware trusts it unconditionally and uses its value as part of the client identifier. Since clients can set arbitrary X-Forwarded-For values, each different spoofed IP creates a separate rate limit bucket. An attacker can rotate through different header values to avoid hitting any single bucket's limit. This affects any Litestar application using RateLimitMiddleware with default settings, which likely includes most applications that implement rate limiting. Version 2.18.0 contains a patch for the vulnerability.

Weakness: CWE-807 (Reliance on Untrusted Inputs in a Security Decision)

## Which versions are affected by CVE-2025-59152?

3 open source packages ship an affected version, including litestar.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `litestar` | PyPI | From 2.17.0 | 2.18.0 |
| `litestar` | PyPI | From 2.17.0 | 2.18.0 |
| `litestar` | PyPI | From 2.17.0 | 2.18.0 |

## How do I fix CVE-2025-59152?

Upgrade litestar to 2.18.0 or later.

## Is CVE-2025-59152 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-59152 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-59152 and fix it if it is affected.

What it is: CVE-2025-59152 is a high-severity vulnerability in litestar-org litestar, published on 6 Oct 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-59152 exists.

Affected packages and fixed versions:
- litestar (PyPI): affected from 2.17.0; fixed in 2.18.0
- litestar (PyPI): affected from 2.17.0; fixed in 2.18.0
- litestar (PyPI): affected from 2.17.0; fixed in 2.18.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-2025-59152/ (Markdown: https://insights.sbomify.com/CVE-2025-59152/index.md)
```

## Sources

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

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