[HIGH] Enforce negotiated HPACK limits - #202
Open
OskarEichler wants to merge 1 commit into
Open
Conversation
HoneyryderChuck
left a comment
Collaborator
There was a problem hiding this comment.
wow, it seems this settings has never been enforced, awesome find!
| @cc = EncodingContext.new(options) | ||
| @max_header_list_size = options.fetch( | ||
| :settings_max_header_list_size, | ||
| DEFAULT_MAX_HEADER_LIST_SIZE |
Collaborator
There was a problem hiding this comment.
do you need this default and to enforce it, considering that the value is always set in the connection defaults? which case would require this?
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.
Summary
Security impact
The decoder's table-size guard could be bypassed by starting a header block with a reduction and following it with an arbitrarily large increase. With a configured 128-byte limit, a focused block changed the effective limit to 1,000,000 bytes; 20 small follow-up blocks then retained 160,810 bytes of dynamic-table data.
Connection SETTINGS handling also applied a peer's header-table setting to the local decoder and an acknowledged local setting to the compressor. A peer could therefore enlarge the memory retained by the decoder, while the receiver's advertised limit did not constrain it.
SETTINGS_MAX_HEADER_LIST_SIZE was recorded but never enforced. A decoder configured for 64 bytes accepted and materialized 100 indexed fields.
This change separates the configured table maximum from the current HPACK table size, fixes the SETTINGS direction, and accounts for RFC 7541's 32-byte per-field overhead before appending decoded fields.
Verification
rbenv exec bundle exec rake: 448 examples, 0 failures; 41 RuboCop files, no offensesrbenv exec bundle exec rake buildgit diff --checkNo repository tests were changed.
Limitations
The repository's HPACK fixture task cannot currently run because its fixtures are absent (tracked separately in issue #200). Live transports, alternate Ruby engines, and sustained memory profiling were not exercised.
Breaking changes
Peers that exceed an advertised HPACK table or header-list bound now receive a connection error. The existing direct Decompressor#table_size= behavior is preserved; a separate internal limit writer tracks negotiated maxima.