Automated Threat Modeling

Brief Summary: Node.js HTTPS Re-entrancy Memory Disclosure (CVE-2026-123864) with Regression Test PoC

A brief summary of CVE-2026-123864, a re-entrancy use-after-free in Node.js HTTPS that can leak memory from other connections. Includes the upstream regression test PoC, patch analysis, and detection guidance.

CVE Analysis

11 min read

Gaurav Sarraf
Gaurav Sarraf

2026-11-11

Brief Summary: Node.js HTTPS Re-entrancy Memory Disclosure (CVE-2026-123864) with Regression Test PoC

Introduction

A request body that comes back carrying bytes the client never sent is a bad day for any web runtime, and that is precisely what CVE-2026-123864 can produce in Node.js HTTPS servers. An unauthenticated client can, under the right application pattern, read memory belonging to other connections, including TLS private keys and other users' requests, by nudging the TLS layer into re-entering the HTTP parser.

This issue affects the TLS path only. Cleartext node:http is not affected, which narrows the attack surface to deployments where Node itself terminates TLS.

Technical information

The flaw sits at the boundary between two Node.js internals that were never designed to run inside each other: the TLS layer (TLSWrap) and the HTTP parser glue (node_http_parser.cc).

Before the fix, TLSWrap::DoWrite() in src/crypto/crypto_tls.cc always called ClearOut() for a zero length write. ClearOut() decrypts pending TLS records and passes the plaintext to the stream listener. The dangerous case appears when that empty write originates from JavaScript that is already running inside Cycle(), for example a res.end() reached from the parser's on_body callback. At that moment the listener receives the next TLS record while it is still processing the current one, which re-enters llhttp_execute() while the HTTP parser is still mid-body.

The nested parse can stop partway through a body chunk and leave llhttp's open span pointing into a temporary buffer. That buffer is freed when the nested call returns. The outer call then reports the same span against its own buffer, so the HTTP request body ends up containing freed or unrelated server heap memory. This is the use-after-free and out-of-bounds heap read classified under CWE-416, and the server then copies that memory into the response for the request body.

Trigger preconditions

Exploitation depends on both a vulnerable runtime and specific application behavior:

  • A request handler that calls res.flushHeaders() before the request body ends.
  • The same handler later calls res.end() with a non-empty chunk.
  • Any ordinary route that echoes or stores a request body, so the leaked bytes become observable.

The trigger does not require authentication, and it is reachable only over HTTPS. Plain node:http never reaches the TLS empty-write path.

Attack flow

Based on the advisory and the upstream reproducer, the sequence that drives the bug is:

  1. The client opens a keep-alive HTTPS connection and sends a HEAD request with Transfer-Encoding: chunked. The handler calls res.flushHeaders(), flushing the response headers early.
  2. The client holds back writes so that multiple TLS records arrive in a single TCP write, then sends the terminating 0\r\n\r\n of the first request immediately followed by the start of a pipelined chunked POST whose body begins with 1\r\nZ.
  3. A crafted continuation record is appended and the batch is flushed so the records reach the server together. The HEAD request's res.end('done') writes an empty string to the socket from the tick queue while the second request's body is still mid-parse and the next TLS record has already been received, triggering the nested llhttp_execute().
  4. On a vulnerable build, the second request's body is reported against a freed or stale buffer and ends up containing leaked server heap memory, which an echoing or storing route then exposes.

Proof of concept

A public, executable reproducer exists as the official Node.js regression test added in the fix commit 940cae5c33 (full SHA 940cae5c334696168729a51da5c79f19e970c7c8), authored by Matteo Collina and carrying the trailer CVE-ID: CVE-2026-123864. It is a legitimate regression test rather than a weaponized exploit, but it fully demonstrates the vulnerable behavior and the memory-disclosure condition. The vulnerability was reported by Chris Rohlf in collaboration with Claude and Anthropic Research, referencing HackerOne report #4150886.

The test test/parallel/test-https-empty-write-nested-parser-execute.js (128 lines) builds a real HTTPS server using the repository's agent1-key.pem and agent1-cert.pem fixtures. It uses a custom Batch Duplex stream that holds back writes so multiple TLS records arrive in a single TCP write. The core batching and sending logic, abbreviated from the committed test, is:

// Sends request 1, then the rest of it plus the start of request 2 and // `record` as two TLS records in one TCP write, then `tail`. function test(record, tail, check) { /* ... */ const server = https.createServer(options, (req, res) => { res.flushHeaders(); const chunks = []; bodies.push(chunks); req.on('data', (chunk) => chunks.push(chunk)); req.on('end', () => res.end('done')); }); // ... socket.write('HEAD / HTTP/1.1\r\nHost: x\r\nTransfer-Encoding: chunked\r\n\r\n'); // after first response data: batch.hold = true; socket.write('0\r\n\r\nPOST / HTTP/1.1\r\nHost: x\r\n' + 'Transfer-Encoding: chunked\r\n\r\n1\r\nZ', () => { socket.write(record, () => { batch.flush(); if (tail) socket.write(tail); }); }); } // Malformed request 2: body must not contain anything but the byte sent. await test('5\r\nHE', null, (bodies, response) => { assert.deepStrictEqual(bodies, ['', 'Z']); assert.match(response, /^HTTP\/1\.1 200 OK\r\n/); });

The assertions verify the fix. For a valid second request body the captured bodies must be exactly ['', 'ZHELLO'], and for a malformed chunk (a Z not followed by CRLF) the captured body must be exactly ['', 'Z']. Both check that the request body never contains a byte the client did not send. On vulnerable builds the body instead contains leaked server heap memory, or the process aborts.

To run it, execute node test/parallel/test-https-empty-write-nested-parser-execute.js from a Node.js checkout. On an unpatched build the assertions on body contents fail or the process aborts. No standalone weaponized or remote data-exfiltration exploit was found in public PoC aggregators. This regression test is the verified public PoC-quality artifact.

Patch information

Node.js fixed CVE-2026-123864 in its 11 November 2026 security release. The fix, titled "tls,http: prevent nested parser execution from empty writes", was written by Matteo Collina, reviewed by Paolo Insogna and Tim Perry, and developed privately (nodejs-private/node-private#1021, HackerOne report 4150886). It adds 163 lines, removes 5, changes two C++ files, and adds one regression test.

Release lineFixed versionCommit
26.x 'Lithium'26.13.1940cae5c33
24.x 'Krypton'24.22.325d487e3da
22.x 'Jod'22.23.5c841c6c7f1

The patch works in two layers because the bug arises from two parts of Node.js interacting.

Layer 1: TLS stops reading on empty writes while a cycle is running

In src/crypto/crypto_tls.cc, TLSWrap::DoWrite() no longer unconditionally calls ClearOut() on a zero length write. It now checks the existing cycle_depth_ counter:

if (length == 0) { Debug(this, "Empty write"); - ClearOut(); + // When the write comes from JS running inside Cycle(), for example from a + // stream listener in ClearOut(), the cycle reads and encrypts any pending + // data once that JS returns. Reading here would hand the next record to + // the listener while it is still processing the current one. + if (cycle_depth_ == 0) ClearOut();

No data is lost. If a cycle is already running, it reads the next record once the listener returns. The guard only prevents that read from happening inside another one, removing the path an attacker could use to re-enter llhttp_execute().

Layer 2: the HTTP parser restores its buffer and checks every span

Re-entrant Execute() calls remain supported but are made safe. First, Execute() and the OnStreamRead hook now save and restore the caller's buffer instead of resetting it to null:

+ const char* const outer_data = current_buffer_data_; + const size_t outer_len = current_buffer_len_; current_buffer_len_ = len; current_buffer_data_ = data; ... - current_buffer_len_ = 0; - current_buffer_data_ = nullptr; + current_buffer_len_ = outer_len; + current_buffer_data_ = outer_data;

Second, the Proxy::Raw trampoline between llhttp and Node's callbacks (on_body, on_url, on_header_value) now validates every span against the buffer currently being parsed with a new IsInCurrentBuffer(at, length) check. The subtraction is written so it cannot overflow:

return pos >= begin && pos - begin <= current_buffer_len_ && length <= current_buffer_len_ - (pos - begin);

If the span points outside the buffer, the callback is not called. The parser sets an error and stops:

llhttp_set_error_reason( p, "HPE_REENTRANT_EXECUTE:Parser re-entered in the middle of data"); return HPE_USER;

This is the part that stops the leak. A nested Execute() that stops partway through a body chunk leaves llhttp's open span pointing into a buffer that is freed when the call returns. The stale pointer now fails the bounds check, so the request ends with a parse error instead of a body full of heap memory. Callbacks that carry no data always pass.

The C++ logic is identical across all three release lines. Only hunk offsets differ, plus a small context difference on 26.x, where the new check sits right after an existing is_being_freed_ early return in the proxy. For applications, HTTPS code needs no changes. In-flight data is still processed, and plain node:http gets the parser hardening as defence in depth even though it was never exposed to the TLS empty-write trigger.

Detection methods

There is no public Sigma, YARA, Snort, Suricata, or Nuclei content for CVE-2026-123864, and the upstream sources reviewed do not list it in any of those rule sets. Detection therefore rests on finding exposed runtimes, checking whether the vulnerable code path is reachable, and watching for the bug's side effects in your own telemetry.

1. Find vulnerable runtimes

The CNA data in NVD lists these affected ranges: below 22.23.5, 23.0.0 up to 24.22.3, and 25.0.0 up to 26.13.1. End-of-life lines such as 20.x and 25.x get no fix, and the advisory says EOL versions are always affected. Run node --version on every host, container, and CI runner. The CLI version can mislead you, because a running process keeps its old runtime in memory until restart and process managers may run a different binary than your shell. Ask the kernel which binary each live process is using:

for p in /proc/[0-9]*; do exe=$(readlink "$p/exe" 2>/dev/null) || continue case "$exe" in */node) echo "$exe" ;; esac done | sort | uniq -c

Any line that does not point to a fixed version (for example v24.22.3/bin/node) is a live vulnerable process. Container images pinned to older Node tags need the same check.

2. Check whether the bug is reachable

The flaw is in HTTPS only, so the processes that matter are those where Node itself terminates TLS (https.createServer). If a reverse proxy terminates TLS and talks plain HTTP/1.1 to Node, clients cannot reach the TLS server bug. The following grep covers both the TLS server constructors and flushHeaders:

grep -rnE 'https\.createServer|http2\.create(Secure)?Server|tls\.createServer|respondWith(File|FD)|SNICallback|addContext|altsvc|flushHeaders' \ --include='*.js' --include='*.mjs' --include='*.cjs' --include='*.ts' src/

If one service has both https.createServer and flushHeaders hits, plus an endpoint that echoes or persists request bodies, treat it as highest priority.

3. Signs of exploitation on unpatched servers

When the bug fires, the nested llhttp_execute() call leaves a body span pointing into a freed buffer. Either the request body ends up containing server heap memory, or the process aborts. That gives two hunting angles:

  • Unexpected crashes or aborts of Node processes serving HTTPS, especially in clusters or bursts.
  • Request bodies that hold data the client never sent. If an app stores or echoes bodies, look for stored payloads containing binary noise, fragments of other requests, or key material, and for responses carrying that content back to a client.

The regression test also shows what a trigger looks like on the wire: a HEAD request with Transfer-Encoding: chunked, then a pipelined chunked POST on the same keep-alive connection, with several TLS records packed into one TCP write. Because TLS encrypts this traffic, a network IDS cannot see it. In application-level logs, HEAD requests carrying a chunked body followed immediately by pipelined requests on the same connection are an unusual pattern worth reviewing, though this is a heuristic and not a validated signature.

4. A log marker that appears after patching

The fix adds a parser check that fails data callbacks pointing outside the buffer being executed with the error reason HPE_REENTRANT_EXECUTE:Parser re-entered in the middle of data (returned as HPE_USER). On patched servers that log parser and client errors, this reason string is a strong candidate to watch for, because an attempt that hits the now-blocked path should produce it. How it appears depends on how your app handles HTTP parser errors, so confirm it in a lab first.

5. Test it in a lab with the upstream regression test

The fix ships with test/parallel/test-https-empty-write-nested-parser-execute.js, whose server handler reproduces the vulnerable application pattern:

const server = https.createServer(options, (req, res) => { res.flushHeaders(); const chunks = []; bodies.push(chunks); req.on('data', (chunk) => chunks.push(chunk)); req.on('error', () => {}); req.on('end', () => res.end('done')); });

The test asserts received bodies of exactly ['', 'ZHELLO'] for a valid second request and ['', 'Z'] for a malformed one. On a vulnerable build the second body can contain extra bytes or the process can abort. Run this only in an isolated test environment, never against production.

There are no public IoCs (IPs, hashes, or domains). VulDB's guidance is limited to monitoring server logs for unusual patterns in connection handling. Until vendor or community signatures appear, rely on runtime inventory, reachability triage, and application-level anomaly hunting.

Affected systems and versions

Per the CNA data in NVD, the affected ranges are:

  • Node.js below 22.23.5
  • Node.js 23.0.0 up to 24.22.3
  • Node.js 25.0.0 up to 26.13.1

This spans the active 22.x, 24.x, and 26.x release lines. End-of-life lines such as 20.x and 25.x receive no fix and are considered affected. Only deployments where Node.js terminates TLS directly (https.createServer) are exposed. Cleartext node:http is not affected. The fixed releases are Node.js 22.23.5, 24.22.3, and 26.13.1, released 2026-11-11.

References

Detect & fix
what others miss

Works with
  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps Services
  • Gerrit
  • CVS
  • Jira
  • Linear
  • Slack
  • Security Compass
Explore integrations
Security magnifying glass visualization