Skip to content

h3: refuse a declared frame length before waiting for its payload - #65

Merged
mattrobenolt merged 1 commit into
mainfrom
fix/h3-declared-length
Nov 29, 2026
Merged

mattrobenolt merged 1 commit into
mainfrom
fix/h3-declared-length

Conversation

@mattrobenolt

Copy link
Copy Markdown
Member

Closes #64, h3spec's last HTTP/3 failure: MUST NOT buffer an over-long frame on a control stream.

h3.frame.Reader.next parses a header, records the declared length, and waits for payload. A GOAWAY declaring 2^30 bytes and sending none therefore never reaches appendAssembly, which is the only place H3_EXCESSIVE_LOAD was raised, so the connection sat until its idle timeout while h3spec gave up at two seconds.

Session.processFrames now checks the declared length as soon as the header is read, for exactly the frames whose payload this session buffers: HEADERS on a request stream, and the known control frames. DATA is streamed frame by frame and has no assembled payload; an unknown frame type is ignored however long it declares, which is what #42 settled and what its test now keeps true.

The test feeds only the nine header bytes — \x07\xc0\x00\x00\x00\x40\x00\x00\x00 — and requires a connection error with excessive_load. Disabling the check makes it fail.

just ci passes, including the existing #42 test that an unknown frame of 16,385 bytes is still ignored.

`frame.Reader.next` consumes a header and then waits for payload, so a peer
that declares a 2^30-byte control frame and sends nothing leaves the session
waiting. `appendAssembly` never ran, so `H3_EXCESSIVE_LOAD` was never raised and
the connection sat until its idle timeout (#64, h3spec's
"MUST NOT buffer an over-long frame on a control stream").

`processFrames` now checks the declared length when the header is read, before
the payload, for exactly the frames whose payload this session buffers: HEADERS
on a request stream and the known control frames. DATA is streamed and an
unknown type is ignored however long it declares, which is what #42 settled.
@mattrobenolt
mattrobenolt force-pushed the fix/h3-declared-length branch from a50b289 to c5055e4 Compare November 29, 2026 14:00
@mattrobenolt
mattrobenolt merged commit 4754390 into main Nov 29, 2026
7 checks passed
@mattrobenolt
mattrobenolt deleted the fix/h3-declared-length branch November 29, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

h3: a known control frame with an over-long declared length waits for its payload

1 participant