Next.js: HttpOnly cookie exposure through internal response header on Next.js Edge runtime routes
Affected releases · next
- 16.x16.0.0 – 16.4.4Fixed in 16.4.5
- 15.x15.0.0 – 15.5.28Fixed in 15.5.29
On 16.x, the newest line:
npm install next@16.4.5Every release on a timeline
Affected
16.0.0 – 16.4.4
47 releases
Fixed
16.4.5 – 16.4.6
2 releases
Affected
15.0.0 – 15.5.28
82 releases
Fixed
15.5.29
1 release
What happens
Next.js applications that set cookies through NextResponse on Edge runtime routes — App Router route handlers and Pages Router Edge API routes — send an internal x-middleware-set-cookie header in the public response, duplicating the cookie value and its attributes. This makes HttpOnly cookies, such as session tokens, readable by JavaScript running on the same origin when an application sets a sensitive cookie on an affected response.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.