Repository navigation
fix(net): read an IETF request message's body before allocating it - #9250
Merged
Merged
Conversation
A peer could declare a 64 KiB request stream message, withhold the body, and make us hold a 64 KiB buffer for every 3 bytes it sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 14 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. Reader.read(size) collects chunks as they arrive, so moving the new Uint8Array(2 + size) allocation after the body read means a peer that withholds the body holds only the bytes it actually sent.
Reviewed changes
#readFramedallocation order (js/net/src/ietf/request_stream.ts): reads the body before allocating the framed buffer. The framing and the error path (malformed(...)) are unchanged.
claude-sonnet-5-5 | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
RequestStream.#readFramed(js/net/src/ietf/request_stream.ts) allocated2 + sizebytes from a peer-declared u16 length before any body bytes arrived. A peer could send a 3-byte header declaring a 64 KiB message and withhold the body. Each stream then held a 64 KiB buffer, about 21,000x the bytes the peer sent (GHSA-pr4h-3fvv-mfgm, reported by Rikuxx0).Only
mainis affected: the code isn't onrelease, and the published@moq/net(0.4.8) predates it.Approach
Read the body first and allocate the framed copy after it arrives.
Reader.read(size)already collects the chunks as they come in, so a peer that withholds the body holds only what it actually sent, within QUIC flow control.I checked the other length-prefixed reads in
js/net(lite and IETF message decode, parameters, setup options, auth) and the streamed frame payloads. They all read before allocating or stream by segment. The Rustrequest_stream.rsdoesn't allocate from a declared size up front.Impact
Validation
0x02 0xff 0xff):bun test src/ietf/(659 pass) andjust checkpass.Uint8Array, and this is an old-bug regression rather than an edge case.Caused by
#readFramedsized the framed buffer from the declared length before reading the body (found by person; GHSA-pr4h-3fvv-mfgm)Alternatives
Follow-ups
None.
Models
Size: XS
Implementer: Claude Code, claude-opus-5-5, unknown effort
(Written by Claude Opus 5.5)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: e33e1fa
Base: origin/main at 037c6f1
Risk: medium,
This changes shipped request-stream buffering behavior and could affect JS clients handling delayed peer messages, while preserving the API and wire format; a revert fully undoes it.Classified: medium by Codex, gpt-6.1-sol, low effort, session
01a1fa83-90ca-7113-8e60-47d050516e97Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1fb9a-5c02-7673-8f50-1cacdd95ffa0, round 1Score: 10/10,
The minimal fix defers allocation until the body arrives without changing framing or error handling, with no regressions identified by source inspection; tests were not run.Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none