Start
All articles
TrendingPublished on · 3 min read

Next.js 16.4.5: security fixes for use cache, Edge and images

Next.js 16.4.5 fixes seven security advisories, most of them cache-related. See who is affected, how to check your project and what to ask whoever maintains it.

BySenior Developer & Tech Lead

On November 3, the Next.js team published version 16.4.5 with security fixes. If you maintain a Next.js 16 app, or pay someone to maintain it, this post explains which fixes matter, how to find out whether your project is affected and what to do about it.

The good news: the six advisories with their own GitHub page are rated "Moderate", with CVSS v4 scores between 6.0 and 6.9. The caveat: most of them are about caching, and a caching bug is the kind of failure where one user receives another user's content.

What was published

According to the official announcement, the fixes shipped in 16.4.5 (Active LTS line) and 15.5.29 (Maintenance LTS). The post offers no alternative mitigations: the recommendation is to upgrade.

The 16.4.5 release notes list seven security advisories. Six have their own page with a CVE and an affected version range; the seventh covers poisoning of shared shells in Cache Components.

What each fix means in practice

The table summarizes what the announcement and the advisory pages say. "Affected" applies to the version range shown, up to 16.4.4 (or 15.5.28 on the 15 line).

Issue Only affects you if... Affected versions
use cache with binary arguments mixes users you pass security-relevant binary arguments to functions marked use cache 16.0.0 to 16.4.4
Leak across root parameters in nested use cache you use Cache Components with nested use cache functions that read root parameters (tenant, site, locale) 16.2.0 to 16.4.4
use cache called inside unstable_cache() you use Cache Components and call the same function directly and through unstable_cache 16.3.0 to 16.4.4
Shared shell poisoning you self-host with next start and Cache Components, with deep dynamic-parameter routes per the announcement
Response injection across clients you self-host, return a fetch response unchanged and run an HTTP/1.1 reverse proxy that queues requests 16.0.0 to 16.4.4 and up to 15.5.28
HttpOnly cookie visible on Edge routes you set cookies with NextResponse.cookies.set() in an Edge route 16.0.0 to 16.4.4 and 15.0.0 to 15.5.28
SVG slips past image optimization blocking a permitted image source is controlled by a third party and the image backend can decode SVG 16.0.0 to 16.4.4 and 15.0.0 to 15.5.28

Three notes from the announcement itself that help avoid unnecessary alarm:

  • The cookie issue requires the attacker's JavaScript to already be running on the same origin. According to the post, it is not an independent way to execute JavaScript.
  • The SVG issue does not, on its own, demonstrate XSS or remote code execution, and the allowlist of image sources still applies.
  • For the unstable_cache() advisory, the GitHub page says that avoiding the nesting fully resolves it.

How to tell whether your project is affected

Start with the version and the features. Without Cache Components, the first four rows of the table do not apply to your code.

npm ls next
grep -n "cacheComponents" next.config.*
grep -rn "use cache" src app 2>/dev/null
grep -rn "unstable_cache" src app 2>/dev/null
grep -rn "runtime = 'edge'" src app 2>/dev/null

If cacheComponents: true shows up in next.config.ts, the project uses use cache. The directive documentation explains the setup.

The cookie pattern described in the advisory looks like this:

// app/api/login/route.ts
import { NextResponse } from 'next/server'

export const runtime = 'edge'

export async function POST() {
  const res = NextResponse.json({ ok: true })
  res.cookies.set('session', 'token-value', { httpOnly: true })
  return res
}

According to the announcement, Node.js Route Handlers and routes that use cookies().set() are not affected. The reverse proxy and next start cases depend on how you host: if you deploy on a managed platform, ask your provider, because the post does not detail the difference.

How to upgrade

Bump the version within your line, run the tests and deploy:

npm install next@16.4.5   # projects on the 16 line
npm install next@15.5.29  # projects on the 15 line
npm run build && npm test

If you are on an older 16 release, such as 16.3, this is a minor upgrade. Read the release notes first and test the routes that use caching, because caching behavior is exactly what changed.

If you publish the app through another platform's adapter, check the provider's documentation to see whether it requires its own version.

What to ask whoever maintains your system

If you are the one hiring, you do not need to read the advisories. These questions are enough:

  1. Which Next.js version is running in production, and when was it last updated?
  2. Does the project use Cache Components, use cache or Edge routes?
  3. Is hosting managed or self-run? Is there a reverse proxy in front?
  4. Does the pipeline run npm audit or any dependency alerting?

Vague answers are information too. This post offers general technical guidance and does not replace an audit of your system.

Checklist for this week

  1. Run npm ls next and note the version.
  2. If it is 16.4.4 or earlier (or 15.5.28 or earlier), plan the upgrade to 16.4.5 or 15.5.29.
  3. Search for use cache, unstable_cache and Edge routes with the commands above.
  4. After the deploy, test pages that depend on tenant, locale or user and confirm each one sees only their own content.
  5. Turn on dependency alerts so you do not have to rely on the news to learn about a fix.

Sources

Enjoyed the article? Share it

Get new articles by email

Practical guides and technical analysis, no spam. Unsubscribe anytime.

We only use your email to send the articles. You confirm the subscription by email and can unsubscribe at any time. Privacy Policy.

Keep reading