1. Vulnerability Background
What is this vulnerability?
- CVE-2026-48710 is a Host header validation bypass in Starlette, a lightweight ASGI framework/toolkit for Python.
- In vulnerable versions, Starlette reconstructed
request.urlfrom the incoming HTTPHostheader without validating that header against the grammar defined by RFC 9112 §3.2 / RFC 3986 §3.2.2. - Because routing uses the raw ASGI
scope["path"]whilerequest.urlis rebuilt from the potentially attacker-controlledHostheader, the two values could diverge.
Why is it critical/important?
request.urlis frequently used by middleware and endpoint logic for security decisions, access control, redirects, and canonicalization.- If an attacker can cause
request.url.pathto differ from the actual requested path, security checks based onrequest.urlcan be bypassed even though the request is routed to the intended endpoint. - This is a logic flaw in request normalization and host header handling, not just a parsing bug.
What systems/versions are affected?
- Starlette versions prior to 1.0.1 are affected.
- The issue is fixed in Starlette 1.0.1 and later.
- Applications using vulnerable Starlette releases and relying on
request.urlfor security-sensitive path or host logic are at risk.
2. Technical Details
Root cause analysis
- In
starlette/datastructures.py,URLconstruction used:url = f"{scheme}://{host_header}{path}whenhost_headerwas present. - The host header was accepted without grammar validation.
- When
host_headercontained characters like?,#,/,@,\, or space, the resulting URL string could be parsed such that the effective path component changed. - The routing engine still used the original ASGI
scope["path"], so the raw request path and reconstructedrequest.url.pathcould diverge.
Attack vector and exploitation conditions
- An attacker sends an HTTP request with a malicious
Hostheader to an application running vulnerable Starlette. - Exploitation requires the application to:
- use Starlette <1.0.1,
- accept the custom Host header,
- and make security decisions based on
request.urlrather than the raw scope path.
- Example malicious host values from the test suite include:
foo/?x=foo/#foo/baruser@foofoo\barfoo bar
Security implications
- A malformed Host header can alter
request.url.pathwhile leaving the raw path unchanged. - Middleware or endpoint code that checks
request.url.pathcan be tricked into wrong conclusions. - This can lead to bypass of:
- path-based access controls,
- URL-based security filters,
- redirect and canonicalization logic,
- host-specific routing or validation.
- The vulnerability is primarily an authorization/information flow bypass rather than remote code execution.
3. Patch Analysis
What code changes were made?
- Added host validation with a regular expression in
starlette/datastructures.py:_HOST_RE = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9.:]+\])(?::[0-9]+)?$", re.IGNORECASE) - Updated URL reconstruction logic to only use
host_headerif it matches the regex:if host_header is not None and _HOST_RE.fullmatch(host_header): - If the host header is invalid, the code falls back to
scope["server"]instead of using the malformed header.
How do these changes fix the vulnerability?
- The regex enforces valid host syntax before incorporating the attacker-controlled header into
request.url. - Invalid Host headers are ignored for URL reconstruction.
- This removes the ability of malformed Host values to inject path/query delimiters into the reconstructed URL.
- The fallback to
scope["server"]ensures a trusted host/port source is used whenever the incoming header is invalid.
Security improvements introduced
- Host header handling now conforms to the expected RFC host grammar.
request.urlbecomes consistent with the actual request path when the client supplies invalid host input.- The patch closes the gap between raw ASGI path routing and reconstructed URL-based security logic.
- Added regression tests explicitly cover invalid Host headers and verify fallback behavior.
4. Proof of Concept (PoC) Guide
Prerequisites for exploitation
- Starlette version prior to 1.0.1.
- A Starlette application that:
- exposes a protected route,
- uses
request.urlin middleware or endpoint logic, - and does not separately validate the raw scope path.
- Ability to send custom
Hostheaders.
Step-by-step exploitation approach
- Deploy a vulnerable Starlette application.
- Create or identify middleware that checks
request.url.pathor similar values for authorization. - Send an HTTP request to a protected path, e.g.
/admin, with a malicious Host header such as:Host: foo/?x= - Observe the reconstructed
request.urlandrequest.url.path.
Expected behavior vs exploited behavior
- Expected behavior on a secure system:
- raw request path
/admin - reconstructed
request.url.path==/admin - security checks based on
request.urlandscope["path"]agree
- raw request path
- Exploited behavior on vulnerable Starlette:
- raw scope path remains
/admin - reconstructed
request.urlmay parse ashttp://foo/?x=/admin request.url.pathbecomes/, or otherwise differs from the actual path- security checks based on
request.urlcan be bypassed or misapplied
- raw scope path remains
How to verify the vulnerability exists
- Reproduce with a vulnerable Starlette installation.
- Send a request with an invalid Host header and log both:
scope["path"]request.url.path
- If they differ due to the Host header value, the issue is present.
- On patched versions, invalid Host headers are ignored for URL construction and
request.url.pathmatches the raw path.
5. Recommendations
Mitigation strategies
- Upgrade Starlette to version 1.0.1 or later.
- Do not rely solely on
request.urlfor security-sensitive path or host decisions. - Validate
Hostheaders against RFC-defined host grammar at the earliest point of request processing. - Prefer trusted data sources such as
scope["server"]when the incomingHostheader is malformed.
Detection methods
- Audit application code for use of
request.url,request.url.path, or host-based security checks. - Monitor logs for requests with suspicious host header values containing delimiters or illegal characters.
- Use automated scanners to detect Starlette versions <1.0.1.
- Add WAF/IDS rules to flag malformed Host headers like those containing
?,#,/,\, spaces, or@.
Best practices to prevent similar issues
- Treat all client-controlled headers as untrusted input.
- Apply strict validation on headers used to reconstruct URLs or derive security decisions.
- Use framework-provided host validation and fallback paths where available.
- Whenever possible, base access control on canonical, server-side values rather than reconstructed request metadata.
- Keep framework dependencies up to date and pay attention to security patches for request normalization logic.