Repository navigation
Open
Conversation
…s not all ones, are decoding errors (#643) RFC 7541 4.2 allows a dynamic table size update only at the start of a header block, and 5.2 makes Huffman padding the most significant bits of EOS, which are all ones. The HPACK decoder applied a size update anywhere in a block, and both Huffman decoders (ioxide.http2's, and ioxide.http3's copy for QPACK, RFC 9204 4.1.2) checked only that the padding was shorter than a byte. Now a size update after a field throws HpackException, which Http2Connection already turns into GOAWAY COMPRESSION_ERROR, and a string whose trailing bits are not all ones decodes to -1 in both decoders. Http2HpackDecodeTests: a size update after :method, a Huffman literal padded with zeros, and the http3 decoder on the same octet fail without the change; their controls (a size update that opens the block, padding of ones) pass either way. h2spec hpack/4.2/1 and hpack/5.2/2.
…ter a field (#643) From review: the size-update rule had no test for a block split across HEADERS and CONTINUATION, where the update comes after :method in the HEADERS frame, nor a control for more than one update ahead of the first field (RFC 7541 4.2).
…a one (#643) From review: the size-update refusals only had an indexed field before the update, and the only bad padding tested was all zeros, so a check of the last padding bit alone would have passed.
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.
Fixes #643.
RFC 7541 allows a dynamic table size update only at the start of a header block (4.2), and requires Huffman padding to be fewer than 8 bits taken from EOS, which are all ones (5.2). The HPACK decoder applied a size update wherever it appeared, and both Huffman decoders checked only the padding's length. h2spec 2.6.0 failed hpack/4.2/1 and hpack/5.2/2 on it.
The change.
HpackDecoder.Decodenotes when it has decoded a field. A size update after one throwsHpackException, whichHttp2Connectionalready turns into GOAWAY COMPRESSION_ERROR. Several updates before the first field are still allowed, as 4.2 permits.Huffman.Decodetracks whether every bit since the last symbol was a 1, and returns -1 when the string ends on any other padding. The same edit is made to ioxide.http3's copy, which QPACK uses (RFC 9204 4.1.2), so the managed HTTP/3 stack refuses the same strings. A full EOS was already refused: the tree leaves it out, so it falls off.What a caller notices. A peer that sends either is disconnected with COMPRESSION_ERROR where it used to be served. No public API changes. One flag per decoded block and one per Huffman bit, with no allocation.
Tests.
Http2HpackDecodeTests(Unit, new), overStrictClient::method, after a literal field, and in a CONTINUATION after:methodin its HEADERS each get GOAWAY COMPRESSION_ERROR and no handler runs; controls: one update, and two, opening the block are taken and the request served;apadded with zeros (0x18), or with 101 (0x1d), gets GOAWAY COMPRESSION_ERROR; control: padded with ones (0x1f) it decodes toa;Seen failing without the change (src/ at origin/main, tests in place): the three refusal tests fail (
the server wrote [], andexpected [-1], got [1]for http3); the controls pass.Suites. Unit 315/0/0.
Review. Three review agents (one on Fable) found no correctness bugs; the test gaps they found are closed by the two later commits.