Mitigate HTTP/2 HPACK "bomb" amplification (decoded list-size + reassembly caps)#830
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Investigate HTTP/2 bomb vulnerability and assess HPACK implementation
Mitigate HTTP/2 HPACK "bomb" amplification (decoded list-size + reassembly caps)
Jun 3, 2026
ademar
approved these changes
Jun 3, 2026
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.
Suave's HTTP/2 stack had no upper bound on either the decoded HPACK header list or the cumulative HEADERS+CONTINUATION reassembly buffer, so a peer could expand a few bytes on the wire (repeated indexed-references into a populated dynamic table, or an unbounded CONTINUATION chain) into arbitrary server-side memory — the attack described in the HPACK bomb writeup.
Changes
Hpack.fs— bounded decoder. NewdecodeHeaderBounded : DynamicTable -> int option -> byte[] -> HeaderListand underlyingdecodeSimpleBoundedtrack RFC 7541 §4.1 size (name + value + 32) per header during decoding and raise the newHpackHeaderListTooLargeExceptionthe moment the running total exceeds the cap, so we don't finish materialising the giant list. LegacydecodeHeader/decodeSimpleremain as thinNonewrappers.Http2.fs— defaults + enforcement.defaultMaxHeaderListSize = 32768anddefaultMaxHeaderBlockReassemblyBytes = 32768constants.localSettingsinitialised withmaxHeaderBlockSize = Some defaultMaxHeaderListSize; both the h2c-upgrade and prior-knowledge server prefaces now emitSettings(false, localSettings)instead ofdefaultSetting, advertisingSETTINGS_MAX_HEADER_LIST_SIZEto peers.handleFramerejects an initial HEADERS fragment or a CONTINUATION that would push the reassembly buffer past the compressed cap.completeHeaderBlockcallsdecodeHeaderBoundedwithlocalSettings.maxHeaderBlockSizeand mapsHpackHeaderListTooLargeExceptionto a connection-level abort.GOAWAY(ENHANCE_YOUR_CALM); stream-level reset is unsafe because the HPACK dynamic table may already be partially mutated.Suave.Tests/Http2.fs— regression test. Plants a 200-byte value in the dynamic table via a literal-with-incremental-indexing frame, then replays it with a single0xBEindexed reference, assertingdecodeHeaderBoundedaborts under a tight cap and decodes normally under a generous cap /None.Notes for reviewers
SuaveConfigis intentionally out of scope here.defaultSettingis unchanged, so the existing "SETTINGS encode only emits explicitly-set entries" tests and any external callers that compare against it keep working.