Host Header SSRF
Routing-based SSRF where the server reconstructs an outbound/base URL from attacker-controlled
Host/X-Forwarded-*headers (or an absolute request line), so a header rewrite — not a URL parameter — steers a server-side request to internal targets.
How it works
When an application sits behind a reverse proxy and derives its own origin from request headers, those headers become an SSRF sink. Two shapes:
- Routing-based SSRF: the front proxy forwards by
Host; setHost:(orX-Forwarded-Host) to an internal IP/hostname and the proxy routes your request to internal services (e.g.192.168.0.0/24, an admin panel). In Burp, uncheck “update Host header to match target.” A connection-state variant validates the first request on a keep-alive connection and trusts later pipelined requests with a maliciousHost(PortSwigger-style host-validation bypass). - SSR URL reconstruction: SSR frameworks build an absolute fetch URL from
Host/X-Forwarded-*for error pages, server actions, image optimization, or middleware redirects; a forged header makes the server fetch an internal URL and (often) return the body — full-read SSRF.
Absolute-form request lines and proxy path-normalization differences (backslash vs. slash) are adjacent routing tricks that reach handlers the edge was supposed to intercept. Password-reset poisoning is the same Host-injection root cause applied to link generation (not covered here; this page is the SSRF/routing facet).
Techniques / payloads
GET / HTTP/1.1
Host: 169.254.169.254 # or 192.168.0.1 / internal-service
X-Forwarded-Host: 169.254.169.254
- Next.js Server Actions (CVE-2024-34351): app uses Server Actions and the action redirects to a relative path (
/...); the handler rebuilds the stream target fromreq.headers['host'], so a forgedHost:makes the server issue a request to your OAST host (first request fires a HEAD to the header value). Preconditions from Assetnote’s original research. - Next.js
/_next/image:remotePatterns/allowlist + redirect-following → chain an open redirect on an allowlisted domain to internal blind SSRF:/_next/image?url=https://third-party.com/logout%3furl%3Dhttps%3A%2F%2Flocalhost%3A2345%2F...&w=256&q=75. See Open Redirect to SSRF. - OpenNext/Cloudflare (CVE-2026-3125): path-normalization bypass —
/cdn-cgi\image/(backslash) evades Cloudflare edge interception; the JSURLclass normalizes\→/, hits the dev-only handler, and fetches arbitrary remote URLs. See URL Parser Differentials.
Notable cases
- CVE-2024-34351 — Next.js Server Actions SSRF via
Hostheader on relative redirects. - CVE-2025-57822 — Next.js middleware: headers passed to
NextResponse.next()/ improper redirect (Location) handling → SSRF in self-hosted apps; patched 14.2.32 / 15.4.7. Escalated to RCE via an internal Jenkins (Groovy console) in the Intigriti CatFlix CTF. - CVE-2026-25545 — Astro SSR:
Host-header injection in prerendered custom error pages (404.astro/500.astro); the fabricated URL is fetched, redirects followed, response returned → full-read SSRF to localhost/internal. Patched astro 5.17.2 / @astrojs/node 9.5.3 / 6.0.0-beta.11. - Angular SSR (GHSA-xh43-g2fq-wjrj) — internal URL-reconstruction trusted
HostandX-Forwarded-*without validating the destination origin → SSRF + header injection; SSR deployments only. - CVE-2026-3125 — @opennextjs/cloudflare path-normalization SSRF (backslash) (<1.17.1).
- Centauri (CVE-2026-109618, CVSS 10.0) — reverse proxy tricked into proxying arbitrary absolute URLs due to request-rewriting/routing evolution → internal access / DDoS.
- PortSwigger Web Security Academy labs: routing-based SSRF via
Host, and host-validation bypass via connection-state attack (reach192.168.0.1/admin).
Defenses
- Never derive the outbound/base origin from request headers; configure a fixed canonical host/origin server-side. Reject requests whose
Host/X-Forwarded-Hostisn’t in an allowlist at the edge. - Validate and pin redirect targets; don’t follow redirects to private ranges in image optimizers; normalize paths consistently between edge and app (watch
\vs/). See URL Parser Differentials. - Egress-restrict SSR renderers; block
169.254.169.254/internal; enforce IMDSv2. General guidance: SSRF Prevention.
Related
- Server-Side Request Forgery
- Open Redirect to SSRF
- URL Parser Differentials
- Partial SSRF
- Cloud Metadata Service Exploitation
- SSRF in PDF and HTML Renderers
Sources
- Hacking Next.js Targets: Advanced SSRF Exploitation Guide · original
- Digging for SSRF in NextJS apps (Assetnote) · original
- August CTF Challenge: Exploiting SSRFs in Next.js Middleware · original
- CVE-2026-3125: OpenNext Cloudflare SSRF via Path Normalization Bypass · original
- Astro SSRF: Host Header Injection in SSR Error Pages (CVE-2026-25545) · original
- Angular Security Advisory: SSRF and Header Injection in Angular SSR · original
- My First CVE: SSRF in Centauri reverse proxy (CVE-2026-109618) · original
- Lab4: Routing-based SSRF · original
- Lab6: Host validation bypass via connection-state attack · original
- CVE-2025-57822: Next.js Improper Middleware Redirect Handling Leads to SSRF · original
- SSRF in Next.js (CVE-2025-57822) - Snyk · original