Skip to content
Smuggling / CRLF Write-up Advanced

CVE-2026–29057 — HTTP Request Smuggling via Next.js Rewrites

A bug in the bundled http-proxy library made Next.js forward DELETE and OPTIONS requests with a Content-Length of zero while still streaming the original chunked body, so the headers and body disagreed. An attacker could hide a second request inside that body and have it reach an unintended backend route such as an internal API or admin endpoint.

medium.com

Published on medium.com

Nextjs

WhitGuidance, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

Next.js allows an application to proxy specific paths to an external backend through rewrites() in next.config.js. Internally this proxying is handled by a vendored copy of the http-proxy library. The vulnerability described here, CVE-2026-29057, is a logic bug in that library's deleteLength() function, which is reached when Next.js forwards DELETE and OPTIONS requests to the backend.

The affected product is Next.js in self-hosted deployments that use rewrites() to proxy to an external backend. The vulnerable version ranges are >= 9.5.0, < 15.5.13 and >= 16.0.0-beta.0, < 16.1.7; the patched versions are 15.5.13 and 16.1.7. The issue is rated CVSS 4.0 6.3 (Moderate) and classified as CWE-444, Inconsistent Interpretation of HTTP Requests (Request Smuggling).

From the original on medium.com

The consequence of the bug is that the headers of a forwarded request can disagree with the body that is actually sent. An attacker can therefore hide a second HTTP request inside the body of an apparently normal request and have it reach an unintended backend route, such as internal APIs or admin endpoints.

Setup

The write-up analyses the bundled source and refers to two public proof-of-concept repositories, learnerxuan/CVE-2026-29057-POC and Nayekah/Next.js-Proof-of-Concept. Instead it analyses the bundled source and refers to two public proof-of-concept repositories, learnerxuan/CVE-2026-29057-POC and Nayekah/Next.js-Proof-of-Concept. Those PoCs run the vulnerable version (15.5.12) and the patched version (15.5.13) side by side in Docker Compose with identical topology, and send the same raw chunked payload directly over a socket to each.

No authentication or user interaction is required for the attack itself; the only precondition is network access to the affected deployment. The attacker does, however, need to know a configured rewrite path, and real impact depends on a downstream component (a proxy or backend) that parses requests differently from Next.js.

Finding it

The starting point is the mismatch between the body length a header claims and the number of bytes actually sent. Next.js correctly understands Transfer-Encoding: chunked and decodes the body, but before forwarding the request it passes it through deleteLength(). That function was written on the assumption that DELETE and OPTIONS requests have no body, and it tried to mark that explicitly with Content-Length: 0. The flaw is that it treated the absence of a Content-Length header as proof that there was no body, when a chunked request is supposed to have no Content-Length header in the first place.

Exploitation

Step 1: Send a chunked DELETE with a hidden request

The attacker sends a DELETE /rewrites/poc request with Transfer-Encoding: chunked, hiding an entire second request, GET /secret HTTP/1.1..., as plain text inside the chunked body.

From the original on medium.com

Step 2: Next.js decodes and passes the request through deleteLength()

Next.js correctly understands Transfer-Encoding and decodes the body, then passes the request through the internal deleteLength() function before forwarding it to the backend.

Step 3: The headers are rewritten but the body is still streamed

Because of the bug, deleteLength() attaches Content-Length: 0 and deletes the Transfer-Encoding header, but the body bytes are still streamed through via pipe().

Step 4: An intermediate hop parses the leftover bytes as a new request

An intermediate proxy or load balancer sees Content-Length: 0 and assumes the request ends there, parsing the remaining bytes as a brand-new, independent request.

Step 5: The backend receives two requests

The backend ends up receiving two requests: DELETE /rewrites/poc and GET /secret.

Byte-level comparison

Comparing the actual bytes sent on the wire for the same input makes the problem unmistakable.

From the original on medium.com

The vulnerable version writes content-length: 0 in the header, then appends the raw text GET /secret ... right after it. From the next hop's perspective this can only look like one zero-length request followed by a separate request that happened to arrive right after.

The patched version keeps Transfer-Encoding: chunked intact. Chunked encoding marks its own body boundary using chunk-size prefixes (such as 2E in hex) and a terminating 0 chunk, so the string GET /secret ... is correctly treated as body data and never gets split into a separate request.

What the PoC shows

The public PoCs fire the same raw chunked payload at both versions. Against the vulnerable version the output is:

Text
[after] {"backendRequests":["DELETE /rewrites/poc","GET /secret"],"flag":"FLAG{...}"}PoC result: vulnerable behavior reproduced.

Against the patched version the output is:

Text
[after] {"backendRequests":["DELETE /rewrites/poc"],"flag":null}PoC result: smuggled request was not observed.

Same topology, same payload, only the Next.js version differs, yet the number of requests the backend receives changes.

Root cause

The real root cause sits in one function inside [redacted], which Next.js bundles: lib/http-proxy/passes/web-incoming.js.

Before the patch:

JavaScript
deleteLength: function deleteLength(req, res, options) {  if ((req.method === 'DELETE' || req.method === 'OPTIONS')      && !req.headers['content-length']) {    req.headers['content-length'] = '0';    delete req.headers['transfer-encoding'];  }},

After the patch:

JavaScript
deleteLength: function deleteLength(req, res, options) {  if ((req.method === 'DELETE' || req.method === 'OPTIONS')      && typeof req.headers['content-length'] === 'undefined'      && typeof req.headers['transfer-encoding'] === 'undefined') {    req.headers['content-length'] = '0';  }},

The function exists because DELETE and OPTIONS requests typically have no body, so it tries to mark that explicitly with Content-Length: 0. Before the patch, the only condition checked was !req.headers['content-length'], meaning "if there is no Content-Length header". But a Transfer-Encoding: chunked request is supposed to have no Content-Length header; that is normal. The condition therefore evaluates to true for chunked requests too, forcibly setting Content-Length: 0 and then deleting the Transfer-Encoding header. The problem is that only the header gets removed: the chunked body data has already entered the stream and is forwarded regardless. The result is a contradiction, with the header saying "no body" while a body is sent anyway.

After the patch, the condition requires that both Content-Length and Transfer-Encoding be absent (typeof ... === 'undefined' && typeof ... === 'undefined'). If Transfer-Encoding: chunked is present, the condition is false, so the function does nothing and leaves the headers untouched. Node.js then re-encodes and sends the request with chunked framing intact, keeping the body boundary unambiguous.

In one line: "Content-Length is absent" and "there is no body" are not the same thing, and the pre-patch code conflated them. Any request using Transfer-Encoding to express its body length will naturally have no Content-Length header.

Connection header handling

The fix did not stop at web-incoming.js. The same commit also hardens setupOutgoing() in lib/http-proxy/common.js, closing off a connection-reuse bypass:

JavaScript
var hasTransferEncodingHeader = Object.keys(outgoing.headers).some(function (header) {  return header.toLowerCase() === 'transfer-encoding'    && typeof outgoing.headers[header] !== 'undefined';});if (hasTransferEncodingHeader    || (typeof outgoing.headers.connection === 'string'        && hopByHopTransferEncodingHeader.test(outgoing.headers.connection))   ) { outgoing.headers.connection = 'close'; }

Even with deleteLength() fixed, if the forwarded connection stays alive via keep-alive, a different flavour of desync could still occur on that same connection. The patch therefore forces connection: close whenever the request carries a Transfer-Encoding header, or whenever the Connection header itself names transfer-encoding as a hop-by-hop token.

The old code only kept the connection alive as an exception when the Connection header contained an upgrade token, to support WebSockets, and that exception appears to have been exploitable via something like Connection: Transfer-Encoding, upgrade. The patch reorders the checks so the Transfer-Encoding check runs first, forcing the connection closed regardless of any upgrade token.

From the original on medium.com

The official patch ships with 5 regression tests covering these cases, each verifying that GET /secret never reaches the backend.

Impact

An attacker who can reach a self-hosted Next.js deployment that proxies rewrite paths to an external backend can smuggle a second request past an intermediate proxy or load balancer and have it land on an unintended backend route, such as internal APIs or admin endpoints. No authentication or user interaction is needed, only network access (CVSS PR:N, UI:N). The attacker must know a configured rewrite path, and real impact depends on a downstream component that parses requests differently (AT:P, Attack Requirements: Present).

Hosting environments where rewrites are handled at the CDN or edge layer, such as Vercel, are not affected. The issue targets self-hosted deployments where rewrites() proxies from the Node.js runtime itself to an external backend.

Fix

The patch changes deleteLength() so that it only sets Content-Length: 0 when neither Content-Length nor Transfer-Encoding is present, leaving chunked requests untouched so that Node.js re-encodes them with chunked framing intact. The same commit hardens setupOutgoing() in common.js to force connection: close whenever a Transfer-Encoding header is present or the Connection header names transfer-encoding as a hop-by-hop token, and reorders the checks so the Transfer-Encoding check runs before the upgrade exception. The fix ships with 5 regression tests, each verifying that GET /secret never reaches the backend.

If upgrading is not immediately possible, the interim mitigation is to block chunked-encoded DELETE/OPTIONS requests to rewrite-proxied paths at the edge or proxy layer, or to enforce independent authentication and authorisation on the backend routes themselves.

Variants to test

  1. Other methods with chunked bodies through rewrites. Send chunked DELETE and OPTIONS requests to a known rewrite path and inspect what the backend logs. A positive result is the backend recording two requests, the second being the smuggled one.
  2. Connection header with an upgrade token. Try a request whose Connection header names transfer-encoding alongside upgrade, for example Connection: Transfer-Encoding, upgrade, and observe whether the connection is kept alive and a desync occurs. A positive result is the smuggled request being processed on a reused connection.
  3. Different downstream parsers. Place a proxy or load balancer in front of the Next.js deployment and vary how it handles Content-Length: 0 followed by extra bytes. A positive result is the front end treating the trailing bytes as a new request while Next.js treats them as body.
  4. Version comparison. Run the same raw payload against 15.5.12 and 15.5.13 (or the corresponding 16.x versions) with identical topology. A positive result is the vulnerable version producing two backend requests and the patched version producing one.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 19 min read.

What happened, in plain words

Imagine a post office that forwards parcels to another building. Each parcel has a label on the outside saying how heavy it is, and the receiving building trusts that label. Now imagine someone hands over a parcel labelled "empty, 0 grams" but the box actually contains a second, smaller parcel inside it. The receiving building opens the box, sees it is supposed to be empty, and treats whatever is inside as a brand-new parcel that arrived separately. That is the shape of the bug described here.

In this case the "post office" is a web framework called Next.js, the "label" is an HTTP header called Content-Length, and the "second parcel" is a hidden HTTP request. The bug lets an attacker slip a second request past a security checkpoint so that it reaches a part of the backend the attacker was never meant to reach, such as internal APIs or admin endpoints.

The bug has an official identifier, CVE-2026-29057. A CVE is a public catalogue number for a known security flaw, so that people can talk about the same bug unambiguously. The flaw is classified as CWE-444, which is the catalogue's name for "Inconsistent Interpretation of HTTP Requests", also known as request smuggling. The severity score is CVSS 4.0 6.3, rated Moderate. CVSS is a scoring system that tries to put a number on how bad a bug is; 6.3 out of 10 sits in the middle.

From the original on medium.com

Before going further, a few words on the pieces involved.

  • HTTP is the language browsers and servers speak. A request looks like a short block of text: a first line with a method and a path (for example GET /secret), then a set of headers (name and value pairs), then optionally a body (the actual data being sent).
  • A method is the verb of the request. GET means "give me something". DELETE means "remove something". OPTIONS asks what is allowed on a resource.
  • A header is a line of metadata, such as Content-Length: 0, which says "the body of this request is zero bytes long".
  • An API is a programmatic doorway into a service, meant for other software rather than for people clicking around in a browser. Internal APIs are ones not meant to be reachable from the outside.
  • A proxy is a middleman server that sits between the client and the real backend and passes requests along. A load balancer is a similar middleman that spreads traffic across several servers.
  • A backend is the server that actually does the work, behind the proxy.

Next.js is a popular framework for building websites and web applications with JavaScript. One of its features is rewrites(), configured in a file called next.config.js. A rewrite is a rule that says "when a request comes in for this path, quietly forward it to that other address instead". It is like a receptionist who redirects certain visitors to a different office without telling them. Under the hood, Next.js uses a bundled copy of a library called http-proxy to do the forwarding. "Vendored" or "bundled" means Next.js ships its own copy of that library inside itself, rather than asking you to install it separately.

The affected product is Next.js in self-hosted deployments that use rewrites() to proxy to an external backend. Self-hosted means you run the Next.js server yourself on your own machine or cloud server, as opposed to letting a hosting platform run it for you. The vulnerable version ranges are >= 9.5.0, < 15.5.13 and >= 16.0.0-beta.0, < 16.1.7; the patched versions are 15.5.13 and 16.1.7. In plain terms: every version from 9.5.0 up to but not including 15.5.13 is vulnerable, and every 16.x version from the first beta up to but not including 16.1.7 is vulnerable. If you are on 15.5.13 or 16.1.7, you have the fix.

The consequence of the bug is that the headers of a forwarded request can disagree with the body that is actually sent. An attacker can therefore hide a second HTTP request inside the body of an apparently normal request and have it reach an unintended backend route, such as internal APIs or admin endpoints.

Setup

The write-up analyses the bundled source and refers to two public proof-of-concept repositories, learnerxuan/CVE-2026-29057-POC and Nayekah/Next.js-Proof-of-Concept. Instead it analyses the bundled source and refers to two public proof-of-concept repositories, learnerxuan/CVE-2026-29057-POC and Nayekah/Next.js-Proof-of-Concept. A proof of concept (PoC) is a small, deliberately built demonstration that shows a bug is real, usually with the least amount of code needed to trigger it.

Those PoCs run the vulnerable version (15.5.12) and the patched version (15.5.13) side by side in Docker Compose, with identical topology, and send the same raw chunked payload directly over a socket to each. Docker Compose is a tool for describing and starting several containers (small isolated computers) at once from one configuration file. Topology here just means the arrangement of the pieces: the same proxy, the same backend, the same network layout. A socket is the low-level connection over which the raw bytes of an HTTP request travel; sending "directly over a socket" means skipping the browser and writing the exact bytes by hand, so nothing gets normalised or cleaned up along the way.

No authentication or user interaction is required for the attack itself; the only precondition is network access to the affected deployment. Authentication means proving who you are, usually with a username and password, or with a cookie or token, which is a small piece of data your browser stores and sends back with each request to prove it is still you. "No authentication required" means the attacker does not need an account at all. "No user interaction" means no victim has to click anything; the attacker acts alone.

The attacker does, however, need to know a configured rewrite path, and real impact depends on a downstream component (a proxy or backend) that parses requests differently from Next.js. Parsing means reading the raw bytes and deciding where one request ends and the next begins. The whole bug lives in that decision.

Finding it

The starting point is the mismatch between the body length a header claims and the number of bytes actually sent. Next.js correctly understands Transfer-Encoding: chunked and decodes the body, but before forwarding the request it passes it through a function called deleteLength(). That function was written on the assumption that DELETE and OPTIONS requests have no body, and it tried to mark that explicitly with Content-Length: 0.

Transfer-Encoding: chunked deserves a short explanation, because everything hinges on it. Normally, a request with a body says how long the body is with Content-Length: 42, and the receiver counts 42 bytes. Chunked encoding is an alternative: instead of one length up front, the body is split into pieces, and each piece is preceded by its own length written in hexadecimal (base 16, where 2E means 46). The body ends with a chunk of size 0. It is like sending a book as numbered envelopes, each labelled with how many pages it contains, and a final empty envelope meaning "that is all". The advantage is that the sender does not need to know the total length in advance.

The flaw is that deleteLength() treated the absence of a Content-Length header as proof that there was no body, when a chunked request is supposed to have no Content-Length header in the first place. Those two situations look identical if you only check for the missing header, but they mean completely different things.

Exploitation

Step 1: Send a chunked DELETE with a hidden request

The attacker sends a DELETE /rewrites/poc request with Transfer-Encoding: chunked, hiding an entire second request, GET /secret HTTP/1.1..., as plain text inside the chunked body.

From the original on medium.com

Why this step: the attacker picks a path that is known to be forwarded by a rewrite rule (/rewrites/poc), and uses a method (DELETE) that the buggy function treats specially. The hidden GET /secret is written as ordinary text inside the body, so on the surface the request looks like one legitimate request with some data in it.

Step 2: Next.js decodes and passes the request through deleteLength()

Next.js correctly understands Transfer-Encoding and decodes the body, then passes the request through the internal deleteLength() function before forwarding it to the backend.

Why this step matters: at this point Next.js has done nothing wrong. It read the chunked body correctly. The damage happens in the next step, in the code that prepares the request for forwarding.

Step 3: The headers are rewritten but the body is still streamed

Because of the bug, deleteLength() attaches Content-Length: 0 and deletes the Transfer-Encoding header, but the body bytes are still streamed through via pipe().

pipe() is a programming pattern where data is passed from one place to another as a continuous stream, like water through a pipe, without first collecting it all in memory. The key point is that removing a header does not remove the bytes that are already flowing. The label has been changed, but the parcel still contains what it contained.

Step 4: An intermediate hop parses the leftover bytes as a new request

An intermediate proxy or load balancer sees Content-Length: 0 and assumes the request ends there, parsing the remaining bytes as a brand-new, independent request.

Why this happens: the proxy trusts the label. It reads Content-Length: 0, concludes the request is finished, and then finds more bytes arriving on the same connection. The only sensible interpretation left is that those bytes are the start of the next request.

Step 5: The backend receives two requests

The backend ends up receiving two requests: DELETE /rewrites/poc and GET /secret.

Byte-level comparison

Comparing the actual bytes sent on the wire for the same input makes the problem unmistakable.

From the original on medium.com

The vulnerable version writes content-length: 0 in the header, then appends the raw text GET /secret ... right after it. From the next hop's perspective this can only look like one zero-length request followed by a separate request that happened to arrive right after.

The patched version keeps Transfer-Encoding: chunked intact. Chunked encoding marks its own body boundary using chunk-size prefixes (such as 2E in hex) and a terminating 0 chunk, so the string GET /secret ... is correctly treated as body data and never gets split into a separate request.

The difference is entirely in how the boundary is communicated. With Content-Length: 0, the boundary is "immediately after the headers". With chunked encoding, the boundary is "after the zero-sized chunk". Same bytes, two different readings.

What the PoC shows

The public PoCs fire the same raw chunked payload at both versions. Against the vulnerable version the output is:

Text
[after] {"backendRequests":["DELETE /rewrites/poc","GET /secret"],"flag":"FLAG{...}"}PoC result: vulnerable behavior reproduced.

Line by line: [after] marks that this is the state after the payload was sent. The JSON object reports what the backend recorded. backendRequests is a list of the requests the backend actually saw: first DELETE /rewrites/poc, then GET /secret. The flag field holds the value FLAG{...}. The final sentence states the conclusion: the vulnerable behaviour was reproduced.

Against the patched version the output is:

Text
[after] {"backendRequests":["DELETE /rewrites/poc"],"flag":null}PoC result: smuggled request was not observed.

Here backendRequests contains only the one legitimate request. The flag is null. The conclusion is that the smuggled request was not observed.

Same topology, same payload, only the Next.js version differs, yet the number of requests the backend receives changes.

Root cause

The real root cause sits in one function inside [redacted], which Next.js bundles: lib/http-proxy/passes/web-incoming.js. The path is just the location of the file inside the library; web-incoming.js is the file that handles requests coming in from the web.

Before the patch:

JavaScript
deleteLength: function deleteLength(req, res, options) {  if ((req.method === 'DELETE' || req.method === 'OPTIONS')      && !req.headers['content-length']) {    req.headers['content-length'] = '0';    delete req.headers['transfer-encoding'];  }},

Line by line:

  1. deleteLength: function deleteLength(req, res, options) { defines a function named deleteLength that receives the incoming request (req), the response (res) and some options. The name suggests its purpose: deal with the length of a DELETE request.
  2. if ((req.method === 'DELETE' || req.method === 'OPTIONS') checks whether the request method is DELETE or OPTIONS. These are the two methods the function cares about.
  3. && !req.headers['content-length']) { adds a second condition: the request must have no Content-Length header. The ! means "not".
  4. req.headers['content-length'] = '0'; sets the header to 0, declaring an empty body.
  5. delete req.headers['transfer-encoding']; removes the Transfer-Encoding header entirely.
  6. The closing braces end the block and the function.

After the patch:

JavaScript
deleteLength: function deleteLength(req, res, options) {  if ((req.method === 'DELETE' || req.method === 'OPTIONS')      && typeof req.headers['content-length'] === 'undefined'      && typeof req.headers['transfer-encoding'] === 'undefined') {    req.headers['content-length'] = '0';  }},

Line by line:

  1. The function signature is unchanged.
  2. The method check is unchanged: still DELETE or OPTIONS.
  3. && typeof req.headers['content-length'] === 'undefined' now checks that the Content-Length header is genuinely absent, not merely falsy. typeof ... === 'undefined' is a precise way of asking "does this exist at all?".
  4. && typeof req.headers['transfer-encoding'] === 'undefined' adds a second requirement: the Transfer-Encoding header must also be absent.
  5. req.headers['content-length'] = '0'; sets the header to 0, but only when both conditions hold.
  6. Notably, the line that deleted Transfer-Encoding is gone. The function no longer removes that header at all.

The function exists because DELETE and OPTIONS requests typically have no body, so it tries to mark that explicitly with Content-Length: 0. Before the patch, the only condition checked was !req.headers['content-length'], meaning "if there is no Content-Length header". But a Transfer-Encoding: chunked request is supposed to have no Content-Length header; that is normal. The condition therefore evaluates to true for chunked requests too, forcibly setting Content-Length: 0 and then deleting the Transfer-Encoding header. The problem is that only the header gets removed: the chunked body data has already entered the stream and is forwarded regardless. The result is a contradiction, with the header saying "no body" while a body is sent anyway.

After the patch, the condition requires that both Content-Length and Transfer-Encoding be absent (typeof ... === 'undefined' && typeof ... === 'undefined'). If Transfer-Encoding: chunked is present, the condition is false, so the function does nothing and leaves the headers untouched. Node.js then re-encodes and sends the request with chunked framing intact, keeping the body boundary unambiguous. Node.js is the JavaScript runtime that Next.js runs on; it is the program that actually writes the bytes onto the network.

In one line: "Content-Length is absent" and "there is no body" are not the same thing, and the pre-patch code conflated them. Any request using Transfer-Encoding to express its body length will naturally have no Content-Length header.

Connection header handling

The fix did not stop at web-incoming.js. The same commit also hardens setupOutgoing() in lib/http-proxy/common.js, closing off a connection-reuse bypass:

JavaScript
var hasTransferEncodingHeader = Object.keys(outgoing.headers).some(function (header) {  return header.toLowerCase() === 'transfer-encoding'    && typeof outgoing.headers[header] !== 'undefined';});if (hasTransferEncodingHeader    || (typeof outgoing.headers.connection === 'string'        && hopByHopTransferEncodingHeader.test(outgoing.headers.connection))   ) { outgoing.headers.connection = 'close'; }

Line by line:

  1. var hasTransferEncodingHeader = Object.keys(outgoing.headers).some(function (header) { starts a check over every header name on the outgoing request. Object.keys lists the names, and .some(...) asks whether at least one of them satisfies the test that follows.
  2. return header.toLowerCase() === 'transfer-encoding' compares the header name, lowercased, to transfer-encoding. Lowercasing matters because HTTP header names are case-insensitive, so Transfer-Encoding and transfer-encoding are the same header.
  3. && typeof outgoing.headers[header] !== 'undefined';}); requires that the header also has a value, not just a name.
  4. if (hasTransferEncodingHeader is the first condition: the request carries a Transfer-Encoding header.
  5. || (typeof outgoing.headers.connection === 'string' is the alternative: the Connection header exists and is a string.
  6. && hopByHopTransferEncodingHeader.test(outgoing.headers.connection)) and that string matches a pattern looking for transfer-encoding as a hop-by-hop token. A hop-by-hop header is one meant for a single connection between two machines, not for the final destination.
  7. ) { outgoing.headers.connection = 'close'; } if either condition holds, set Connection: close, which tells the other side to close the connection after this request instead of reusing it.

Why was this needed? Even with deleteLength() fixed, if the forwarded connection stays alive via keep-alive, a different flavour of desync could still occur on that same connection. Keep-alive means the connection is kept open after a request so the next request can reuse it, which saves time but means leftover bytes from one request can be read as part of the next. Desync is exactly that: two parties disagreeing about where one message ends and the next begins.

The old code only kept the connection alive as an exception when the Connection header contained an upgrade token (to support WebSockets), and that exception appears to have been exploitable via something like Connection: Transfer-Encoding, upgrade. WebSockets are a way for a browser and server to keep a two-way conversation open, which is why an upgrade token exists at all. The patch reorders the checks so the Transfer-Encoding check runs first, forcing the connection closed regardless of any upgrade token.

From the original on medium.com

The official patch ships with 5 regression tests covering these cases, each verifying that GET /secret never reaches the backend. A regression test is an automated check that a bug stays fixed: if someone later reintroduces the flaw, the test fails.

Impact

An attacker who can reach a self-hosted Next.js deployment that proxies rewrite paths to an external backend can smuggle a second request past an intermediate proxy or load balancer and have it land on an unintended backend route, such as internal APIs or admin endpoints. No authentication or user interaction is needed, only network access (CVSS PR:N, UI:N). Those two codes are shorthand from the scoring system: PR:N means no privileges are required, and UI:N means no user interaction is required. The attacker must know a configured rewrite path, and real impact depends on a downstream component that parses requests differently (AT:P, Attack Requirements: Present).

Hosting environments where rewrites are handled at the CDN or edge layer, such as Vercel, are not affected. A CDN (content delivery network) is a network of servers that sit close to users and handle traffic before it reaches your application; the edge is the outermost layer where that happens. The issue targets self-hosted deployments where rewrites() proxies from the Node.js runtime itself to an external backend.

Fix

The patch changes deleteLength() so that it only sets Content-Length: 0 when neither Content-Length nor Transfer-Encoding is present, leaving chunked requests untouched so that Node.js re-encodes them with chunked framing intact. The same commit hardens setupOutgoing() in common.js to force connection: close whenever a Transfer-Encoding header is present or the Connection header names transfer-encoding as a hop-by-hop token, and reorders the checks so the Transfer-Encoding check runs before the upgrade exception. The fix ships with 5 regression tests, each verifying that GET /secret never reaches the backend.

If upgrading is not immediately possible, the interim mitigation is to block chunked-encoded DELETE/OPTIONS requests to rewrite-proxied paths at the edge or proxy layer, or to enforce independent authentication and authorisation on the backend routes themselves. In other words: either refuse the suspicious shape of request before it reaches Next.js, or make the backend check permissions for itself rather than trusting that the proxy already did.

Variants to test

  1. Other methods with chunked bodies through rewrites. Send chunked DELETE and OPTIONS requests to a known rewrite path and inspect what the backend logs. A positive result is the backend recording two requests, the second being the smuggled one.
  2. Connection header with an upgrade token. Try a request whose Connection header names transfer-encoding alongside upgrade, for example Connection: Transfer-Encoding, upgrade, and observe whether the connection is kept alive and a desync occurs. A positive result is the smuggled request being processed on a reused connection.
  3. Different downstream parsers. Place a proxy or load balancer in front of the Next.js deployment and vary how it handles Content-Length: 0 followed by extra bytes. A positive result is the front end treating the trailing bytes as a new request while Next.js treats them as body.
  4. Version comparison. Run the same raw payload against 15.5.12 and 15.5.13 (or the corresponding 16.x versions) with identical topology. A positive result is the vulnerable version producing two backend requests and the patched version producing one.

Glossary

  • API: a programmatic doorway into a service, meant for software to talk to software rather than for people clicking in a browser.
  • Authentication: proving who you are, typically with a password, cookie or token.
  • Authorisation: deciding what an authenticated identity is allowed to do.
  • Backend: the server that actually performs the work, sitting behind a proxy or load balancer.
  • CDN: a network of servers that handle traffic close to users before it reaches the application.
  • Chunked encoding: a way of sending a body in pieces, each preceded by its length in hexadecimal and ended by a zero-sized chunk.
  • Content-Length: a header stating how many bytes long the body is.
  • Cookie: a small piece of data a browser stores and sends back with requests, often used to prove who you are.
  • CVE: a public catalogue number for a known security vulnerability.
  • CVSS: a scoring system that rates the severity of a vulnerability, here 6.3 out of 10, Moderate.
  • CWE-444: the catalogue entry for inconsistent interpretation of HTTP requests, also called request smuggling.
  • Desync: a state where two parties disagree about where one message ends and the next begins.
  • Docker Compose: a tool for starting several isolated containers from one configuration file.
  • Edge: the outermost layer of a hosting setup, where traffic is handled before reaching the application.
  • Header: a line of metadata in an HTTP request or response, such as Content-Length: 0.
  • Hop-by-hop header: a header meant for a single connection between two machines, not for the final destination.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • Keep-alive: keeping a connection open after a request so the next request can reuse it.
  • Load balancer: a middleman that spreads incoming traffic across several servers.
  • Method: the verb of an HTTP request, such as GET, DELETE or OPTIONS.
  • Next.js: a JavaScript framework for building web applications, which can forward requests to other servers via rewrites().
  • Node.js: the JavaScript runtime that Next.js runs on and that writes the bytes onto the network.
  • Parsing: reading raw bytes and deciding what they mean, including where one request ends and the next begins.
  • pipe(): a programming pattern that passes data along as a continuous stream rather than collecting it first.
  • Proof of concept (PoC): a small demonstration that proves a vulnerability is real.
  • Proxy: a middleman server that forwards requests to a backend.
  • Regression test: an automated check that a fixed bug stays fixed.
  • Request smuggling: hiding one request inside another so that a middleman and a backend disagree about how many requests were sent.
  • Rewrite: a rule that forwards requests for one path to a different address.
  • Self-hosted: running the server yourself rather than letting a hosting platform run it for you.
  • Socket: the low-level connection over which raw bytes travel.
  • Token: a piece of data used to prove identity or permission, similar in role to a cookie.
  • Topology: the arrangement of the pieces in a system, such as proxy, backend and network layout.
  • Transfer-Encoding: a header that says how the body is framed, for example chunked.
  • Vendored: bundled inside another project rather than installed separately.
  • WebSocket: a way for a browser and server to keep a two-way conversation open, which is why an upgrade token exists.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.