Reject invalid DEFLATE HLIT values - #67
Merged
Merged
Conversation
RFC 1951 limits HLIT to values 0 through 29. Reject 30 and 31 before filling the dynamic code-length table, and check repeat runs against both the declared alphabet size and table capacity. Refs: weidai11/cryptopp#1368
Merged
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.
Inflator::DecodeHeader()accepted HLIT values 30 and 31, although RFC 1951 limits HLIT to 0 through 29.With the maximum HDIST value, the calculated fill length could reach 320 entries against the 318-entry code-length table. The existing guard compared against that same malformed bound rather than the table capacity, allowing an out-of-bounds write. On the layouts tested, this clears the
m_allocatedflag in theSecBlockallocator and triggersCRYPTOPP_ASSERT(m_allocated)during destruction.Reported upstream as weidai11/cryptopp#1368.
HDIST values 30 and 31 remain accepted. RFC 1951 permits the full 0 through 31 range, and
CreateFixedDistanceDecoder()initialises all 32 distance codes. Only HLIT is out of range; 286 literal/length codes plus 32 distance codes gives the correct table size of 318.What changed:
hlit > 29before filling the code-length table.