How to fix: X-Nextjs-Cache Reveals Next.js ISR Cache State
Next.js sets X-Nextjs-Cache: HIT | MISS | STALE | BYPASS to indicate ISR/SSG cache state. This leaks framework architecture details to any client.
Why it matters
Confirms that the application uses Next.js and reveals ISR/SSG cache configuration, helping attackers target Next.js-specific vulnerabilities (e.g., SSRF via getStaticProps, path traversal in ISR routes).
X-Nextjs-Cache is a Next.js-specific response header that was added for debugging ISR behavior. It has no user-facing benefit and should be removed in production.
How to fix it
- 1Strip X-Nextjs-Cache in next.config.js headers config or via middleware.
- 2Use an env guard to only emit it in development.
Code examples
Next.js middleware (strip header)
// middleware.ts
import { NextResponse } from 'next/server';
export function middleware(req) {
const res = NextResponse.next();
res.headers.delete('x-nextjs-cache');
return res;
}References
Detected automatically by VulnRadar. The check id is x-nextjs-cache, stable across every scan so you can filter or diff on it.
More config checks
- MediumNo Rate-Limit Policy Detected
- MediumVary: Cookie Missing on Cookie-Bearing Response
- LowSet-Cookie Header Exceeds 4 KB
- LowVary Header Missing on Compressed Responses
- InfoDownloadable Content Served as inline
- InfoX-XSS-Protection Header Is Deprecated
- LowServer-Timing Exposes Cache Timings
- LowVary: Cookie on Static Resource
Questions
- How severe is X-Nextjs-Cache Reveals Next.js ISR Cache State?
- VulnRadar rates this info severity in the config category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id x-nextjs-cache, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does X-Nextjs-Cache Reveals Next.js ISR Cache State map to?
- It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.