-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The matcher's only optional suffix was `\\.json`\n\n`middleware.ts` in a Next.js app is a single file at the project root that exports a `middleware` function and a `config.matcher` array. The matcher is how the developer tells the framework which requests middleware should run for. The framework compiles that matcher source into a regular expression at build time. At request time, the edge router tests the incoming pathname against that regex. Match, middleware runs. No match, middleware is skipped and the renderer is invoked directly.\n\nUp through v16.2.4, the compiler that produced that regex lived in `packages/next/src/build/analysis/get-page-static-info.ts`, in a function called `getMiddlewareMatchers`. The relevant line wrapped the developer's source pattern in a prefix and a suffix:\n\n```ts\nsource = `/:nextData(_next/data/[^/]{1,})?${source}${\n isRoot\n ? `(${nextConfig.i18n ? '|\\\\.json|' : ''}/?index|/?index\\\\.json)?`\n : '{(\\\\.json)}?'\n}`\n```\n\nThe trailing group for non-root paths is `{(\\\\.json)}?`. That is the entire alphabet of suffixes the matcher accepted. The compiled regex for `matcher: '/dashboard/:path*'` came out as `^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/dashboard(?:\\/(?.+?))?(\\.json)?[\\/#\\?]?$`. Plain `/dashboard` matched. `/_next/data//dashboard.json` matched. Nothing else did.\n\n`.json` is the data-route convention from the Pages Router. The Pages Router was the page model Next.js shipped from 2016 through 2022, where a page could be requested as either HTML or as a JSON-serialised props blob at `/_next/data//.json`. That blob is what `getStaticProps` and `getServerSideProps` produced. The matcher's `(\\.json)?` was the gate accommodating that variant.\n\nThe App Router shipped in v13.4 (May 2023) and replaced `getStaticProps` and `getServerSideProps` with React Server Components. RSC pages do not have a `.json` data variant. They have a `.rsc` flight-payload variant, served at `/.rsc`, and as of the cacheComponents / segment-cache work in v15, a per-subtree variant served at `/.segments/$c$children/__PAGE__.segment.rsc`. Three years after the App Router shipped, three years into being the recommended page model, the matcher's only optional suffix was the convention App Router replaced. That gap is CVE-2026-44575.\n\n## The renderer canonicalizes three transport suffixes. The matcher canonicalized one.\n\nThe constants that name the App Router's transport suffixes are not new. They live in `packages/next/src/lib/constants.ts` and they have been imported by the App Router's request handler since the segment-cache work landed:\n\n```ts\nexport const RSC_SUFFIX = '.rsc'\nexport const RSC_SEGMENTS_DIR_SUFFIX = '.segments'\nexport const RSC_SEGMENT_SUFFIX = '.segment.rsc'\n```\n\nThe renderer reads those three constants to strip the suffix off an incoming URL, look up which page the canonical path resolves to, and produce the right payload type for the suffix it stripped. `GET /dashboard.rsc` and `GET /dashboard.segments/$c$children/__PAGE__.segment.rsc` and `GET /dashboard` all land in the same page module on the server. The renderer treats them as three transport variants of the same logical request.\n\n`getMiddlewareMatchers` is the other function in this codebase that classifies an incoming URL. It is one directory away. It never imported those constants. It hardcoded `\\.json` and stopped.\n\nThe fix for CVE-2026-44575, commit `d166096c39` from May 1 2026, is the import that should have happened in 2023. The commit imports `RSC_SUFFIX, RSC_SEGMENT_SUFFIX, RSC_SEGMENTS_DIR_SUFFIX` from `../../lib/constants` and uses them to build the matcher's suffix group:\n\n```ts\nconst APP_ROUTE_RSC_SUFFIX_MATCHER = escapeStringRegexp(RSC_SUFFIX)\nconst APP_ROUTE_SEGMENT_PREFETCH_SUFFIX_MATCHER =\n `${escapeStringRegexp(RSC_SEGMENTS_DIR_SUFFIX)}/.+${escapeStringRegexp(RSC_SEGMENT_SUFFIX)}`\nconst APP_ROUTE_TRANSPORT_SUFFIX_MATCHER =\n `${APP_ROUTE_RSC_SUFFIX_MATCHER}|${APP_ROUTE_SEGMENT_PREFETCH_SUFFIX_MATCHER}`\nconst MIDDLEWARE_DATA_SUFFIX_MATCHER =\n `\\\\.json|${APP_ROUTE_TRANSPORT_SUFFIX_MATCHER}`\n```\n\nThe post-patch compiled regex for the same `/dashboard/:path*` matcher reads `^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/dashboard(?:\\/(?.+?))?(\\.json|\\.rsc|\\.segments\\/.+\\.segment\\.rsc)?[\\/#\\?]?$`. Same prefix, same wildcard, four allowed suffixes instead of one.\n\n## The bypass is one request with two headers\n\n```bash\ncurl -i http://target/dashboard\n# HTTP/1.1 307 Temporary Redirect\n# location: /login?from=%2Fdashboard\n\ncurl -i -H 'RSC: 1' -H 'Accept: text/x-component' \\\n http://target/dashboard.rsc\n# HTTP/1.1 200 OK\n# content-type: text/x-component; charset=utf-8\n# \n```\n\nThe redirect on the canonical path proves middleware is wired up. The 200 on `/dashboard.rsc` proves middleware never ran for that URL. The body of that 200 is the same React tree the authenticated user would have seen, serialised as a flight payload. Whatever the protected page renders, that includes any server-fetched data, any prop, any string the developer chose to put on the page assuming middleware would gate it, is in that response. The segment-prefetch URL `/dashboard.segments/$c$children/__PAGE__.segment.rsc` works the same way for the same reason.\n\nThe matcher was the auth gate. The developer wrote middleware to redirect unauthenticated requests for `/dashboard` to `/login` because that is what the framework's auth documentation recommends. The framework's auth documentation describes middleware as the place to do authentication checks for groups of routes. There is no warning in that documentation that `matcher: '/dashboard/:path*'` means the canonical pathname and the `.json` Pages Router variant but not the `.rsc` App Router variant, because no developer reading that documentation would model the matcher that way. The developer's mental model is: this matcher governs requests for `/dashboard`. The framework's model is: this matcher governs the regex we compiled, and we compiled the regex from an enumeration of suffixes we forgot to update when we shipped the App Router.\n\n## Parallel implementation gap, applied to URL classification\n\nThis is the same shape as Vite's CVE-2026-39363 from last month. Vite had two callers of `transformRequest`. They agreed on which file to load. They disagreed on whether to consult the `server.fs.allow` allowlist. The allowlist was the gate. The renderer respected it. The transform did not. Same gate, two enforcement sites, one updated, one not.\n\nNext.js has two functions that classify a URL. The renderer strips `.rsc` and `.segments/.../.segment.rsc` and routes to a page. The matcher decides whether middleware runs. They agree the canonical pathname is `/dashboard`. They disagree on which suffixes count as transport variants of `/dashboard`. The renderer says three. The matcher said one. The patch updated the matcher to say four.\n\nThe sibling CVEs in the v16.2.4 to v16.2.5 release window are the rest of this same family. CVE-2026-44578 was the dev-server's TCP listener parallel to the router-server's RPC listener, where the RPC listener trusted the SSRF check the renderer performed elsewhere. CVE-2026-44574 was middleware behaviour governed by query parameters whose name format `nxtP*` only one of the two places that parse query parameters knew was internal. Three CVEs, one release, the same shape: two places that classify a request, one of them updated, the other one still on the old vocabulary.\n\n## `.rsc` was internal only by convention, the way `x-middleware-subrequest` was\n\nThere is no public documentation telling developers their middleware will be skipped on `.rsc` URLs. The `.rsc` suffix is described in framework internals as transport, not as a routable URL surface. Developers do not write links to `/dashboard.rsc`. The Next.js client writes those URLs, fetches them, parses the flight payload, and merges it into the page. They are internal.\n\nInternal in the sense that the framework's own components produce and consume them. Not internal in any sense the network respects. They are HTTP requests to the same listener that serves `/dashboard`. Any client can send them. The matcher's job was to be the one component that classified them correctly anyway.\n\nThis is the same pattern that produced CVE-2025-29927 last year, where `x-middleware-subrequest` was the header the framework set on itself to break recursion and the network was permitted to set it too. The header was internal by convention. The matcher's enumeration of suffixes is internal by the same kind of convention: a list of URL shapes the framework knows it produces, treated as if the network would only send what the framework produces. The patch in 2025 was to require a token on the header so the network could not forge it. The patch in 2026 is to recognise the URL shapes the framework's own client sends, so the framework does not skip the gate when its own URL conventions are spoken back to it.\n\nThe thing that makes both bugs the same bug is the developer's understanding of `/dashboard`. The developer wrote middleware for `/dashboard`. The matcher recognised the URLs the framework's documentation prepared the developer for. The URLs the framework's later releases taught its own client to send were never added to that list.","closing_line":"Next.js shipped the App Router and updated one of the two functions that classify URLs. The one it did not update was the gate.","hook_md":"On a Next.js v16.2.4 server with `middleware.ts` redirecting unauthenticated requests for `/dashboard` to `/login`, `GET /dashboard` returns 307. `GET /dashboard.rsc` returns 200 with `Content-Type: text/x-component` and the protected page's rendered subtree in the body. The App Router renderer treats `.rsc` as a transport variant of the same page. The middleware matcher regex does not. The only optional suffix in that regex is `(\\.json)?`, which is the Pages Router's data-route convention, the convention App Router replaced.","post_id":381,"slug":"nextjs-cve-2026-44575-matcher-recognized-json-not-rsc","title":"CVE-2026-44575: Next.js's Middleware Matcher Recognized `.json`. The App Router Routes `.rsc`.","type":"initial","unreadable_sentence":"The matcher's only optional suffix was the convention App Router replaced."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCalUhhAAKCRDeZjl4jgkQ JsmlAP9EsewjOs8HMD1VOBQJ5wxuY/oL55ZPW4P/swLsD6pF5AD/Tf0rURhE94MM A22H0GPsImcCb/K4MNwrNwucmT4WRQ8= =qR2l -----END PGP SIGNATURE-----