On November 3 Next.js fixed seven vulnerabilities, and three of them let use cache serve one customer's data to another. Here is the mechanism in runnable code, two scripts to check your project and an upgrade plan for multi-tenant apps.
- Published
- Reading
- 17 min
- Author
- Yaroslav Tsarenko

The scariest bug in a web app isn't always the one where an attacker runs code on your server. Sometimes it's much quieter: customer A opens their dashboard and sees customer B's invoices. No breach, no suspicious requests in the logs. The cache simply decided it was "the same request".
That's what three of the seven vulnerabilities Next.js fixed on November 3 in 16.4.5 and 15.5.29 are about. If you run a SaaS with several client companies, locales or sites on one codebase, and you've already moved to Cache Components and use cache, this one's for you.
Below: what broke, why a cache can serve someone else's data at all (with code you can run), how to check your project in five minutes, and how to upgrade so poisoned entries don't outlive the patch. Every output here is real: macOS, Node.js 25.7.
What shipped on November 3, and who it affects
On October 27 the Next.js team announced a scheduled security release, and on November 3 they shipped it: 16.4.5 for the Active LTS line and 15.5.29 for Maintenance LTS. 16.4.6 followed on November 9 and includes every fix.
The Next.js blog labels the first issue High and the rest Medium. On GitHub, each advisory carries a CVSS v4 score between 6.0 and 6.9, which is Moderate. Don't let the labels lull you: for a multi-tenant product, a "moderate" cross-customer leak is an incident you may have to disclose.
| Vulnerability | Affects | Versions |
|---|---|---|
| use cache through unstable_cache (CVE-2026-119790) | Cache Components, function reads a root param | 16.3.0–16.4.4 |
| Nested use cache and root params (CVE-2026-119351) | Cache Components, nested cached functions | 16.2.0–16.4.4 |
| Binary use cache arguments (CVE-2026-119349) | Uint8Array, Blob as arguments |
16.0.0–16.4.4 |
| Shared shell poisoning | next start, Partial Prefetching off or unset |
self-hosted |
| Compressed responses behind a proxy (CVE-2026-119348) | returning a fetched Response unchanged, HTTP/1.1 proxy |
16.0.0–16.4.4, up to 15.5.28 |
| Cookies in Edge routes (CVE-2026-119346) | NextResponse.cookies.set() on Edge |
15.0.0–15.5.28, 16.0.0–16.4.4 |
| SVG in Image Optimization (CVE-2026-119347) | a native backend that decodes SVG | 15.0.0–15.5.28, 16.0.0–16.4.4 |
Cache Components (16.x only)
- use cache + unstable_cache16.3.0–16.4.4, CVSS 6.3
- Nested use cache and root params16.2.0–16.4.4, CVSS 6.3
- Binary arguments16.0.0–16.4.4, CVSS 6.3
Self-hosted
- Shared shell poisoningnext start, Partial Prefetching off
- Compressed responses behind a proxy15.x and 16.x, CVSS 6.3
All setups
- HttpOnly cookies in Edge routes15.x and 16.x, CVSS 6.0
- SVG in Image Optimization15.x and 16.x, CVSS 6.9
Spot the pattern? Everything involving use cache lives only on the 16 line, where Cache Components became stable. So 15.5.29 fixes four other problems, and the three cross-tenant leaks are purely a 16.x story.
Why a cache can serve someone else's data at all
Let's start with the foundation, because without it the rest looks like magic. Per the docs, a use cache key is built from the Build ID, a function ID, the serialized arguments and any captured closure variables. Plus root params, but only the ones the function actually read.
That last part is the whole story. Root params are the dynamic segments above the root layout, such as app/[tenant]/layout.tsx. Since 16.3 you can read them anywhere with import { tenant } from "next/root-params", no prop drilling. Convenient, but now the tenant enters the key implicitly, through tracking: Next.js has to notice the function read it. Miss that moment and the entry becomes shared by everyone.
Here's a toy model of this class of bug. It's not Next.js code, just 40 lines that show the same mechanics: a function reads the tenant from request context, while the cache key is built from arguments only.
import { AsyncLocalStorage } from "node:async_hooks";
const request = new AsyncLocalStorage<{ tenant: string }>();
const tenant = () => request.getStore()!.tenant;
const db: Record<string, string[]> = {
acme: ["Invoice #1 ACME", "Invoice #2 ACME"],
globex: ["Invoice #7 GLOBEX"],
};
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
function memo<A extends unknown[], R>(fn: (...args: A) => Promise<R>, keyOf: (...args: A) => string) {
const store = new Map<string, Promise<R>>();
return (...args: A) => {
const key = keyOf(...args);
if (!store.has(key)) store.set(key, fn(...args));
return store.get(key)!;
};
}
async function loadInvoices(limit: number) {
const t = tenant();
await sleep(50);
return db[t].slice(0, limit);
}
const unsafe = memo(loadInvoices, (limit) => `invoices:${limit}`);
const safe = memo(
async (t: string, limit: number) => {
await sleep(50);
return db[t].slice(0, limit);
},
(t, limit) => `invoices:${t}:${limit}`,
);
async function run(label: string, get: (t: string) => Promise<string[]>) {
const [a, b] = await Promise.all(
["acme", "globex"].map((t) => request.run({ tenant: t }, async () => `${t} sees ${JSON.stringify(await get(t))}`)),
);
console.log(`${label}\n ${a}\n ${b}`);
}
await run("unsafe key (args only):", () => unsafe(10));
await run("safe key (tenant is an argument):", (t) => safe(t, 10));$ node memo-leak.ts
unsafe key (args only):
acme sees ["Invoice #1 ACME","Invoice #2 ACME"]
globex sees ["Invoice #1 ACME","Invoice #2 ACME"]
safe key (tenant is an argument):
acme sees ["Invoice #1 ACME","Invoice #2 ACME"]
globex sees ["Invoice #7 GLOBEX"]Globex sees ACME's invoices. No hacking involved, just a key missing one dimension. In Next.js, root param tracking normally works. The November issues are three situations where it didn't keep up, or where the key matched for different data.
Three leaks through use cache
One at a time: where the tracking didn't keep up, and what to do about it in your code.
Leak 1: use cache inside unstable_cache
The setup: you have a cached function that reads tenant from root params. Some code calls it directly, while an older module still wraps it in unstable_cache. Next.js already throws on that nesting, but the advisory describes a race window: right after process start, while the first fill is still in flight, the unstable_cache call can receive another request's result without the root param check.
And it gets worse. That result is stored in unstable_cache under a key without the tenant and served to later callers until the entry is revalidated or evicted. One unlucky cold start poisons the cache for a long time.
Here the workaround is official and complete: don't call a use cache function through unstable_cache. The advisory says plainly that avoiding the nesting is a full fix. In practice:
import { cacheLife, cacheTag } from "next/cache";
import { tenant } from "next/root-params";
export async function getInvoices(limit: number) {
"use cache";
cacheLife("minutes");
const t = await tenant();
cacheTag(`invoices:${t}`);
return db.invoices.findMany({ where: { tenantId: t }, take: limit });
}One function, one caching model, a tenant-scoped tag for targeted invalidation. No wrappers from the old API.
Leak 2: nested use cache and root params
The second one (CVE-2026-119351) is subtler. An outer cached function calls an inner one; the inner function reads a root param and returns an object where part of the value is ready and part is still a promise. The outer function takes the ready part, finishes, and gets stored before the inner function has recorded its root param dependency.
Result: the outer entry has no tenant in its key and is shared by everyone. According to the advisory, such entries can also ignore the tags and lifetimes of the nested caches. An attacker can't choose what leaks; it depends on whose request wrote the entry first. For a localized site that means English copy on the German page. For a SaaS, another company's data.
Which leads to a rule that stays useful after the patch: if a function depends on the tenant, pass the tenant as an argument rather than relying on it being noticed deep inside a nested call. The Next.js docs already recommend reading cookies and headers "outside cached scopes" and passing values as arguments. Same principle, applied to tenants.
export async function getDashboard(tenantId: string) {
"use cache";
cacheLife("minutes");
cacheTag(`dashboard:${tenantId}`);
const [invoices, stats] = await Promise.all([getInvoicesFor(tenantId, 10), getStatsFor(tenantId)]);
return { invoices, stats };
}Now tenantId is explicitly in the key at every nesting level. Boring? Yes. Safe? Also yes.
Leak 3: binary arguments with identical keys
The third advisory says it briefly: distinct binary arguments such as Uint8Array or Blob could produce the same cache key. If those bytes are how you tell users apart (a signed token, a session hash, a file), one user gets another's result, or plants their own.
The advisory doesn't detail the mechanism, so here's an illustration of the bug class with a naive key serializer:
import { createHash } from "node:crypto";
const naiveKey = (...args: unknown[]) => JSON.stringify(args);
const alice = new Blob(["session-of-alice"]);
const bob = new Blob(["session-of-bob"]);
console.log("naive:", naiveKey(alice), naiveKey(bob), naiveKey(alice) === naiveKey(bob));
const digest = async (b: Blob) => createHash("sha256").update(Buffer.from(await b.arrayBuffer())).digest("hex").slice(0, 16);
const [ka, kb] = [await digest(alice), await digest(bob)];
console.log("hashed:", ka, kb, ka === kb);$ node binary-key.ts
naive: [{}] [{}] true
hashed: 55d7bb25fc8d8b53 536ac816b5bc8150 falseTwo different Blobs collapsed into the same [{}]. The takeaway holds on any version: don't pass binary data into cached functions when it determines whose data it is. Hash it outside the cache and pass a string, or better, pass a user ID you've already verified.
Self-hosted: shared shells and compressed responses
Two issues hit teams running Next.js themselves: Docker, a VPS, Kubernetes.
Shared shell poisoning. With next start, Cache Components on and Partial Prefetching disabled (or simply unset), an unauthenticated request with a crafted URL could write request-specific values into a shared static shell. The result: wrong content or persistent 404s on other URLs. The conditions are narrow: a dynamic param with a value not generated at build, two deeper params that are never prerendered, and a layout reading one of them inside Suspense. The team reports no issue in their tests with Partial Prefetching on. In my App Router production guide I recommended setting partialPrefetching: true explicitly, and it pays off here too.
Compressed responses behind a proxy (CVE-2026-119348). The familiar "simple proxy" pattern: a route handler calls fetch and returns the Response as is. fetch decompresses the body, but content-encoding and content-length still describe the compressed original. Behind an HTTP/1.1 proxy that queues requests on a shared backend connection, that mismatch shifts response boundaries, and part of one client's response lands with another.
The patch fixes this, but the pattern deserves to go. Don't return a foreign Response unchanged:
const ALLOWED = new Set(["api.partner.example"]);
export async function GET(req: Request) {
const raw = new URL(req.url).searchParams.get("u");
const target = raw && URL.canParse(raw) ? new URL(raw) : null;
if (!target || target.protocol !== "https:" || !ALLOWED.has(target.hostname)) {
return new Response("Forbidden", { status: 403 });
}
const upstream = await fetch(target, { headers: { accept: "application/json" } });
const headers = new Headers({ "content-type": upstream.headers.get("content-type") ?? "application/octet-stream" });
return new Response(upstream.body, { status: upstream.status, headers });
}A host allowlist, your own headers instead of copied ones, no content-encoding or content-length from someone else's server. As a bonus you close an SSRF hole, if one was open.
Edge cookies and SVG: two issues for everyone
HttpOnly that stopped being HttpOnly (CVE-2026-119346). App Router Edge Route Handlers and Pages Router Edge API routes that set a cookie with NextResponse.cookies.set() also copied it into the internal x-middleware-set-cookie header. Unlike Set-Cookie, that header is readable by same-origin JavaScript. On its own this isn't XSS: an attacker needs script running on your origin. But HttpOnly exists precisely so that an XSS doesn't turn into session theft. Node.js routes and cookies().set() weren't affected.
SVG slipping past the ban (CVE-2026-119347). An image from an allowed source could pose as AVIF, get past images.dangerouslyAllowSVG: false and then be decoded as SVG. The source allowlist still applies, and the advisory doesn't demonstrate XSS or code execution. The risk is load on the SVG parser and its own bugs. If you allow images from domains where users upload files, this is you.
Are you affected: a decision tree and two scripts
Script one checks the version. It reads the installed next from node_modules (not the range in package.json, which can lie) and exits with 1 if it's vulnerable. Handy in CI.
import { readFileSync } from "node:fs";
import { join } from "node:path";
const PATCHED: Record<string, string> = { "15": "15.5.29", "16": "16.4.5" };
const parse = (v: string) => v.split("-")[0].split(".").map(Number);
const lt = (a: string, b: string) => {
const [x, y] = [parse(a), parse(b)];
for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] < y[i];
return false;
};
const root = process.argv[2] ?? process.cwd();
const { version } = JSON.parse(readFileSync(join(root, "node_modules/next/package.json"), "utf8"));
const major = version.split(".")[0];
const fixed = PATCHED[major];
if (!fixed) console.log(`next ${version}: no patch line in this release, upgrade to 16.4.5+`);
else if (lt(version, fixed)) {
console.log(`next ${version}: VULNERABLE, upgrade to ${fixed} or newer`);
process.exitCode = 1;
} else console.log(`next ${version}: patched (>= ${fixed})`);$ node check-next.ts ./app-a
next 16.4.4: VULNERABLE, upgrade to 16.4.5 or newer
$ node check-next.ts ./app-b
next 15.5.29: patched (>= 15.5.29)
$ node check-next.ts ./app-c
next 16.4.6: patched (>= 16.4.5)Script two looks for the patterns from the advisories. It's not a vulnerability scanner, it's a list of places worth reading by eye, even after you upgrade:
import { readFileSync, readdirSync, statSync } from "node:fs";
import { join, relative } from "node:path";
type Rule = { id: string; why: string; test: (src: string) => boolean };
const rules: Rule[] = [
{ id: "use-cache+unstable_cache", why: "use cache function wrapped by unstable_cache (CVE-2026-119790)",
test: (s) => /["']use cache/.test(s) && /unstable_cache\(/.test(s) },
{ id: "use-cache+root-params", why: "cached code reads root params: check nesting (CVE-2026-119351)",
test: (s) => /["']use cache/.test(s) && /from ["']next\/root-params["']/.test(s) },
{ id: "use-cache+binary-arg", why: "binary argument in a cached function (CVE-2026-119349)",
test: (s) => /["']use cache/.test(s) && /:\s*(Uint8Array|ArrayBuffer|Blob|Buffer)\b/.test(s) },
{ id: "edge+cookies.set", why: "NextResponse cookies set in an Edge route (CVE-2026-119346)",
test: (s) => /runtime\s*=\s*["']edge["']/.test(s) && /\.cookies\.set\(/.test(s) },
{ id: "fetch-passthrough", why: "fetched Response returned as is (CVE-2026-119348, self-hosted)",
test: (s) => /return\s+(await\s+)?fetch\(/.test(s) },
{ id: "svg-allowed", why: "dangerouslyAllowSVG enabled",
test: (s) => /dangerouslyAllowSVG\s*:\s*true/.test(s) },
];
const root = process.argv[2] ?? ".";
const skip = new Set(["node_modules", ".next", ".git"]);
function* walk(dir: string): Generator<string> {
for (const name of readdirSync(dir)) {
if (skip.has(name)) continue;
const path = join(dir, name);
if (statSync(path).isDirectory()) yield* walk(path);
else if (/\.(t|j)sx?$|\.mjs$/.test(name)) yield path;
}
}
let hits = 0;
for (const file of walk(root)) {
const src = readFileSync(file, "utf8");
for (const r of rules) {
if (!r.test(src)) continue;
hits++;
console.log(`${relative(root, file)} [${r.id}] ${r.why}`);
}
}
console.log(hits ? `\n${hits} place(s) to review` : "nothing suspicious found");
process.exitCode = hits ? 1 : 0;On a test project with three deliberately bad files:
$ node audit-use-cache.ts ./fixture
app/api/login/route.ts [edge+cookies.set] NextResponse cookies set in an Edge route (CVE-2026-119346)
app/api/proxy/route.ts [fetch-passthrough] fetched Response returned as is (CVE-2026-119348, self-hosted)
lib/reports.ts [use-cache+unstable_cache] use cache function wrapped by unstable_cache (CVE-2026-119790)
lib/reports.ts [use-cache+root-params] cached code reads root params: check nesting (CVE-2026-119351)
lib/reports.ts [use-cache+binary-arg] binary argument in a cached function (CVE-2026-119349)
5 place(s) to reviewThe regexes are blunt, so expect false positives. That's fine: five extra lines beat one missed unstable_cache.
How to upgrade without surprises
The upgrade itself is one command. The surprises live around it.
- Install the current patch.
npm install next@16.4.6(ornext@15.5.29on the 15 line). Thennpm ls next: if your monorepo has a second app or package with its own copy ofnext, it stays vulnerable. - Check the lockfile in CI. A
^16.4.0range inpackage.jsonguarantees nothing if the lockfile pinned 16.4.3. Runcheck-next.tsafternpm ci. - Think about poisoned entries.
use cacheentries include the Build ID, so a new deploy discards them. Butunstable_cacheand thefetchcache, per the docs, survive deploys. So if you had the nesting from leak 1, a poisonedunstable_cacheentry can outlive the patch. CallrevalidateTagfor the affected tags or clear your custom cache handler's store. - Review Edge routes that set cookies. If a session cookie is set there, rotate sessions for users where you have reason to suspect XSS. Without XSS, the cookie didn't leak.
- Run the tenant test on staging right after
next start, while the cache is cold.
Here's that test. It opens two tenants' dashboards in parallel and looks for the other tenant's marker in the HTML:
const base = process.env.BASE_URL ?? "http://localhost:3000";
const tenants = ["acme", "globex"];
const parallel = 5;
const rounds = 20;
const marker = (t: string) => `data-tenant="${t}"`;
let leaks = 0;
for (let i = 0; i < rounds; i++) {
const results = await Promise.all(
tenants.flatMap((t) =>
Array.from({ length: parallel }, async () => {
const res = await fetch(`${base}/${t}/dashboard`, { headers: { "x-test-round": String(i) } });
const html = await res.text();
const foreign = tenants.filter((o) => o !== t && html.includes(marker(o)));
return foreign.length ? `${t} received ${foreign.join(", ")}` : null;
}),
),
);
for (const r of results) if (r) { leaks++; console.log(`round ${i}: ${r}`); }
}
const total = rounds * tenants.length * parallel;
console.log(leaks ? `${leaks} of ${total} responses contain another tenant` : `${total} responses, no foreign tenant markers`);
process.exitCode = leaks ? 1 : 0;I ran it against two local stub servers: an honest one and a deliberately leaky one that remembers the first tenant.
$ BASE_URL=http://localhost:3999 node tenant-race.ts
200 responses, no foreign tenant markers
$ BASE_URL=http://localhost:3999 node tenant-race.ts
round 0: globex received acme
round 0: globex received acme
round 0: globex received acme
...
100 of 200 responses contain another tenantAdd a data-tenant attribute to your layout (it reveals nothing, the tenant is already in the URL) and the test becomes part of CI. If pages sit behind a login, pass test accounts' session cookies in headers.
If a leak may already have happened
The uncomfortable question technical posts rarely ask: what if your product sat on a vulnerable version for months and every condition matched? Logs won't help much. From the server's point of view every request was legitimate; the response simply came from cache.
What you can honestly do:
- Narrow it down. Were Cache Components on? Does the code have the nesting from leak 1 or binary arguments? If the audit script finds nothing and
cacheComponentsis off, the cross-tenant risk is practically zero. - Look for human signals. Support tickets like "I can see someone else's orders" or "the page shows the wrong language" now have an explanation. Reread the last few months of tickets.
- Write the decision down. What you checked, what you found, when you upgraded. If you process personal data of people in the EU, GDPR Article 33 requires notifying the supervisory authority no later than 72 hours after becoming aware of a breach (where it poses a risk to people). If you process data on a client's behalf, you notify the client, without undue delay.
I'm not a lawyer, and the disclosure call belongs to the product owner. But the technical part, "could this have happened to us", is a day of engineering work, not a week of panic.
Multi-tenant caching rules that will survive the next patch
The patch fixes specific bugs. Next time the bug will be different, but the class will be the same: a cache key missing the "whose is this" dimension. These are the rules I follow in products with several roles and clients:
- Tenant and user are explicit arguments. Root params are great for a site's locale. For data owned by a company, pass the ID explicitly so it's guaranteed to be in the key.
- One caching API. Don't mix
use cacheandunstable_cachefor the same data. If you migrated, finish the migration. - Tenant-scoped tags.
cacheTag(`invoices:${tenantId}`)gives targeted invalidation and a readable trail in logs. - No ownership-defining binary arguments. A hash or a verified ID, as a string.
- Authorization outside the cache. The cache answers "which data", not "may this person see it". Check access before calling the cached function, on every request.
- A cold-start test in CI. The script above catches a whole class of bugs, not one CVE.
That last rule isn't theory for me. In AllShip AI shippers, carriers, drivers and admins share one codebase, and I audited 109 entry points for authorization. The nastiest findings in audits like that are never "a hole in the login". They're places where the right kind of data goes to the wrong owner.
A word on AI coding assistants. An agent will happily wrap an old function in unstable_cache "for speed" or pass a Buffer into a cached function, because it compiles. I wrote about where these agents stumble on real tasks in my breakdown of the AI coding agents study. Same moral: trust, but verify automatically.
What to do this week
Checklist
-
nextin the lockfile is at least 16.4.5 or 15.5.29, in every monorepo package - No
use cachefunction is called throughunstable_cache - Tenant-dependent functions receive the tenant as an argument
- Cached functions take no
Uint8Array,BloborBufferthat defines who owns the data -
unstable_cachetags revalidated after the upgrade, if you had the nesting - Self-hosted:
partialPrefetching: trueset explicitly, proxy routes don't return a foreignResponseas is - Session cookies are set via
cookies().set()or in Node.js routes -
dangerouslyAllowSVGis off and image sources are yours - The tenant test runs in CI after every staging deploy
Where to start
Run both scripts on your repo. Fresh version and an empty audit? Great: add the tenant test to CI and forget about it until the next security release. Found unstable_cache next to use cache, or binary arguments? Fix those before upgrading, then revalidate the cache after the deploy.
And if you have a Next.js product with several clients or roles, where caching was added piece by piece and nobody remembers what's nested in what, that's work I do regularly. More on how I run projects like that on the Next.js development page.
Was this useful?
– likes · – views
Questions people ask
Which Next.js version should I install after the November 2026 security release?
On the 16 line, at least 16.4.5, and preferably the current 16.4.6 (November 9). On the 15 line, 15.5.29. The three Cache Components issues exist only in 16.x, so 15.5.29 fixes the other four: Edge cookies, compressed responses, SVG and the self-hosted ones.
Does the use cache vulnerability affect me if I never enabled cacheComponents?
No. The three cross-tenant leaks and the shared shell poisoning require Cache Components. The other three issues (cookies in Edge routes, compressed responses behind a proxy, SVG in image optimization) don't depend on it, so you still need to upgrade.
Do I need to clear the cache after upgrading Next.js?
use cache entries include the Build ID, so a new deploy discards them. unstable_cache and fetch cache entries survive deploys. If you ever wrapped a use cache function in unstable_cache, call revalidateTag for the affected tags or clear your cache store after upgrading.
Were apps hosted on Vercel affected?
Some issues are described for self-hosted setups: shared shell poisoning with next start and response mix-ups behind an HTTP/1.1 proxy. The use cache leaks and the Edge cookie exposure depend on your application code, not on the host, so everyone should upgrade.