Skip to content
Heist/ feed
Back to feed
High

X-Forwarded-For Header Spoofing Bypasses Litestar Rate Limiting

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2025-59152
Confirmed fixed CVEs
Not specified
Updated in this feed
3 Nov 2026, 06:13 UTC · Revision 1

Source evidence

X-Forwarded-For Header Spoofing Bypasses Litestar Rate Limiting

core-osv · Original source

Published 6 Oct 2025, 15:23 UTC

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.

osv:CVE-2025-59152
Complete source record
{
  "id": "94dda51c621055d0ba414affbf480c6f54f729589105a84156e6134db2dd78fa",
  "url": "https://osv.dev/vulnerability/CVE-2025-59152",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "X-Forwarded-For Header Spoofing Bypasses Litestar Rate Limiting",
    "summary": "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.",
    "evidence": "osv:CVE-2025-59152",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2025-59152",
      "aliases": [
        "CVE-2025-59152",
        "GHSA-hm36-ffrh-c77c",
        "PYSEC-2026-1553"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/litestar-org/litestar",
              "type": "GIT",
              "events": [
                {
                  "introduced": "130914406220b2a63b27ca2c9bb496092a76e484"
                },
                {
                  "fixed": "42a89e043e50b515f8548a93954fe143f63cf9fb"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "range": [
                      {
                        "introduced": "= 2.17.0"
                      },
                      {
                        "last_affected": "= 2.17.0"
                      }
                    ],
                    "source": "AFFECTED_FIELD",
                    "strategy": "StandaloneSingleVersion"
                  },
                  {
                    "range": [
                      {
                        "fixed": "42a89e043e50b515f8548a93954fe143f63cf9fb"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "= 2.17.0",
            "v2.17.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-59152.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:26.158603875Z",
      "provider": "osv",
      "references": [
        "https://github.com/litestar-org/litestar/blob/26f20ac6c52de2b4bf81161f7560c8bb4af6f382/litestar/middleware/rate_limit.py#L127",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/59xxx/CVE-2025-59152.json",
        "https://github.com/litestar-org/litestar/security/advisories/GHSA-hm36-ffrh-c77c",
        "https://nvd.nist.gov/vuln/detail/CVE-2025-59152",
        "https://github.com/litestar-org/litestar/commit/42a89e043e50b515f8548a93954fe143f63cf9fb"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-807"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/59xxx/CVE-2025-59152.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2025-59152",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 492987,
  "published_at": "2025-10-06T15:23:12.526+00:00"
}