Skip to content
SSRF Write-up Intermediate

Digging for SSRF in NextJS apps by Assetnote

NextJS's server-side redirect handling in Server Actions used the client-supplied Host header to build an internal fetch URL, allowing an attacker to make the server send requests to arbitrary hosts. This could be used for blind SSRF, and with a crafted server, full-read SSRF.

Adam Kues Follow

Published on assetnote.io

If you want to design a mostly static, modern landing page for your brand new business, what do you do? Ten years ago, it felt like every company was using a heavyweight CMS like Wordpress.

Adam Kues (@hash_kitten), Shubham Shah (@infosec_au), on assetnote.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The server-side redirect handler trusted the client-supplied Host header when constructing the URL for an internal fetch.

Impact

An attacker could perform blind SSRF to internal hosts, and with a crafted server, achieve full-read SSRF to access internal resources.

What the attacker needed

A server action that redirects to a path starting with /; Ability to set a custom Host header

The fix

The vulnerability was fixed in NextJS v14.1.1.

How it was found

  1. Identify a server action that redirects to a path starting with /.
  2. Capture the Next-Action header value from a legitimate request.
  3. Send a request with the Next-Action header and a forged Host header pointing to an attacker-controlled server.
  4. Observe the server making a HEAD request to the attacker's server.
  5. Set up a server that responds to HEAD with Content-Type: text/x-component and to GET with a redirect to the SSRF target.
  6. Send the request again with the Host header pointing to the malicious server to achieve full-read SSRF.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When a NextJS app handles a server action that redirects to a relative path, it fetches that path on the server side. The bug is that it uses the Host header from the incoming request to decide where to fetch, so an attacker can change that header to point to an internal server. This lets the attacker make the NextJS server send requests to internal systems, which is called SSRF (server-side request forgery).

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by Adam Kues

View all

1 more disclosed report, best first.

More from Vercel (NextJS)

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.