--- name: hunt-headers description: HTTP header injection — Host header, password reset poisoning, CRLF, response splitting, path bypass via headers. --- # HEADER INJECTION HUNTING — 3 BULLETS MAX **Core:** Server trusts user-controlled headers without validation. ## DIFFERENTIAL ```bash # Host header injection curl -s -H "Host: evil.com" "https://target.com/" -o /dev/null -w "%{http_code}" # Password reset poisoning curl -s -X POST "https://target.com/auth/reset" -H "Host: evil.com" -d "email=victim@test.com" # Path bypass curl -s -H "X-Original-URL: /admin" "https://target.com/" curl -s -H "X-Rewrite-URL: /admin" "https://target.com/" # CRLF injection curl -s "https://target.com/?name=test%0d%0aInjected-Header:value" -I ``` ## ATTACKS ``` Host header: password reset poisoning, cache poisoning, SSRF X-Forwarded-Host: reflection, cache poisoning X-Original-URL/X-Rewrite-URL: path bypass, WAF bypass CRLF: response splitting, XSS, cookie injection, cache poisoning ``` ## CHAINS ``` Host header → password reset poisoning → ATO → Critical Host header → cache poisoning → XSS for all → Critical CRLF → response splitting → XSS → High X-Original-URL → path bypass → admin access → Critical ``` ## DETECTION SIGNALS — WHERE TRUST HIDES The bug is never the header. The bug is a component making a security or routing decision from a header it did not set. Hunt for decision points: ``` Absolute URL built from Host → emails, redirects, sitemaps, exports Cache key excludes a varied header → one user's response served to all ACL keyed on X-Forwarded-For → allowlists, geo gates, rate limits Backend chosen by Host/XFH → vhost routing, tenant resolution Log/analytics reflection → stored XSS in admin dashboards ``` Baseline first: capture the clean response (status, length, `Location`, `Set-Cookie`, body hash). Every probe below is a differential against it — a changed redirect target, cache header flip (`MISS`→`HIT` on a poisoned variant), or a new absolute URL in the body is signal. Identical bytes back is not. ## HOST HEADER FAMILY ### Password-reset poisoning ``` 1. Request reset for YOUR OWN test account with Host: attacker-controlled 2. Check the inbox: link domain = your Host value → confirmed 3. Variants when plain Host is rejected: - Host duplicated (two Host headers — front/back parse differently) - X-Forwarded-Host, X-Host, Forwarded: host= - Host with port / trailing dot / @ / whitespace padding - Absolute-URI request line instead of origin-form ``` Never trigger a reset against a real user's address. Prove with your own account, then stop — the chain to ATO is self-evident to a triager. ### Cache poisoning via Host Poison only cache-busting probe URLs (unique query param) until the vector is proven; a poisoned production URL harms real users and kills the report. Signal: poisoned response returns `Age:`/`CF-Cache-Status: HIT` for a request *without* your header. Escalation is the stored payload: unkeyed Host reflected into a cached redirect or script URL = XSS for every visitor. ### Routing / SSRF via Host Multi-tenant and vhost-routed stacks resolve the backend from Host. Probe sibling vhosts (`admin`, `internal`, staging names from cert transparency) and internal addresses as Host values against the public IP. A different app answering = routing trust failure; metadata/internal content answering = SSRF-class. Distinguish an intentionally public vhost from one reachable only because the front door trusted your Host. ## X-FORWARDED-* TRUST DIFFERENTIALS CDN/origin pairs disagree about which hop may set forwarding headers. Test the SAME request direct-to-origin (origin IP from cert/DNS history) vs through the CDN: ``` X-Forwarded-For → IP allowlists, rate limit keys, audit logs X-Forwarded-Host → absolute URLs, tenant routing X-Forwarded-Proto → secure-cookie flags, HTTPS redirect loops, HSTS logic X-Forwarded-Port → redirect construction X-Real-IP / True-Client-IP / CF-Connecting-IP → vendor-specific trust ``` The finding is the *differential*: header honoured at origin but stripped (or vice versa) at the edge. Spoofed XFF that only reaches a log is noise; spoofed XFF that bypasses an IP allowlist or resets a rate-limit bucket is the report. Multi-value XFF also splits parsers: first-entry vs last-entry layers disagree. ## REQUEST / RESPONSE SPLITTING CRLF lives wherever a header VALUE is built from input: redirect `Location` from a `next`/`return` parameter, `Set-Cookie` from a locale/language parameter, download filenames, custom logging headers. ``` Probe: %0d%0aX-Probe:%20split (and %0a-only, %0d-only, %u560d unicode) Signal: X-Probe appears as a real header in the response — not in the body Escalate: second injected header controls cache or cookies → Set-Cookie: session=attacker-chosen (session fixation) Content-Length / fake body boundary (response splitting → stored content served under the target origin) ``` Modern frameworks encode CR/LF at the header layer; the surviving surface is proxies, legacy stacks, and custom Go/Java/Node header handling. A 400 from the front proxy with a 200 from origin on the same bytes = parser differential worth one more probe, not a dead end. ## SECURITY HEADERS — SIGNAL VS SCANNER NOISE Noise (do not report alone): missing `X-Content-Type-Options` on a JSON API, missing `X-Frame-Options` where nothing sensitive is framable, server version banners, missing `Referrer-Policy`/`Permissions-Policy`. Matters (prove the consequence): ``` CSP present but bypassable → reflected/stored XSS becomes exploitable: unsafe-inline, wildcard, JSONP endpoint on an allowlisted origin, dangling allowlisted domain (subdomain takeover feeds CSP) HSTS missing on the LOGIN/SESSION origin only (not marketing pages) CORS is headers too: reflected Origin + Allow-Credentials → cross-origin read of authenticated API (test with a real cross-origin fetch, not curl) Cache-Control absent on authenticated PII responses + shared cache/CDN in path → cross-user disclosure Set-Cookie without Secure on a session set over an HTTP-reachable endpoint ``` ## FALSE-POSITIVE TRAPS - Host reflected in a *relative* redirect or in an error page nobody caches: no impact, no report. - Reset poisoning where the email uses a hardcoded domain despite the header: verify the actual email, not the HTTP response. - "Cache poisoning" that only poisons a URL with your unique cache-buster: you poisoned your own key. Show a victim-shaped request hitting it. - XFF "bypass" of a rate limit that is also keyed on account/session: rotate one variable at a time or the differential proves nothing. ## ESCALATION LADDER ``` Header trusted → reflected in own response (lead, not a finding) → persisted (email sent, cache stored, log stored) (finding) → reaches another user or a privileged decision (High) → ATO / all-user XSS / internal routing (Critical) ``` ## REPORTING CHECKLIST - [ ] Baseline vs probe responses side by side (status, headers, body diff) - [ ] Named component making the decision (cache, mailer, router, ACL) - [ ] Cache tests used a sacrificial URL; no production cache poisoned - [ ] Reset poisoning proven only against my own test account - [ ] Impact stated as the victim-visible result, not the header name