Repository navigation
fix(parquet): reject varints longer than 10 bytes in read_vlq - #12132
Closed
amitcoder79 wants to merge 1 commit into
Closed
amitcoder79 wants to merge 1 commit into
amitcoder79 wants to merge 1 commit into
Conversation
read_vlq loops until a byte without the continuation bit, with no upper bound. A 64-bit varint uses at most 10 bytes (ceil(64/7)). On the 11th byte wrapping_shl turns a 70-bit shift into 6, silently corrupting the decoded value. Return an error when the shift exceeds 63, matching the protobuf and Thrift compact protocol specifications. Closes apache#12099
Contributor
|
Thank you for your submission, but #12099 has already been assigned. In the future, to avoid duplication of effort, please instruct your agent not to perform work on issues that have an asignee. |
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.
Which issue does this PR close?
Closes #12099
Rationale
read_vlqloops until it reads a byte without the continuation bit, with no upper bound on the number of bytes consumed. A 64-bit Thrift compact varint uses at most 10 bytes (ceil(64/7)). On the 11th byte,wrapping_shlturns a shift of 70 bits into a shift of 6 bits, silently ORing the payload into the low bits and corrupting the decoded value.The issue provides a reproducer where a 15-byte varint causes
decode_metadatato read the file version as 33 instead of 1.What changes are included in this PR?
Added a
shift > 63check in theread_vlqloop that returns a newThriftProtocolError::InvalidVlqerror, matching the protobuf and Thrift compact protocol varint specifications. The error converts toParquetError::General("varint exceeds 10 bytes").Are there any user-facing changes?
Malformed Thrift varints that previously decoded silently with wrong values now return an error. This is a correctness improvement — no valid file should contain varints longer than 10 bytes.