//nefariousplan

Host Header As Self

A server makes a security decision against its own identity: the URL this request was addressed to, the audience a signed assertion names, the path prefix the middleware guards. The server does not know the answer. It derives it from the request, usually by writing the client-supplied Host header into a URL string and re-parsing. The signed "intended for X" check and the implicit "am I the right server" check both collapse to "intended for whatever the client claims I am."

A server makes a security decision against its own identity. The identity is a URL, an audience, a host, a path prefix the server needs for a self-referential comparison. The server does not know the answer from its own configuration. The URL constructor on the request object reads the Host header; the SAML library computes its self URL from the dict the handler filled with http_host; the path-prefix middleware reads request.url.path, which the framework recovered by concatenating scheme, Host header, and scope["path"], then handing the string back to urlsplit.

The signed "intended for X" check and the implicit "am I the right server for this request" check both collapse to the same comparison: a value the client wrote against a value the client wrote. The cryptographic step runs correctly. The URL parser runs correctly. The accept decision depends on whether the attacker's Host header agrees with the attacker's claim about who the server was supposed to be, and the attacker writes both.

The patch pins self-identity at boot, or validates the Host header against an operator-pinned allowlist before any accessor is allowed to inherit it. Between those two moments is the window the class lives in.

Mechanism

Three ingredients participate in every exhibit, across stacks whose remaining lexicons do not look alike.

The first is a security decision the handler needs to make against a self-referential question. SAML Destination validation asks whether a signed response was intended for this server's Assertion Consumer Service URL. The anti-replay semantics of the check depend on the responder knowing what URL it just received the response at. Apache Airflow's AWS Auth Manager (CVE-2026-25604) runs the check through python3-saml's OneLogin_Saml2_Utils.get_self_url_no_query(request_data) and compares the result to the signed Destination attribute. Path-prefix middleware in an ASGI framework asks whether this request's path lands on an allowlisted segment of the application. Starlette's middleware (CVE-2026-48710) reads request.url.path to answer. A PSR-7 server-side router asks for the request's host to route, log, and build canonical links. guzzlehttp/psr7's Message::parseRequestUri and ServerRequest::extractHostAndPortFromAuthority (CVE-2026-48998) produce a Uri whose ->getHost() is the answer.

The second is a URL-assembly step inside the framework or library that builds the "self" answer by reading the Host header into a URL string and parsing the string back. Starlette's Request.url concatenates scheme, the Host header value from scope["headers"], and scope["path"], then re-parses with urlsplit; request.url.path is whatever the re-parse recovers under the path field. python3-saml's get_self_url_no_query reads request_data['http_host'], which Airflow's handler populates from the inbound Host header, and concatenates it with the scheme and script_name before the Destination comparison. Guzzle's two functions write the literal string 'http://' in front of the Host header value and hand the result to PHP's parse_url; the library has no Host header parser of its own and reaches for a URL parser by producing a URL to parse. In all three, the server's notion of self is assembled from server-side constants plus one client-controlled byte string.

The third is the downstream read that treats the derived self as authoritative. The SAML library's Destination check is cryptographically bound (the assertion is signed) and compares against the computed self URL; the signature attests to the intended audience, and the "I am that audience" claim is caller-written. Starlette's example middleware runs a startswith against the allowlist and admits any request whose Host header shifts the re-parsed path into the prefix. A PSR-7 consumer of Guzzle's Uri reads ->getHost() and receives evil.example when the Host header is [email protected], because parse_url interprets the characters before @ as userinfo and because Uri::__toString had never been expected to round-trip through a userinfo encoder. The attack writes one header and inverts the comparison.

The class is not about signatures. The Starlette exhibit has no cryptography. The class is about the server deriving its own identity from a transport field the client writes and then using the derived identity as the right-hand side of a comparison the client is supposed to be verified against. The shared mechanism explains why fixes drift between codebases: Starlette and Guzzle patched the same shape within four days of each other in October 2026, inside entirely different ecosystems, because the ergonomics of "give me the request's URL as one object" push every HTTP framework toward the same assembly step. Django's request.get_host() passes through ALLOWED_HOSTS for exactly this reason; ASGI frameworks grew TrustedHostMiddleware after enough variants of this bug surfaced to make the primitive general.

Patches cluster into three recognizable shapes. The first pins self-identity at boot. The server reads its canonical URL, its SAML entity ID, its ACS endpoint, its administrative host from operator-provided configuration loaded before the first request is served, and every self-referential comparison references that configuration. The anti-replay Destination check compares against the configured ACS URL; http_host never enters the comparison. The second gates the Host header against a per-deployment allowlist at the earliest ingress. Django's ALLOWED_HOSTS, Starlette's TrustedHostMiddleware, nginx's server_name under default_server rejection: each refuses to admit a Host header outside the pinned set before any request accessor is allowed to inherit it. The third writes the parser the library shipped without. Guzzle's October 2026 fix is a real Host header parser that does not route through parse_url and does not accept userinfo characters in a field that cannot contain them. Each closes one layer. Where the framework's request-URL accessor continues to inherit the Host header without narrowing, and callers continue to read it for security decisions, the class remains live.

The failure repeats because the HTTP Host header's design purpose (route one TCP connection to the right virtual host on a shared-origin server) and the handler's design purpose (compute an absolute URL that represents this request) read the same field as the same answer. There is no separate "my configured hostname" accessor on the per-request object because the per-request object is per-request and the configured hostname is deployment-level state. Code that needs "the server's URL" for a security comparison reaches for the ergonomic single-object accessor and inherits the Host header as its answer. The gap between "URL as the client described this request" and "URL as this server knows itself" is one Host header wide, and the class lands every time a security-relevant comparison crosses that gap.

Exhibits

CVE-2026-48710: Starlette's request.url.path Is Not the Request's Path. Starlette's URL constructor builds the request's URL by concatenating the scheme, the Host header, and scope["path"], then re-parses the result with urlsplit. request.url.path is the path field that urlsplit recovers. Any middleware that gates on request.url.path is reading a label whose value the Host header controls. The pattern's Airflow exhibit named the same shape one layer up: server reads Host header into request_data['http_host'], hands that dict to python3-saml, which uses it to compute the "self" URL the cryptographic Destination check compares against. Starlette's case has no cryptography in it; the gate is a startswith against a path-prefix allowlist. The shared mechanism in both is a server assembling its notion of itself out of server fields and a client-supplied header, then treating the whole string as authoritative.

CVE-2026-25604: The PoC Tests /login. The Bug Is on /login_callback.. Apache Airflow's AWS Auth Manager built its SAML request_data['http_host'] from the Host request header and passed it into python3-saml alongside settings whose ACS URL was hardcoded to the configured base_url. The library's OneLogin_Saml2_Utils.get_self_url_no_query(request_data) uses http_host to compute the server's own URL, and the Destination validation on incoming SAML responses compares the signed Destination attribute to that computed URL. The anti-replay control became a comparison between a signed field and a client-controlled field, which is the shape this pattern names. The post traces both functions and the library call path end-to-end and explains why the PoC's mock, which built the ACS URL from http_host directly, does not reproduce the real bug.

Boundaries

Not every Host header poisoning is this pattern. Classic password-reset-link poisoning writes the Host header into an outbound link the server emails to the user; the server's own inbound security decisions do not read the derived URL, the attacker still needs the victim to click, and the primitive is a phishing assist rather than a self-identity bypass. Host Header As Self requires the derived URL (or audience, or host) to feed into an inbound check that the attacker's write to the Host header flips. If the Host header only lands in an outbound string the server renders and no handler compares anything to it, the shape is outbound-link injection, not this class.

Not every URL-parser bug is this pattern. A parser that misinterprets userinfo as host, treats mixed-case schemes inconsistently, or fails to normalise percent-encoding is a general URL-parser flaw and its CVEs stand on their own. Host Header As Self is the specific case where that parser is fed the request's Host header as if it were an authority, and the server treats the output as its own identity for a comparison. The Guzzle exhibit qualifies because parseRequestUri and extractHostAndPortFromAuthority are reading the Host header to build the server's view of the inbound request, and downstream consumers read ->getHost() as "the host of this request from the server's point of view." A URL parser that is only ever fed URLs the server has emitted, with no attacker write-path into the input, does not belong here.

Not every "caller writes the value the verifier compares against" is this pattern. Caller Chosen Key covers verifiers that read verification parameters (key material, algorithm, trust anchor) from the artifact being verified. The caller writes the policy. Host Header As Self covers servers that read their own identity (URL, audience, host, path) from the transport. The caller writes the self. Both collapse an authenticating comparison into caller-against-self; they differ by which side of the comparison the client wrote. If the bypass is alg: none, a JWKS URL named by the token, or a peer-supplied trust pool, the key-axis class applies. If the bypass is a Host header the server reads back as "my ACS URL" or "my path prefix," this class applies.

Not every wide-accessor-on-a-typed-request-object bug is this pattern. Predicate Stringifies The Object describes the case where a predicate named for one field of a structured request value (isWebhookEndpoint, isPublicResource, SecurityRequestFilter) reads the object's stringified form and the attacker writes the allow-string into another request field (query string, Servlet path parameter, trailing path segment) the gate did not know it was inspecting. The leak is from a sibling field of the same request to the same gate. Host Header As Self describes the case where the field leaking into the comparison is specifically the Host header and the sink is the server's notion of itself. Starlette is the closest to both frames at once; the distinguishing signal is that the derived string the gate reads includes the Host header and the gate's semantics are about the server's identity, not about which sibling field of the request happened to carry the pattern.

Defender playbook

Audit for places where the server's notion of self is derived from a request field. Grep for request.url, request.get_host, $_SERVER['HTTP_HOST'], scope["headers"], http_host, getUri(), ->getHost(), and every framework accessor whose docstring mentions "the request's URL." For each hit, trace whether the value feeds into a signed-message audience check (SAML Destination, OIDC aud, JWT iss), a redirect allowlist, a path-prefix gate, an outbound URL the server attests to, or any comparison that is supposed to answer "am I the right server for this message?". Those call sites are the exhibit list. The inventory is more valuable than any single patch: this class lands repeatedly inside one codebase when a framework's request-URL object continues to serve as the ergonomic reach.

Pin self-identity at boot, not at request time. The server's canonical URL, SAML entity ID and ACS endpoint, OIDC issuer, administrative host, and allowlisted redirect targets belong in operator-provided configuration loaded before the first request is served. Every security check that asks "am I the intended recipient?" or "does this URL belong to me?" must compare against that configuration, not against any value derived from the request. Airflow's AWS Auth Manager fix sets the ACS URL from the configured base_url; the risk window reopens for any call path that still routes through request_data['http_host']. python3-saml exposes an opt-in setting (strict, security.wantHttpHost) the caller must engage, which means the library ships with the unsafe default and the caller is responsible for installing the primitive. Treat that default as the bug-site and configure explicitly.

Install a Host header allowlist at the earliest ingress. Starlette's TrustedHostMiddleware, Django's ALLOWED_HOSTS, FastAPI's wrapped equivalent, and nginx's server_name under a default_server 444 rejection all refuse to admit a Host header outside a per-deployment pinned set before any request accessor is allowed to inherit it. The allowlist must come from operator configuration, must default empty, and must fail closed when empty. This single check closes every downstream bug where some code path reaches for the request's URL object and inherits the Host header's current value, including the paths you have not audited yet. It is a coarse control, deliberately so: the point is to decouple the framework's URL-assembly ergonomics from the attacker's write-authority on one specific field.

Prove the bypass. For every self-referential check in your handlers, send the service a request whose Host header disagrees with the deployment's configured hostname and watch the decision. Submit a signed SAML response whose Destination names an attacker-controlled hostname with a Host header that matches: the verifier should reject because the signed value does not match the configured ACS URL. Fire a request at a protected prefix with a Host header designed to shift the re-parsed path, and assert that the gate decides on the real path. Send a request whose Host header is [email protected] and read the downstream ->getHost() value: a correctly-parsed answer is the configured host or a rejection; a bypassed answer is evil.example. The test suite is five minutes per endpoint and catches the full spectrum from SAML audience bypass to path-prefix smuggling to userinfo-in-authority parsing, before the class finds the next framework.

Kinship

Caller Chosen Key. Sibling on the verifier's self-identity axis. Caller Chosen Key covers verifiers that read verification policy (key material, algorithm, trust anchor) out of the artifact being verified: the caller writes the policy and the cryptographic step runs correctly against inputs the attacker chose. Host Header As Self covers servers that read their own identity (URL, audience, host, path prefix) out of the transport: the caller writes the self and the comparison runs correctly against a target the attacker chose. Both collapse an authenticating comparison into caller-against-self; they differ by which operand the client wrote. The Airflow exhibit here, where python3-saml's Destination check compares a signed field to a Host-derived self URL, is the exact meeting point of the two patterns: the signature is good, the policy is operator-pinned, the self is caller-written.

Predicate Stringifies The Object. Cousin at the wide-accessor frame. Predicate Stringifies The Object names cases where a predicate reads an object's default serialization and catches the allow-string from a sibling attacker-controlled field (query string, Servlet path parameter, unanchored regex over the full URL). Host Header As Self is adjacent in the Starlette exhibit specifically: request.url.path is a re-parse of a string the framework built by writing the Host header into a URL, so the middleware's startswith reads a field the Host header controls. The pattern divides by what leaks and what the gate is semantically asking. If a sibling request field leaks into the predicate's view of some other request field, the cousin applies. If the Host header leaks into the server's view of its own identity, this pattern applies. Many codebases exhibit both shapes on the same request object at different call sites.

Trust Inversion. Umbrella relationship. Trust Inversion is the general shape where the primitive that is supposed to authorize or authenticate the caller lives in the caller's hands. Host Header As Self is the subset where the primitive is a self-referential comparison and the caller's reach is specifically the HTTP Host header's ability to supply the server's notion of itself. The verifier still runs. The URL parser still runs. The inversion is in which operand came from the attacker.

The server did not know what URL it was. The client was happy to supply one.