Skip to content

fix: harden HPACK decoding and table sizing - #582

Open
azkrishpy wants to merge 2 commits into
mainfrom
todo/hpack
Open

azkrishpy wants to merge 2 commits into
mainfrom
todo/hpack

Conversation

@azkrishpy

@azkrishpy azkrishpy commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available: N/A

Description of changes:

Two HPACK conformance problems, both from TODOs left in the code.

The encoder took the peer's SETTINGS_HEADER_TABLE_SIZE at face value and passed it straight through as the requested table size. Anything above the 16MB this implementation supports is rejected outright, so a peer advertising a larger table made every resize fail, and with it every header block we tried to send. The value is now clamped to the supported ceiling, which RFC-7541 4.2 allows since the peer's number is a limit we may use, not one we must.

The decoder did not check the padding bits at the end of a Huffman-coded string. RFC-7541 5.2 requires padding to be the most significant bits of the EOS symbol and shorter than 8 bits, and says anything else MUST be treated as a decoding error. Both conditions are now enforced.

Worth knowing on review: the padding check rejects strings that previously decoded, and any HPACK failure becomes a connection error, so a peer that pads incorrectly now loses the whole connection rather than one stream. That is what the spec asks for, but the blast radius is the connection.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@azkrishpy
azkrishpy requested a review from a team as a code owner September 8, 2026 21:50
@github-actions github-actions Bot added the patch ABI backward-compatible (patch release) label Sep 8, 2026
@codecov-commenter

codecov-commenter commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.13%. Comparing base (2b563f8) to head (c969567).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #582      +/-   ##
==========================================
+ Coverage   79.84%   80.13%   +0.29%     
==========================================
  Files          28       28              
  Lines       12105    12117      +12     
==========================================
+ Hits         9665     9710      +45     
+ Misses       2440     2407      -33     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

/* The largest dynamic table this implementation will allocate, whatever the peer's
* SETTINGS_HEADER_TABLE_SIZE says. A macro so both hpack.c and hpack_encoder.c can use it
* without exporting a new symbol. */
#define AWS_HPACK_MAX_DYNAMIC_TABLE_SIZE (16 * 1024 * 1024)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a guess there can probably be lower. Please leave a comment if you have a better estimate on what the lower number should be.

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

Labels

patch ABI backward-compatible (patch release)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants