THRIFT-6071: Validate container size fits int32 range before narrowing conversion in TSimpleJSONProtocol#3601
Open
Jens-G wants to merge 1 commit into
Open
THRIFT-6071: Validate container size fits int32 range before narrowing conversion in TSimpleJSONProtocol#3601Jens-G wants to merge 1 commit into
Jens-G wants to merge 1 commit into
Conversation
…g conversion in TSimpleJSONProtocol Client: go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fishy
approved these changes
Jun 17, 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.
Summary
ParseElemListBeginreads the list/set element count from the wire asint64viaParseI64, but passesint32(nSize)tocheckSizeForProtocol. Values larger thanmath.MaxInt32are silently narrowed before the check; the truncated value may pass while the fullint64is stored insizeand returned to callers.The fix adds an explicit range check (
nSize > math.MaxInt32) before the narrowing cast, returningSIZE_LIMITimmediately. The existingcheckSizeForProtocolcall is retained for the normal range.ReadListBeginandReadSetBeginboth delegate toParseElemListBeginand are covered by this change.binary_protocol,compact_protocol, andjson_protocolread container sizes asint32directly and are not affected.Related: PR #3599 addresses an analogous issue in
ReadMapBegin; the same guard should be added there once that fix lands.Test plan
TestReadSimpleJSONProtocolListBeginSizeOverflow— new test covering list and set; verifiesSIZE_LIMITis returned for a declared size of1<<32 + 1(whichint32truncation would reduce to1)go test ./...passes🤖 Generated with Claude Code