Next.js has a Middleware / Proxy bypass in App Router applications via segment-prefetch routes
Affected releases · next
- 16.x16.0.0 – 16.2.4Fixed in 16.2.5
- 15.x15.2.0 – 15.5.15Fixed in 15.5.16
On 16.x, the newest line:
npm install next@16.2.5Affected
16.0.0 – 16.2.4
25 releases
Fixed
16.2.5 – 16.4.2
20 releases, latest
Not affected
15.0.0 – 15.1.12
22 releases
Affected
15.2.0 – 15.5.15
48 releases
Fixed
15.5.16 – 15.5.28
12 releases
Is your project affected?
Paste your package.json, or type the range you declare for next. It is read in your browser and sent nowhere.
What happens
Impact
App Router applications that rely on middleware or proxy-based checks for authorization can allow unauthorized access through transport-specific route variants used for segment prefetching. In affected configurations, specially crafted .rsc and segment-prefetch URLs can resolve to the same page without being matched by the intended middleware rule, which can allow protected content to be reached without the expected authorization check.
Fix
We now include App Router transport variants when generating middleware matchers, so middleware protections are applied consistently to those requests as well as to the normal page URL.
Workarounds
If you cannot upgrade immediately, enforce authorization in the underlying route or page logic instead of relying solely on middleware.