Skip to content

http2, http3: a size update after a field, and Huffman padding that is not all ones, are decoding errors (#643) - #645

Open
MDA2AV wants to merge 3 commits into
mainfrom
fix-643
Open

MDA2AV wants to merge 3 commits into
mainfrom
fix-643

Conversation

@MDA2AV

@MDA2AV MDA2AV commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

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.Decode notes when it has decoded a field. A size update after one throws HpackException, which Http2Connection already turns into GOAWAY COMPRESSION_ERROR. Several updates before the first field are still allowed, as 4.2 permits.
  • Huffman.Decode tracks 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), over StrictClient:

  • a size update after :method, after a literal field, and in a CONTINUATION after :method in 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;
  • a literal value Huffman-coded as a padded with zeros (0x18), or with 101 (0x1d), gets GOAWAY COMPRESSION_ERROR; control: padded with ones (0x1f) it decodes to a;
  • ioxide.http3's decoder: 0x1f decodes, 0x18 is refused.

Seen failing without the change (src/ at origin/main, tests in place): the three refusal tests fail (the server wrote [], and expected [-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.

…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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http2, http3: the HPACK decoder takes a table size update mid-block, and both Huffman decoders take padding that is not all ones

1 participant