Repository navigation
http2: HEADERS without END_STREAM after the block that opens a request resets the stream, so its fields no longer land in the body - #512
Open
MDA2AV wants to merge 1 commit into
Conversation
…t resets the stream, so its fields no longer land in the body They were decoded into the arena the body was being appended to, and the body's one range ran across them, losing as many bytes off its end. RFC 9113 8.1 makes such a request malformed. The block is still decoded, to keep HPACK in step. Fixes #502.
This branch has not been deployed
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.
What was wrong
AppendBodygrows one range and assumes the body is contiguous. The range then ran across those header bytes, and as many bytes fell off the body's end.x-a: abcin a HEADERS without END_STREAM, then 400 B more reached its handler with a body of 800 B,x-aabcat offset 400, and its last 6 bytes missing.RFC 9113 8.1 makes such a request malformed. Details are in #502.
The fix
A HEADERS without END_STREAM on a buffered stream that is already open resets that stream with PROTOCOL_ERROR. Its block is still decoded, to keep HPACK in step, through the path that already does that for a refused stream's block.
A streamed body already decodes such a block aside and drops it, so that path is unchanged.
Behaviour
API
None.
Tests
New in the Unit suite (
Http2TrailerTests.cs):h2 buffered request: HEADERS without END_STREAM after the opening block resets the stream, and its body never reaches a handlerh2 buffered request: HEADERS without END_STREAM split over CONTINUATION still keeps HPACK in stepAgainst main's
ioxide.http2(the tests only):Each was also run against a mutation of the code it guards and failed there: no reset, and the block not decoded (COMPRESSION_ERROR on the next request).
With the fix:
Bench
None. The new branch is on a HEADERS frame for a stream already open, which a normal request only reaches for its trailers.
Fixes #502.