Skip to content

[v26.x backport] http2: avoid uaf while receiving and sending rst_stream - #65264

Merged
aduh95 merged 1 commit into
nodejs:v26.x-stagingfrom
mcollina:backport-64166-v26.x-staging
Aug 13, 2026
Merged

aduh95 merged 1 commit into
nodejs:v26.x-stagingfrom
mcollina:backport-64166-v26.x-staging

Conversation

@mcollina

@mcollina mcollina commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Backport of #64166 to v26.x-staging.

Original PR: http2: avoid uaf while receiving and sending rst_stream
Fixes: #64113

Backport note

The upstream fix relies on the http2 JS close/destroy refactor from PR #63249 (http2: error for incomplete reads on RST, auto-drain, deprecate aborted), which is semver-major and cannot be backported to a release branch. On v26.x (which lacks that refactor) the C++ backport alone stalls test-http2-many-writes-and-destroy.js (graceful close never completes — the server's GOAWAY is not flushed because the SendPendingData() guard returns busy during nghttp2_session_mem_recv()).

So this backport includes a second commit that drops the send guard. The primary UAF protection (the RST_STREAM / Destroy / Close deferrals) remains intact, and the full http2 suite passes.

@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 and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. v26.x Issues that can be reproduced on v26.x or PRs targeting the v26.x-staging branch. labels Aug 13, 2026
@mcollina
mcollina requested review from aduh95 and pimterry August 13, 2026 14:33
@aduh95 aduh95 changed the title http2: avoid uaf while receiving and sending rst_stream [v26.x backport] http2: avoid uaf while receiving and sending rst_stream Aug 13, 2026
@aduh95

aduh95 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

116 tests failed on the FIPS jobs, that's expected and already fixed on the staging branch. Closing and reopening to fix that

@aduh95 aduh95 closed this Aug 13, 2026
@aduh95 aduh95 reopened this Aug 13, 2026
@codecov

codecov Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.92593% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.24%. Comparing base (9b55403) to head (ca26282).
⚠️ Report is 149 commits behind head on v26.x-staging.

Files with missing lines Patch % Lines
src/node_http2.cc 73.46% 6 Missing and 7 partials ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           v26.x-staging   #65264      +/-   ##
=================================================
- Coverage          90.29%   90.24%   -0.05%     
=================================================
  Files                729      729              
  Lines             242763   242760       -3     
  Branches           46920    46044     -876     
=================================================
- Hits              219191   219073     -118     
- Misses             15024    15133     +109     
- Partials            8548     8554       +6     
Files with missing lines Coverage Δ
src/node_http2.h 91.86% <100.00%> (ø)
src/node_http2.cc 81.87% <73.46%> (+0.09%) ⬆️

... and 119 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.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 13, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 13, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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
Backport-PR-URL: nodejs#65264
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95
aduh95 force-pushed the backport-64166-v26.x-staging branch from 9b55403 to ca26282 Compare August 13, 2026 21:34
@aduh95

aduh95 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Landed in ca26282

@aduh95
aduh95 merged commit ca26282 into nodejs:v26.x-staging Aug 13, 2026
18 checks passed
@juanarbol

Copy link
Copy Markdown
Member

This also fixes in v22.x. Will land this into v22.x-staging

juanarbol pushed a commit that referenced this pull request Aug 21, 2026
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: #64113
Signed-off-by: Evgeniy Gorbanev <gorbanev.es@gmail.com>
PR-URL: #64166
Backport-PR-URL: #65264
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
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: #64113
Signed-off-by: Evgeniy Gorbanev <gorbanev.es@gmail.com>
PR-URL: #64166
Backport-PR-URL: #65264
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 27, 2026
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: #64113
Signed-off-by: Evgeniy Gorbanev <gorbanev.es@gmail.com>
PR-URL: #64166
Backport-PR-URL: #65264
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@mcollina
mcollina deleted the backport-64166-v26.x-staging branch August 31, 2026 08:57
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 and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. v26.x Issues that can be reproduced on v26.x or PRs targeting the v26.x-staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants