Skip to content

[v24.x backport] http2: avoid UAF while receiving and sending RST_STREAM - #65093

Open
mcollina wants to merge 2 commits into
nodejs:v24.x-stagingfrom
mcollina:backport-64166-to-v24.x
Open

[v24.x backport] http2: avoid UAF while receiving and sending RST_STREAM#65093
mcollina wants to merge 2 commits into
nodejs:v24.x-stagingfrom
mcollina:backport-64166-to-v24.x

Conversation

@mcollina

@mcollina mcollina commented Aug 7, 2026

Copy link
Copy Markdown
Member

Backports #64166 to v24.x-staging.

The direct cherry-pick relies on newer HTTP/2 stream lifecycle behavior that is not present in Node.js 24. The second commit preserves v24's reset ordering, avoids JavaScript callbacks after a session close is deferred out of nghttp2_session_mem_recv(), and lets destroyed streams finish without requesting trailers.

This addresses the memory corruption reported in #64841, where the corrupted state generally surfaced later in V8's concurrent Maglev compiler.

The release build passed all 278 parallel/test-http2-* tests. The Undici reproducer also completed 96/96 concurrent reduced runs and 16/16 concurrent original node:test runs without an abnormal exit.

Eusgor and others added 2 commits August 6, 2026 17:46
Mark the session as receiving around nghttp2_session_mem_recv() and
defer RST_STREAM handling while receive is in progress. This prevents
closing a stream while nghttp2 still processes it and avoids
heap-use-after-free in nghttp2_session_mem_recv2().

Fixes: nodejs#64113
Signed-off-by: Evgeniy Gorbanev <gorbanev.es@gmail.com>
PR-URL: nodejs#64166
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
(cherry picked from commit 46de80d)
Node.js v24 does not include the later stream lifecycle changes that the original fix relies on. Preserve its reset ordering, avoid JavaScript callbacks after a deferred session close, and let destroyed streams finish without requesting trailers.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
(cherry picked from commit 687a46df60e6211a6d0fbdcf3513125299440ae3)
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch. labels Aug 7, 2026
@mcollina
mcollina requested a review from pimterry August 7, 2026 00:39
@mcollina mcollina added the lts-watch-v24.x PRs that may need to be released in v24.x label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.95238% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.29%. Comparing base (b881658) to head (e9d433f).
⚠️ Report is 799 commits behind head on v24.x-staging.

Files with missing lines Patch % Lines
src/node_http2.cc 79.31% 6 Missing and 6 partials ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           v24.x-staging   #65093      +/-   ##
=================================================
+ Coverage          89.92%   90.29%   +0.36%     
=================================================
  Files                686      711      +25     
  Lines             208389   228175   +19786     
  Branches           40077    43141    +3064     
=================================================
+ Hits              187387   206023   +18636     
- Misses             13238    14091     +853     
- Partials            7764     8061     +297     
Files with missing lines Coverage Δ
src/node_http2.h 91.86% <100.00%> (+0.24%) ⬆️
src/node_http2.cc 82.02% <79.31%> (+0.16%) ⬆️

... and 300 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues or PRs related to the http2 subsystem. lts-watch-v24.x PRs that may need to be released in v24.x needs-ci PRs that need a full CI run. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants