shellbits

Field NotesApril 2025

SBR-2025-01Vulnerability research 20 min

A request must not be able to say that middleware already ran: CVE-2025-29927 and in-band control headers

Next.js kept the state of its recursion guard in a request header that arrives through the same door as client traffic. We reconstruct the header from the source of 12.0.0 through 15.2.4 and from the patches on four branches, place it in a weakness class we call in-band control signals, and give a white-box audit record and a fix-verification list.

White-box auditVulnerability researchAuthorization
In this piece
  1. 01What the header does in the code
  2. 02The fix took two steps: authenticate, then remove
  3. 03The response layer: what vendors said, and how often it changed
  4. 04A classification of in-band control signals
  5. 05White-box audit: finding this class in a code base
  6. 06Method and limits

On 21 March 2025 the Next.js project published CVE-2025-29927: if an application performs its authorization check in middleware, the check can be bypassed1. The CVE record gives a CVSS 3.1 score of 9.1 and the weakness type CWE-285, Improper Authorization2. The reporters, Rachid Allam (zhero) and Yasser Allam (inzo_), explained the method in their write-up: send the header x-middleware-subrequest with the right value, and the middleware does not run at all3.

It is easy to read this as one header that was not filtered. We read the source at more than ten version tags between 12.0.0 and 15.2.4, and the patches on four release branches, and we see something different. The header is a recursion record that the framework writes for itself. When middleware calls its own site with fetch, the framework attaches the header. On our reading of the code, that request re-enters as an ordinary HTTP request, at the same entry point as client traffic. The legitimate signal and a forged one enter through the same door, and the door cannot tell them apart.

Our claim is that internal control state on a channel the client can write is a weakness class of its own. We call it the in-band control signal. Stripping a header at the entry point fixes only part of this class. A signal that must legitimately come back in through the public entry can only be made verifiable, moved out of the request, or removed. Next.js took two of those steps in seven days. The claim can be refuted: find one signal that must legitimately arrive through the public entry and that was fixed by entry stripping alone, and the classification needs to change.

01What the header does in the code#

Unless we say otherwise, this section reports what we saw in the source files of vercel/next.js at the tags named. We did not run any version. Step three of the flow, the return through the public entry, is our reading of the code, not a trace.

The writer: every fetch from middleware#

In 12.0.0, sandbox.ts has a function named getFetchHeaders. It reads any x-middleware-subrequest value already on the outgoing request, splits it on colons, appends the name of the current middleware, and writes it back. It also sets user-agent to Next.js Middleware4. Later versions move this code into context.ts, and at 15.2.2 it still appends the name in the same way5. Neither location checks the destination host, so every fetch from middleware carries the header, including calls to third-party APIs. Later versions run Edge-runtime routes in the same sandbox, so their fetch calls get the header too; the test in pull request #60615 is such a route8.

Vercel's post-mortem gives the purpose: middleware runs in a separate process, and when it fetches its own application an internal header tells the routing process that middleware has already run, which detects and prevents recursion14. That is the vendor's statement. The code we read agrees on the purpose. At 12.0.7 and 15.2.2 the server calls the sandbox directly, and we saw no separate process there65.

  1. 01

    Middleware runs

    User middleware calls fetch on its own site

    Normal
  2. 02

    Wrapped fetch

    The framework attaches x-middleware-subrequest with the middleware name in the value

    Normal
  3. 03

    Public entry

    The request returns over the network to the same HTTP entry point as any outside request

    Origin unknown
  4. 04

    Reader

    Reads the header; if the name occurs (five times in later versions) it returns x-middleware-next

    Trust on presence
  5. 05

    Routing

    The request goes to the page or API; the check in middleware never ran

    Check skipped

The reader: three forms#

Tags we readFile and functionCondition that skips middleware
12.0.7runMiddleware in packages/next/server/next-server.tsThe colon-separated list includes middlewareInfo.name6
12.0.8, 13.5.6, 14.1.4run in server/web/sandbox/sandbox.tsThe list includes params.name71516
14.2.0, 14.2.24, 15.2.2, 15.2.3SameThe number of entries equal to params.name reaches MAX_RECURSION_DEPTH, which is 51712

The second form:

packages/next/server/web/sandbox/sandbox.ts (v12.0.8, excerpt)ts
  const subreq = params.request.headers[`x-middleware-subrequest`]
  const subrequests = typeof subreq === 'string' ? subreq.split(':') : []
  if (subrequests.includes(params.name)) {
    return {
      waitUntil: Promise.resolve(),
      response: new context.Response(null, {
        headers: {
          'x-middleware-next': '1',
        },
      }),
    }
  }

When the condition holds, the function returns an empty response with x-middleware-next, which tells the server to go on. The user's middleware is not called7. To make it hold, a sender needs only the name. The researchers point out that the name is the path of the middleware file, which follows from the framework's file conventions3.

The third form comes from pull request #60615, merged on 6 February 2024. Its description says the aim is to allow 5 recursive calls to match Vercel production8. The same pull request adds code that copies the incoming x-middleware-subrequest value onto the fetch calls that middleware makes, so the framework now passes a client-supplied value down the chain.

Secondary write-ups disagree on when this changed: ProjectDiscovery says a recursion depth limit exists from 13.2.018, and Datadog says the change came in 15.x19. The tags we read place it between 14.1.4 and 14.2.01617.

A lower bound that does not match#

The researchers say that every version from 11.1.4 is affected3. The CVE record starts its affected range at 11.1.4, as did the advisory a week before the dateline220. The record's description says 1.11.4, which we take as a typing error. That description dates from 8 April 2025; the original of 21 March named only 14.2.25 and 15.2.321.

We did not find the header in next-server.ts at the v11.1.4 tag22; the writer is present at 12.0.04. The npm package agrees: the file list of next@11.1.4 has nothing under dist/server/web, and dist/server/next-server.js lacks the string23. The code we read does not support the 11.1.4 bound; we do not know its basis.

02The fix took two steps: authenticate, then remove#

  1. PR #60615 merged: the skip condition becomes five occurrences of the same name8

    Code
  2. PR #73482 merged: an entry strip list of eight internal headers, without x-middleware-subrequest9

    Code
  3. The same list is backported to the 14.x branch24

    Code
  4. The researchers report through GitHub private reporting; the report names only 12.x14

    Report
  5. The researchers add that the latest stable releases are affected too3

    Report
  6. Vercel's security team raises the report to the Next.js team, which confirms it14

    Triage
  7. The fix is merged and 14.2.25 ships; 15.2.3 follows early on 18 March (GMT)1410

    Fix
  8. The advisory and the CVE become public1

    Disclosure
  9. 13.5.9 ships; Cloudflare deploys a WAF rule and makes it opt-in the same day1413

    Fix
  10. 12.3.5 ships14

    Fix
  11. 15.2.4, 14.2.26, 13.5.10 and 12.3.6 delete the recursion header logic122513

    Removal
  12. The advisory for CVE-2025-30218 is published26

    Disclosure

Step one: a secret that travels with the signal#

The 15.x fix does three things10:

  1. At server start it generates 8 random bytes, encodes them as 16 hexadecimal characters, and stores them in a global.
  2. The middleware fetch wrapper adds a second header, x-middleware-subrequest-id, with that identifier as its value.
  3. filterInternalHeaders, at the entry point, gets one more condition: if a request has x-middleware-subrequest and its -id value is not this process's identifier, delete x-middleware-subrequest.

The reader is unchanged. The commit message is one sentence:

This just adds an additional header to our internal filtering list for middleware.10

The branches enforce the fix in different places. The 13.x branch did not have the eight-name list, so its backport adds the filterInternalHeaders function, the list and the call at the entry together27. The 12.x branch has no entry filter; its patch changes the reader directly, to skip only if the identifier matches and the name occurs28.

We draw two inferences from this code and tested neither. First, each process generates its own identifier, so with several instances a subrequest from instance A that lands on instance B loses the header and runs middleware again. That is safe for authorization and weakens the recursion guard. Second, the fix commit was public on 17 March and contains a test that sends the header; the advisory came on 21 March101. In between, anyone who reads diffs could learn the header name and the form of its value.

Step two: the secret took the same road#

On 2 April Vercel described the problem with the first fix: the identifier is sent on all requests, even when the destination is not the Next.js application's host, so a fetch to a third party from middleware hands the identifier to that party11. The issue is CVE-2025-30218, rated low. The affected versions are exactly the four that had just been patched: 12.3.5, 13.5.9, 14.2.25 and 15.2.326. Vercel says exploitation is unlikely because the attacker must control the third party11.

The four releases of 24 March do not adjust the check again: the diffs for 15.2.4 and 12.3.6 show the writer, the reader and the identifier check removed1225. Vercel says it already planned to remove this recursion protection, because newer Middleware work that supports the Node.js runtime does not support it, and that the disclosure moved the plan forward11.

Cloudflare describes the same events differently: the vulnerability is fully patched in 14.2.26 and 15.2.4, and the earlier interim releases did not fully patch it13. Vercel treats the second issue as a separate low-severity vulnerability.

Why the entry list did not catch it#

Pull request #73482, in December 2024, adds filterInternalHeaders. The commit description says internal request headers are not intended to be used externally, so the change filters them9. The list has eight names, among them x-middleware-rewrite, x-middleware-next and x-now-route-matches. In the last 15.x release before the fix, the list still has those eight29. It reached 14.x 17 days before the report24.

We do not know why x-middleware-subrequest was left out. The code shows that the filter sits at the start of request handling9, and the subrequests that middleware sends to itself come in at the same place. Put the name on the list, and the legitimate recursion signal is deleted too, so the guard stops working. This is an inference; we did not run it. The fix is consistent with it: it deletes conditionally, and its code comment describes the deleted case as a request that did not originate from this session10.

This was not the first such problem in this code base. In January 2025 zhero wrote that some internal parts of the framework were not closed to the outside, and named several internal headers. The same article explains that the cache poisoning of CVE-2024-46982 used x-now-route-matches30. That advisory is dated 17 September 202431, and the name is on the eight-name list. Our reading is that the list answered particular incidents and was not built from the other end, by listing every header the framework reads.

03The response layer: what vendors said, and how often it changed#

From report to fix#

18 days

From the report (2025-02-27 06:03 GMT) to the first fixed release, 14.2.25 (17 March 22:44 GMT), on Vercel's timeline14

7 days

From the merge of the first fix (17 March) to the releases that delete the mechanism (24 March)1012

3 versions

Of the vendor's answer, between 22 and 25 March, to whether applications on Cloudflare were affected323314

Vercel explains the delay this way. The first report named only 12.x, so it had a lower triage priority. The follow-up of 1 March opened a new thread. The reply of 5 March was about a planned LTS policy under which 11.x and 12.x would get no security patches14. The researchers' timeline is compatible and adds reminders on 5 and 11 March3.

The vendor's own accounts differ on one point. The Next.js blog post of 22 March says the 15.x patch was pushed at 19:08Z on 14 March32. The post-mortem says the public pull request was opened at 17:54 GMT on 17 March14. The first may refer to a private branch; neither text says.

The post-mortem lists commitments: document the internal headers or replace them with a proper API, open a partner mailing list, and take reports only through GitHub private reporting. It says the internal header was undocumented14.

Which deployments were affected#

Every row below is a statement by the vendor named. We tested no platform.

Time (UTC)SourceStatement about hosting
22 March 15:27Cloudflare changelog, first versionThe WAF rule has been deployed automatically to all sites3435
22 March 19:49, archivedNext.js blogApplications hosted on Vercel, Netlify and Cloudflare are not affected32
22 March 20:26Netlify forumSites on Netlify are not and have never been affected; end-to-end tests were added to the OpenNext Netlify adapter36
22 March 22:53, archivedNext.js blogNot affected: Vercel, Netlify and static exports only. Cloudflare moves under "Affected", worded as a managed WAF rule that can be turned on33
25 MarchVercel post-mortemNetlify and Cloudflare Workers were confirmed never to have been affected, for the same reason as Vercel: application routing is decoupled14

An application on Cloudflare can be one deployed on Workers, or a self-hosted Next.js server with Cloudflare in front of it. The blog post does not separate the two, and the post-mortem speaks only of the first. Cloudflare's own text says the rule protects Next.js sites on Workers and Pages, and applications hosted elsewhere that use Cloudflare for protection13. It does not say whether an application on Workers has the weakness itself.

According to Vercel, the affected setups are self-hosted applications that use next start and output: 'standalone'; static exports have no middleware. On the Vercel platform the routing logic runs in a separate, globally distributed system, and the post-mortem says this made Vercel "incidentally invulnerable"14. Vercel's changelog of 22 March first said its Firewall protected customers; a capture eight hours later says customers are not affected3738. The post-mortem admits that this changelog reused an earlier template, mentioned the firewall, and was confusing14.

By 3 April the blog URL redirected to the post-mortem; the capture of 2 April still has the original text, which now survives only in the archive39. The official documentation, archived one week before the report, lists authentication and authorization as the first common use of Middleware40, while the post-mortem says Vercel does not recommend Middleware as the sole method of protecting routes14.

The WAF rule: the cost of matching on presence#

By Cloudflare's description, the rule blocks requests that have the x-middleware-subrequest header, regardless of Next.js version, and the custom rule it offers as an alternative tests only whether the header exists13. The page dates the change to opt-in at 16:00 UTC on 22 March, and the matching edit in the documentation repository was merged at 18:46 UTC1335. Cloudflare's stated reason is that sites using auth middleware with third-party auth vendors saw failing requests13. The researchers' write-up has an update that says the rule produced many false positives3.

Datadog's observations of 28 March fit this. It saw a low volume of scans, and most of the payloads it identified were normal activity. Its examples are requests with the Vercel Edge Functions user agent, whose header value looks like a 40-character hexadecimal ID, and recursive middleware with the Next.js Middleware user agent19. CISA's SSVC entry on the CVE record is not a stable signal: Exploitation was none on 21 March, poc from 26 March, and none again on 8 April41.

Cloudflare does not explain the mechanism; a note on the page says only that the rule blocked requests across sites for specific authentication middleware13. Our inference comes from the writer code: the sandbox sends the header on a fetch to any host, so a third-party authentication API receives legitimate requests that carry it. If that API is itself behind Cloudflare, a default-on rule that matches on presence blocks them. One public report describes this for another API: a Next.js issue of 24 March says fetch calls from an Edge-runtime route on 15.2.3 to an API behind Cloudflare carried the header and failed, while the same calls from the Node.js runtime worked42. It is one user's report, filed after the rule became opt-in, and we did not reproduce it. If Cloudflare publishes a different cause, this inference falls.

A writer that ignores the destination puts its signal at other people's entry points, where a presence rule blocks it along with attack traffic. When Cloudflare made the rule opt-in, it added that the rule can first be set to Log to check the impact35.

04A classification of in-band control signals#

The CVE record uses CWE-2852. That describes the result: an authorization check that was not performed correctly. For the cause, we think CWE-807 is closer. Its description reads:

The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.43

This mapping is our judgement, not the record's. By in-band control signal we mean metadata that travels on the same channel as user data and changes how a component behaves. This article looks only at HTTP request headers.

Who writes, who trusts, who strips#

The table puts this case next to others that have primary documentation. The last column is our classification.

SignalWho writes itWho trusts it, and for whatWho strips itBasis of trust
X-Forwarded-For, -Host, -ProtoA reverse proxyThe application framework: client address, host name, whether the request used HTTPSThe documentation requires the last trusted proxy to remove or overwrite them4445Entry stripping
X-Original-URL, X-Rewrite-URLSymfony calls them legacy IIS headersSymfony HttpFoundation: the request pathNobody; fixed in 2018 by removing support46Presence
x-envoy-*Envoy, or a caller that Envoy classifies as internal (our reading)EnvoyEnvoy sanitizes them depending on whether the request is internal or external47Entry stripping
x-amzn-oidc-dataAWS Application Load BalancerThe backend application: user identityThe documentation requires verification of the signature and the signer field, and recommends that targets accept traffic only from the load balancer48Signature
x-now-route-matches and seven othersNext.js internalsNext.js routing and middleware handlingThe entry list, from December 20249Entry stripping
x-middleware-subrequestThe wrapped fetch in Next.jsNext.js: whether to run middlewareNobody before the fixPresence, then a co-travelling secret, then removed1012

The Symfony advisory credits James Kettle, who reported the issue to the Drupal security team. It says a user could access one URL and have Symfony return a different one, which can bypass restrictions on higher-level caches and web servers46.

The difference lies between the second and fourth columns. For X-Forwarded-*, the writer and the strip point are the same component, on the boundary. For x-middleware-subrequest, the writer stands behind the boundary, but the signal goes around to the front and comes in again. There is no place to put a strip point.

When the signal is absent#

Forging a signal is one direction; making it disappear is the other. Section 7.6.1 of RFC 9110 requires an intermediary to parse the Connection header before it forwards a message and to remove every field that the header names49. In 2019 Nathan Davison showed that a client can use this by naming a proxy-added header in Connection. Some systems forward that list to the next hop unchanged, and a later node then removes the header. One example in the post is X-Forwarded-For: once it is removed, the backend sees a different source address50.

So each signal needs this question: when it is absent, does the system take the stricter path or the looser one?

Five bases of trust#

  1. 01

    Trust on presence

    The header exists and its value has the right form, so it is believed. x-middleware-subrequest before the fix and X-Original-URL are at this level.

    Forgeable
  2. 02

    Entry stripping

    A boundary component deletes or overwrites the header, and components behind it then trust it. Two conditions: the legitimate signal does not have to come in through the same entry, and the backend cannot be reached around the boundary.

    Depends on deployment
  3. 03

    Co-travelling secret

    A value that only the product knows is attached next to the signal. The secret takes the same road as the signal: where the writer sends one, it sends the other.

    Leaks
  4. 04

    Signature

    The signal itself proves its origin. The receiver checks the key and the signer.

    Verifiable
  5. 05

    Out of band

    The state is not in the request. It is in an in-process call argument, on a separate connection, or recorded by the server itself.

    Request cannot write it

The labels are our assessment. The nginx internal directive is an out-of-band example: a location marked with it accepts only internal requests that the server generates, and returns 404 to external ones51. No request field can declare a request internal.

The Next.js fix history maps onto this ladder: level one, level three, then removal. On our reading, level two was not available, for the reason given in the previous section. Level three lasted seven days and left a CVE of its own. Vercel says its platform was not affected because routing runs in a separate system14. We read that as level five.

Our judgement: when you find a level-one signal, first ask whether it can be removed. Symfony and Next.js both ended there. If it cannot, go to level four or five, and do not stop at level three.

05White-box audit: finding this class in a code base#

Three lists: reads, writes, strips#

First build three lists and compare them. Adjust the search strings to the language and framework.

Search targetstext
Header reads          headers[   headers.get(   getHeader(   req.header(   request.META   $_SERVER['HTTP_   Header.Get(
Name hints            internal  subrequest  invoke  skip  bypass  override  rewrite  original
                      forwarded  real-ip  matched  trusted  authenticated
Writes on outgoing    headers.set(   setHeader(   and wrappers around fetch and HTTP clients
Strip and filter      INTERNAL_HEADERS   strip   sanitize   filter   delete headers[
Response as command   code that treats an upstream response header as a rewrite, redirect or internal-jump instruction

Every name on the read list must be on the strip list, or have a verification step. A name with neither is a candidate. In this case x-middleware-subrequest is on the read and write lists and not on the strip list. Starting from the reads finds it; starting from known incidents and adding names to the strip list does not.

One record per header#

In-band signal audit recordtext
Name
Read point               file and function
Decision affected        skip a check / select an identity / change the path / change the cache key / other
Writers                  which components write it legitimately
Path of the legit signal in-process / internal connection / public entry
Strip point              which component and function; write "none" if there is none
Basis of trust           presence / entry stripping / co-travelling secret / signature / out of band
Behaviour when absent    stricter / looser
Outbound scope           does the writer limit the destination
Maintained branches      identical or not; if not, one record per branch

Then decide:

The record showsVerdictNext step
A security decision, and the basis of trust is presenceVulnerabilityRemove the signal if possible; otherwise move to a signature or out of band
A strip point exists, but the legitimate signal enters through the public entryStripping does not holdSame as above; do not only add the name to a list
The basis is entry stripping, and the backend can be reached directlyVulnerable in some deploymentsRestrict the sources of the backend, or verify at the backend
The basis is a co-travelling secretMore checks neededCheck the outbound scope, the lifetime of the secret and the behaviour with several instances; a failed check must take the stricter path
Behaviour is looser when the header is absentPossibly exposed to removal techniquesTest what happens when Connection names the header; reject when it is missing

Verifying a fix#

  1. Run a negative test. Set a response header in middleware as a marker, send a request from outside with the internal header, and confirm that the marker is still there. The self-check that Netlify published works this way36. Test every historical form of the reader; this case has three.
  2. Read the reader after the patch. In 15.2.3 the reader is unchanged and safety depends on the conditional delete at the entry. In 15.2.4 the reader is gone1012. Both pass the same negative test, with different residual risk.
  3. Run a leak test. Make middleware send a request to an external endpoint that you control, and inspect the received headers for internal names or identifiers. CVE-2025-30218 is the kind of problem this test finds11.
  4. Verify each branch separately. Here the 12.x patch and the patches for 13.x and later are in different places2827.
  5. Log before you block at the boundary. Legitimate traffic with this header exists1913.
  6. Confirm that authorization is not only in middleware. For each protected route, find a second check in the route handler or in the data access layer.

06Method and limits#

References51

  1. Authorization Bypass in Next.js Middleware (GHSA-f82v-jwr5-mffw)GitHub Advisory Database · 2025-03-21github.com/advisories/GHSA-f82v-jwr5-mffwThe vendor advisory. Supports the impact statement, the fixed versions on four branches, workaround-only for 11.x, the statement that Vercel deployments are protected, and the Critical / 9.1 rating. All of this is already in captures from before the dateline (2025-04-01 and 2025-04-02). The page was updated after the dateline (2026-03-02); we do not use today's EPSS figure or machine-readable ranges. Today's page gives 12.0.0 as the lower bound of the affected range; at the dateline it was 11.1.4, see ghsa-f82v-archive.
    AdvisoryOriginal read↩× 4
  2. CVE-2025-29927 (CVE Record, JSON 5.1)CVE Program; CNA: GitHub · 2025-03-21cveawg.mitre.org/api/cve/CVE-2025-29927Record last updated 2025-04-08T15:17Z, the same day as the dateline. Supports CWE-285, the CVSS 3.1 vector and 9.1 score, the affected range starting at 11.1.4, the description text that says 1.11.4, and the CISA SSVC assessment now attached to the record (2025-04-08, Exploitation: none). That value changed before; for it the article cites cvelist-history.
    Registry recordOriginal read↩× 3
  3. Next.js and the corrupt middleware: the authorizing artifactRachid Allam (zhero;), Yasser Allam (inzo_) · zhero_web_security · 2025-03zhero-web-sec.github.io/research-and-things/nextjs-and-the-corrupt-mi…The reporters' own write-up. Supports what the header does, how the value follows from file conventions, the researchers' side of the timeline, the figure of more than 9.4 million weekly downloads, and the update about the Cloudflare rule becoming opt-in. The page is dated only March 2025; the earliest archived copy is from 2025-03-22 and the 24 March copy has the same body as today. The 11.1.4 lower bound comes from this page; we could not confirm it from code. The sentences the article uses are also in the capture of 2025-04-07.
    First-hand reportOriginal read↩× 6
  4. packages/next/server/web/sandbox/sandbox.ts (tag v12.0.0)vercel/next.js · 2021-10-26raw.githubusercontent.com/vercel/next.js/v12.0.0/packages/next/server…Supports: getFetchHeaders in 12.0.0 appends x-middleware-subrequest to outgoing requests and sets the user-agent, with no destination check. The date is the publication date of the v12.0.0 release on GitHub. The sandbox is built with Node's vm module; next-server.ts at the same tag calls its run function directly, and we saw no child process.
    Source codeOriginal read↩× 3
  5. packages/next/src/server/web/sandbox/context.ts (tag v15.2.2)vercel/next.jsraw.githubusercontent.com/vercel/next.js/v15.2.2/packages/next/src/se…Supports: in the last 15.x release before the fix, the fetch wrapper still appends x-middleware-subrequest to every outgoing request and copies the incoming value; this block has no check on the destination host. The sandbox is an Edge Runtime instance; next-server.ts at the same tag loads and calls the sandbox's run function directly (once for middleware, once for Edge functions), and we saw no child process or worker. The user-agent is set only when the outgoing request has none.
    Source codeOriginal read↩× 3
  6. packages/next/server/next-server.ts (tag v12.0.7)vercel/next.jsraw.githubusercontent.com/vercel/next.js/v12.0.7/packages/next/server…Supports: runMiddleware reads the header, splits it on colons and skips with NextResponse.next() when the list includes middlewareInfo.name. The same file at 12.0.0 has the same logic. The same file imports and calls the sandbox's run function directly; we saw no child process or worker in it.
    Source codeOriginal read↩× 3
  7. packages/next/server/web/sandbox/sandbox.ts (tag v12.0.8)vercel/next.js · 2022-01-12raw.githubusercontent.com/vercel/next.js/v12.0.8/packages/next/server…Supports: the check moved into run in sandbox.ts and tests whether the list includes params.name; the code excerpt in the article is from this file. The date is the publication date of the v12.0.8 release.
    Source codeOriginal read↩× 3
  8. fix: allow some recursion for middleware subrequests (#60615)Julius Marminge · vercel/next.js (commit 6d07c00) · 2024-02-06github.com/vercel/next.js/commit/6d07c00dee39435e21c1113a85a7398c03cb…Supports the change of the skip condition from membership to five occurrences, the stated reason of matching Vercel production, and the added code that copies the incoming header onto outgoing fetches. We cannot read the Slack thread the description links to. The test the pull request adds is an Edge-runtime route that fetches its own URL and is expected to stop after five calls; this shows that the same sandbox serves Edge routes and that the subrequest returns to the server and reaches the reader.
    Source codeOriginal read↩× 4
  9. remove unnecessary internal middleware header from response (#73482)Zack Tanner · vercel/next.js (commit 224ca18) · 2024-12-03github.com/vercel/next.js/commit/224ca189921354cfbb0d531b948842b1a48d…Supports the date the INTERNAL_HEADERS entry list was added, its eight names, the commit description and the call at the entry. It does not say why x-middleware-subrequest is not on the list.
    Source codeOriginal read↩× 5
  10. Update middleware request header (#77201)JJ Kasper · vercel/next.js (commit 52a078d, 15.x) · 2025-03-17github.com/vercel/next.js/commit/52a078da3884efe6501613c7834a3d02a916…The 15.x fix. Supports how the random identifier is generated, the fetch wrapper adding the -id header, the conditional delete at the entry, the commit message wording, and the test that sends the header. We also read the 14.x backport (5fd3ae8); the code change is the same. The code comment above the conditional delete says that the header is filtered out when the request did not originate from this session, so that middleware is not skipped incorrectly. The identifier is generated in initialize in router-server.ts.
    Source codeOriginal read↩× 9
  11. CVE-2025-30218Ty Sbano · Vercel · 2025-04-02vercel.com/changelog/cve-2025-30218-5DREmEH765PoeAsrNNQj3OThe vendor's explanation. Supports: the identifier was sent on all outgoing requests, exploitation needs control of the third party, removal of the recursion protection was already planned, Vercel customers are protected. The archived copy of 2025-04-07 has the same body as today.
    Vendor statementOriginal read↩× 5
  12. Comparing v15.2.3...v15.2.4 (GitHub compare API)vercel/next.js · 2025-03-24api.github.com/repos/vercel/next.js/compare/v15.2.3...v15.2.4Supports: the commit "Match subrequest handling for edge and node (#77474)" deletes the depth check in sandbox.ts, the write and the copy in context.ts, the conditional delete in utils.ts and the matching test. It also shows that 15.2.3 still had the MAX_RECURSION_DEPTH = 5 check.
    Source codeOriginal read↩× 7
  13. New Managed WAF rule for Next.js CVE-2025-29927.Cloudflare · 2025-03-22developers.cloudflare.com/changelog/2025-03-22-next-js-vulnerability-wafSupports: the rule blocks requests that carry the header, the custom-rule example matches on the header's existence, the change to opt-in at 16:00 UTC on 22 March and its stated reason, the two updates of 24 March, and Cloudflare's view of which releases fully patch the issue. Every sentence we cite is in the documentation repository's copy of the page as of 2025-03-25 (commit 547e9a3). The page does not publish the managed rule's expression and does not explain the mechanism of the failing requests. The same version has a note that says the rule is not enabled by default because it blocked requests across sites for specific authentication middleware.
    Vendor statementOriginal read↩× 10
  14. Postmortem on Next.js Middleware bypassTy Sbano · Vercel · 2025-03-25vercel.com/blog/postmortem-on-next-js-middleware-bypassThe vendor post-mortem. Supports the minute-level timeline, the stated reasons for the delay, which hosting setups the vendor says were affected, the purpose of the header and the follow-up commitments. All of it is the vendor's account. The archived copy of 2025-04-02 has the same body as today.
    Vendor statementOriginal read↩× 16
  15. packages/next/src/server/web/sandbox/sandbox.ts (tag v13.5.6)vercel/next.jsraw.githubusercontent.com/vercel/next.js/v13.5.6/packages/next/src/se…Supports: at 13.5.6 the condition is still subrequests.includes(params.name), with no depth count.
    Source codeOriginal read↩
  16. packages/next/src/server/web/sandbox/sandbox.ts (tag v14.1.4)vercel/next.jsraw.githubusercontent.com/vercel/next.js/v14.1.4/packages/next/src/se…Supports: at 14.1.4 the condition is still membership; MAX_RECURSION_DEPTH is absent.
    Source codeOriginal read↩× 2
  17. packages/next/src/server/web/sandbox/sandbox.ts (tag v14.2.0)vercel/next.js · 2024-04-11raw.githubusercontent.com/vercel/next.js/v14.2.0/packages/next/src/se…Supports: 14.2.0 already uses the count against MAX_RECURSION_DEPTH = 5. We also read the file at the same path at tags 14.2.24 and 15.2.2, which have the same check; they are not listed separately. The date is the publication date of the v14.2.0 release.
    Source codeOriginal read↩× 2
  18. CVE-2025-29927: Next.js Middleware Authorization Bypass - Technical AnalysisPrince Chaddha · ProjectDiscovery · 2025-03-23projectdiscovery.io/blog/nextjs-middleware-authorization-bypassUsed for one point only: it says the recursion depth limit exists from 13.2.0, which does not match the code we read.
    Research reportOriginal read↩
  19. Understanding CVE-2025-29927: The Next.js Middleware Authorization Bypass VulnerabilityFrederic Baguelin, Eslam Salem, Emile-Hugo Spir, Matt Muir, Adrian Korn · Datadog Security Labs · 2025-03-28securitylabs.datadoghq.com/articles/nextjs-middleware-auth-bypassSupports Datadog's observation of a low volume of scans and of normal traffic that carries the header (a 40-character hex value from Vercel Edge Functions, the Next.js Middleware user agent). It is also the source of the statement that the depth count arrived in 15.x, which the code does not support. The sentences the article uses are in the capture of 2025-04-02.
    Research reportOriginal read↩× 3
  20. Authorization Bypass in Next.js Middleware (GHSA-f82v-jwr5-mffw)GitHub Advisory Database (Internet Archive capture, 2025-04-01) · 2025-04-01web.archive.org/web/20250401131901id_/https://github.com/advisories/G…A capture from one week before the dateline. Supports: at that time the advisory's affected range read >= 11.1.4, < 12.3.5, and 11.x had a workaround only. The file history in github/advisory-database (seven versions) agrees: the first version of 2025-03-21 gave only a workaround for 11.1.4 through 13.5.6; 13.5.9 and 12.3.5 were added on 2025-03-24; the lower bound changed to 12.0.0 only on 2026-03-02, which the article does not use.
    AdvisoryOriginal read↩
  21. CVE-2025-29927 Change History (NVD CVE History API)NIST National Vulnerability Database · 2025-04-08services.nvd.nist.gov/rest/json/cvehistory/2.0?cveId=CVE-2025-29927Supports: the original description of 2025-03-21 named only 14.2.25 and 15.2.3; on 2025-04-08 it was rewritten to start at 1.11.4 and to add 12.3.5 and 13.5.9. The API also lists changes after the dateline (2025-09-10, 2026-06-17); the article does not use them.
    Registry recordOriginal read↩
  22. packages/next/server/next-server.ts (tag v11.1.4)vercel/next.jsraw.githubusercontent.com/vercel/next.js/v11.1.4/packages/next/server…Supports: the string x-middleware-subrequest does not occur in this file at this tag. This covers one file at the Git tag; the tag also has no packages/next/server/web directory. For the npm package see npm-11-1-4.
    Source codeOriginal read↩
  23. next@11.1.4: package file list (jsDelivr data API)jsDelivr (public CDN mirror of npm packages) · 2022-01-27data.jsdelivr.com/v1/package/npm/next@11.1.4/flatSupports: the file list of the 11.1.4 package has 1,104 files and none under dist/server/web (the 12.0.0 list has 54); dist/server/next-server.js on the same mirror (https://cdn.jsdelivr.net/npm/next@11.1.4/dist/server/next-server.js) does not contain the string x-middleware-subrequest. The date is the publication time of 11.1.4 in the npm registry, which is later than 12.0.0 (2021-10-26). We read only the list and this one text file; we did not download, unpack or run the package, and we did not separately verify that the mirror matches the npm registry.
    Registry recordOriginal read↩
  24. [Backport v14] add additional x-middleware-set-cookie filtering (#75561) (#75870)Zack Tanner · vercel/next.js (commit 5791cb6, 14.x) · 2025-02-10github.com/vercel/next.js/commit/5791cb677808df1cea625057d6aff95fbf5c…Supports: the same eight-name list was backported to the 14.x branch on 2025-02-10.
    Source codeOriginal read↩× 2
  25. Comparing v12.3.5...v12.3.6 (GitHub compare API)vercel/next.js · 2025-03-24api.github.com/repos/vercel/next.js/compare/v12.3.5...v12.3.6Supports: the 12.x branch deleted the identifier, the writer and the decision check on the same day. We also read the 13.5.10 and 14.2.26 diffs, which do the same; they are not listed separately. The 13.5.10 and 14.2.26 diffs are at https://github.com/vercel/next.js/compare/v13.5.9...v13.5.10 and https://github.com/vercel/next.js/compare/v14.2.25...v14.2.26 .
    Source codeOriginal read↩× 2
  26. Next.js may leak x-middleware-subrequest-id to external hosts (GHSA-223j-4rm8-mrmf, CVE-2025-30218)GitHub Advisory Database · 2025-04-02github.com/advisories/GHSA-223j-4rm8-mrmfSupports the publication date, the low severity, that the affected versions are exactly 12.3.5, 13.5.9, 14.2.25 and 15.2.3, and the fixed versions 12.3.6, 13.5.10, 14.2.26 and 15.2.4. The page was updated on 2025-10-13; we do not cite its CVSS 4.0 score. The affected versions, fixed versions and severity are the same in the advisory database file (github/advisory-database) as of 2025-04-02 and 2025-04-03.
    AdvisoryOriginal read↩× 3
  27. [backport] middleware subrequest patch (#77418)JJ Kasper · vercel/next.js (commit 0a49ce1, 13.x) · 2025-03-22github.com/vercel/next.js/commit/0a49ce10b9ca584d43626803990587c1b764…The 13.x backport. Supports: this patch adds the filterInternalHeaders function, the eight-name list and the call at the entry to the 13.x branch.
    Source codeOriginal read↩× 2
  28. [backport] middleware subrequest patch (#77424)JJ Kasper · vercel/next.js (commit 6390e07, 12.x) · 2025-03-22github.com/vercel/next.js/commit/6390e074da6211c6ccb47216451358c70a98…The 12.x backport. Supports: on 12.x the identifier is compared at the decision point in sandbox.ts; there is no entry filter function.
    Source codeOriginal read↩× 2
  29. packages/next/src/server/lib/server-ipc/utils.ts (tag v15.2.2)vercel/next.jsraw.githubusercontent.com/vercel/next.js/v15.2.2/packages/next/src/se…Supports: in the last 15.x release before the fix, INTERNAL_HEADERS still has eight names and does not include x-middleware-subrequest.
    Source codeOriginal read↩
  30. Next.js, cache, and chains: the stale elixirRachid Allam (zhero;) · zhero_web_security · 2025-01zhero-web-sec.github.io/research-and-things/nextjs-cache-and-chains-t…Supports: exploitation of CVE-2024-46982 used x-now-route-matches, and the researcher had already noted that the framework's internal headers could be influenced from outside. This is the researcher's account; we did not reproduce it.
    First-hand reportOriginal read↩
  31. Next.js Cache Poisoning (GHSA-gp8f-8m3g-qvj9, CVE-2024-46982)GitHub Advisory Database · 2024-09-17github.com/advisories/GHSA-gp8f-8m3g-qvj9Supports the publication date, High severity, the affected and fixed versions, and that deployments on Vercel are not affected. The advisory itself does not name the header.
    AdvisoryOriginal read↩
  32. CVE-2025-29927Lee Robinson · Next.js blog (Internet Archive capture, 2025-03-22 19:49 UTC) · 2025-03-22web.archive.org/web/20250322194919id_/https://nextjs.org/blog/cve-202…The earliest capture we found. Supports: at that time the post said applications hosted on Vercel, Netlify and Cloudflare were not affected; its timeline says patches were pushed on 14 March.
    Vendor statementOriginal read↩× 3
  33. CVE-2025-29927Lee Robinson · Next.js blog (Internet Archive capture, 2025-03-22 22:53 UTC) · 2025-03-22web.archive.org/web/20250322225339id_/https://nextjs.org/blog/cve-202…A capture about three hours later. Supports: Cloudflare moved from the not-affected list to the affected section, worded as a managed WAF rule that can be turned on; the not-affected list keeps only Vercel, Netlify and static exports.
    Vendor statementOriginal read↩× 2
  34. Commit history: src/content/changelog/workers/2025-03-22-next-js-vulnerability-waf.mdxcloudflare/cloudflare-docs (GitHub commits API) · 2025-03-25api.github.com/repos/cloudflare/cloudflare-docs/commits?path=src/cont…Supports: the first commit of this changelog entry is at 2025-03-22T15:27:21Z, followed by five edits up to 25 March. These are documentation times, not the times the rule was actually enabled or disabled.
    Registry recordOriginal read↩
  35. changelog: update CVE-2025-29927 changelog (#21062)cloudflare/cloudflare-docs · 2025-03-22github.com/cloudflare/cloudflare-docs/pull/21062.diffSupports: the first version said the rule was automatically deployed to all sites; this change rewrote it to opt-in and added the note that the rule can first be set to Log. The merge time of 2025-03-22T18:46:44Z comes from the commit record (commit 82fcd1b).
    Registry recordOriginal read↩× 3
  36. Next.js sites on Netlify are NOT vulnerable to CVE-2025-29927 / GHSA-f82v-jwr5-mffwserhalp · Netlify Support Forums · 2025-03-22answers.netlify.com/t/next-js-sites-on-netlify-are-not-vulnerable-to-…Supports Netlify's statement that sites on Netlify are not and have never been affected, that end-to-end tests were added to the OpenNext Netlify adapter, and the published self-check that uses a response header as a marker. We did not test it. The page metadata gives the post time as 2025-03-22T20:26:52Z and the last edit as 2025-03-24.
    Vendor statementOriginal read↩× 2
  37. Vercel Firewall proactively protects against vulnerability with MiddlewareAaron Brown · Vercel (Internet Archive capture, 2025-03-22 16:34 UTC) · 2025-03-22web.archive.org/web/20250322163420id_/https://vercel.com/changelog/ve…The earliest capture of the same changelog entry. Supports: at that time the title and the text said that Vercel customers were proactively protected by its Firewall, and listed the fixed versions 15.2.3 and 14.2.25.
    Vendor statementOriginal read↩
  38. Protection against Next.js CVE-2025-29927Aaron Brown · Vercel · 2025-03-22vercel.com/changelog/vercel-firewall-proactively-protects-against-vul…Supports Vercel's statement that its customers are not affected and should still update. This is the rewritten version: the capture of 2025-03-23 00:37 UTC already has this title and these two sentences, and the capture of 2025-04-03 is the same. For the first version see vercel-changelog-v1.
    Vendor statementOriginal read↩
  39. Wayback Machine capture index: nextjs.org/blog/cve-2025-29927, 2025-03-21 to 2025-04-10Internet Archive · 2025-04-04web.archive.org/cdx/search/cdx?url=nextjs.org/blog/cve-2025-29927&fro…Supports: the capture of 2025-04-02 has status 200 and captures from 2025-04-03 have status 308. We also opened the 2025-04-03 capture; its Location header points to the Vercel post-mortem. It does not give the exact time of the redirect, only that it falls between those two captures.
    Registry recordOriginal read↩
  40. Routing: MiddlewareNext.js documentation (Internet Archive capture, 2025-02-20) · 2025-02-20web.archive.org/web/20250220022546id_/https://nextjs.org/docs/app/bui…Supports: the official documentation, one week before the report, listed Authentication and Authorization as the first common use of Middleware.
    DocumentationOriginal read↩
  41. Commit history: cves/2025/29xxx/CVE-2025-29927.jsonCVEProject/cvelistV5 (GitHub) · 2025-04-08github.com/CVEProject/cvelistV5/commits/main/cves/2025/29xxx/CVE-2025…Supports: this file has eight versions up to and including the dateline. In CISA's SSVC assessment, Exploitation was none on 2025-03-21, changed to poc in the version of 2025-03-26 (assessment timestamp 2025-03-25), and became none again at 2025-04-08T15:16Z, about 77 minutes after the CNA rewrote the description (13:59Z). The record gives no reason for the changes. We took the version list from the GitHub commits API and read the raw JSON of each version.
    Registry recordOriginal read↩
  42. x-middleware-subrequest issue with Edge Runtime (#77466)vercel/next.js (GitHub issue) · 2025-03-24github.com/vercel/next.js/issues/77466A public report by one user, opened at 2025-03-24T15:37Z. Supports: the reporter says that fetch calls from an Edge-runtime route on 15.2.3 carried x-middleware-subrequest and the Next.js Middleware user agent, that calls to a third-party API behind Cloudflare failed for that reason, and that the same calls from the Node.js runtime worked. It is a single report, it does not concern an authentication service, and it came after Cloudflare made the rule opt-in. We did not reproduce it and did not open the reproduction repository or demo site linked in the report. The issue was closed on 2026-08-13; the closing comment is later than the dateline and the article does not use it. We read the issue body as returned by the GitHub API.
    First-hand reportOriginal read↩
  43. CWE-807: Reliance on Untrusted Inputs in a Security DecisionMITRE CWEcwe.mitre.org/data/definitions/807.htmlSupports the description sentence quoted verbatim in the article. Mapping CVE-2025-29927 to CWE-807 is our judgement; the CVE record says CWE-285. The quoted sentence is identical in the Internet Archive capture of 2025-02-11.
    StandardOriginal read↩
  44. Express behind proxiesExpress documentation (Internet Archive capture, 2025-03-01) · 2025-03-01web.archive.org/web/20250301062105id_/https://expressjs.com/en/guide/…Supports: with trust proxy set to true, the last trusted reverse proxy must remove or overwrite X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto.
    DocumentationOriginal read↩
  45. Settings: SECURE_PROXY_SSL_HEADER (Django 5.1)Django documentationdocs.djangoproject.com/en/5.1/ref/settingsSupports: the setting is safe only if the proxy strips X-Forwarded-Proto from all incoming requests and sets it itself only for requests that arrived over HTTPS.
    DocumentationOriginal read↩
  46. CVE-2018-14773: Remove support for legacy and risky HTTP headersFabien Potencier · Symfony Blog · 2018-08-01symfony.com/blog/cve-2018-14773-remove-support-for-legacy-and-risky-h…Supports: X-Original-URL and X-Rewrite-URL let a request override the path, and the fix was to remove support. The advisory thanks James Kettle for reporting the issue to the Drupal security team, which reported it to Symfony.
    AdvisoryOriginal read↩× 2
  47. HTTP header sanitizing (Envoy 1.33.0)Envoy documentationenvoyproxy.io/docs/envoy/v1.33.0/configuration/http/http_conn_man/hea…Supports: Envoy sanitizes a set of headers (most of them x-envoy-*) depending on whether the request is internal or external; that decision depends on x-forwarded-for and internal_address_config. The page does not say who writes each header; the writer column in our table is our reading.
    DocumentationOriginal read↩
  48. Authenticate users using an Application Load BalancerAWS documentation (Internet Archive capture, 2025-03-04) · 2025-03-04web.archive.org/web/20250304154307id_/https://docs.aws.amazon.com/ela…Supports: the documentation requires verifying the signature of x-amzn-oidc-data and its signer field before any authorization, and recommends restricting targets to traffic from the load balancer.
    DocumentationOriginal read↩
  49. RFC 9110: HTTP SemanticsR. Fielding, M. Nottingham, J. Reschke · IETF · 2022-06rfc-editor.org/rfc/rfc9110.txtWe cite only Section 7.6.1: intermediaries must remove the fields named in Connection. We did not read the whole document.
    StandardOriginal read↩
  50. Abusing HTTP hop-by-hop request headersNathan Davison · nathandavison.com · 2019-10-31nathandavison.com/blog/abusing-http-hop-by-hop-request-headersSupports: a client can name a header in Connection so that a proxy removes it; some systems forward the list to the next hop; the X-Forwarded-For example. The post cites RFC 2612, which should read RFC 2616.
    Research reportOriginal read↩
  51. Module ngx_http_core_module: internalnginx documentationnginx.org/en/docs/http/ngx_http_core_module.htmlSupports: a location marked internal accepts only internal requests and returns 404 to external ones. We read today's version of the page and did not compare it with an April 2025 capture.
    DocumentationOriginal read↩

Cite this piece

Shellbits Research. “A request must not be able to say that middleware already ran: CVE-2025-29927 and in-band control headers.” Field Notes, SBR-2025-01. 2025-04-08. https://shellbits.com/research/in-band-control-headers/

Version and notesv1.0

First published . Corrections: research@shellbits.com; we log every correction here.

Related pieces