reject SETTINGS_HEADER_TABLE_SIZE larger than 2^31 - 1 - #9643
Open
basavaraj-sm05 wants to merge 1 commit into
Open
reject SETTINGS_HEADER_TABLE_SIZE larger than 2^31 - 1#9643basavaraj-sm05 wants to merge 1 commit into
basavaraj-sm05 wants to merge 1 commit into
Conversation
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.
readSettings decodes each SETTINGS value with a signed readInt(), and the size-shaped settings are meant to be range checked right where they're read. SETTINGS_INITIAL_WINDOW_SIZE and SETTINGS_MAX_FRAME_SIZE both reject a value whose high bit is set, but the SETTINGS_HEADER_TABLE_SIZE branch is empty, so a peer that advertises a header table size of 2^31 or more lands a negative int in the Settings. That value clears the != -1 guard in Http2Writer.applyAndAckSettings and reaches hpackWriter.resizeHeaderTable, where minOf(negative, 16384) stays negative and maxDynamicTableByteCount goes negative with it; adjustDynamicTableByteCount then runs evictToRecoverBytes against an empty dynamic table and walks off the end into a null slot, so the write side throws NullPointerException rather than a protocol error and the encoder's byte accounting is left broken. I noticed it lining up which settings check their value against which don't. Rejecting a negative header table size in the reader, the same way the two neighboring settings already do, keeps the bad value out of the encoder, and valid sizes decode unchanged since okhttp caps its own table at 16 KiB regardless.