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

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 or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Aug 11, 2026
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. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants