# 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`; set `Host:` (or `X-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 malicious `Host` (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 from `req.headers['host']`, so a forged `Host:` 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 JS `URL` class 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 `Host` header 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 `Host` and `X-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 (reach `192.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-Host` isn'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 - [[raw/intigriti.com/hacking-next-js-targets-advanced-ssrf-exploitation-guide-4782|Hacking Next.js Targets: Advanced SSRF Exploitation Guide]] - [[raw/assetnote.io/digging-for-ssrf-in-nextjs-apps-181|Digging for SSRF in NextJS apps (Assetnote)]] - [[raw/intigriti.com/catflix-ctf-exploiting-ssrfs-in-next-js-middleware-4783|August CTF Challenge: Exploiting SSRFs in Next.js Middleware]] - [[raw/sentinelone.com/cve-2026-3125-opennext-cloudflare-ssrf-via-path-normalization-bypass-3319|CVE-2026-3125: OpenNext Cloudflare SSRF via Path Normalization Bypass]] - [[raw/aikido.dev/astro-ssrf-vulnerability-host-header-injection-in-ssr-error-pages-cve-2609|Astro SSRF: Host Header Injection in SSR Error Pages (CVE-2026-25545)]] - [[raw/blog.angular.dev/security-advisory-addressing-recent-vulnerabilities-in-angular-2627|Angular Security Advisory: SSRF and Header Injection in Angular SSR]] - [[raw/chameth.com/my-first-cve-the-bad-kind-ssrf-in-centauri-13397|My First CVE: SSRF in Centauri reverse proxy (CVE-2026-109618)]] - [[raw/medium.com/lab4-routing-based-ssrf-12900|Lab4: Routing-based SSRF]] - [[raw/medium.com/lab6-host-validation-bypass-via-connection-state-attack-13008|Lab6: Host validation bypass via connection-state attack]] - [[raw/github.com/next-js-improper-middleware-redirect-handling-leads-to-ssrf-cve-2025-5-4785|CVE-2025-57822: Next.js Improper Middleware Redirect Handling Leads to SSRF]] - [[raw/security.snyk.io/ssrf-in-next-js-cve-2025-57822-3321|SSRF in Next.js (CVE-2025-57822) - Snyk]]