Skip to content

http2: fix out-of-bounds write in altsvc frame buffers - #65216

Open
Nashit-h wants to merge 1 commit into
nodejs:mainfrom
Nashit-h:http2-altsvc-buffer-overflow
Open

http2: fix out-of-bounds write in altsvc frame buffers#65216
Nashit-h wants to merge 1 commit into
nodejs:mainfrom
Nashit-h:http2-altsvc-buffer-overflow

Conversation

@Nashit-h

Copy link
Copy Markdown
Contributor

Http2Session::AltSvc sizes the origin and value byte buffers to the exact string length with MaybeStackBuffer, then fills them via WriteOneByteV2 with String::WriteFlags::kNullTerminate, which writes length + 1 bytes for the trailing NUL. Once origin or alt is longer than the 1024-byte inline stack storage the buffer is heap-allocated at exactly the string length, so that NUL lands one byte past the end, a heap-buffer-overflow that ASAN flags on session.altsvc('h2=":8000"; ma=' + '0'.repeat(2000), streamId). The terminator is never needed because the buffers reach nghttp2_submit_altsvc with explicit origin_len and value_len, so drop kNullTerminate and let each write match its allocation.

Signed-off-by: nashit hayyat <nashit@bugqore.com>
@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. labels Aug 11, 2026
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.31%. Comparing base (cb9bb66) to head (f66898b).
⚠️ Report is 291 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65216      +/-   ##
==========================================
- Coverage   90.31%   90.31%   -0.01%     
==========================================
  Files         760      760              
  Lines      248532   248529       -3     
  Branches    46908    46897      -11     
==========================================
- Hits       224467   224463       -4     
+ Misses      15505    15504       -1     
- Partials     8560     8562       +2     
Files with missing lines Coverage Δ
src/node_http2.cc 81.77% <100.00%> (-0.03%) ⬇️

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

@pimterry

Copy link
Copy Markdown
Member

@Nashit-h linters hadn't run before I approved, and unfortunately they're failing, can you take a look? You can run locally with make lint, and then push a new commit to fix them and they'll be squashed together when this lands.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants