Skip to content

fix(parquet): reject varints longer than 10 bytes in read_vlq - #12132

Closed
amitcoder79 wants to merge 1 commit into
apache:mainfrom
amitcoder79:fix/parquet-vlq-limit
Closed

amitcoder79 wants to merge 1 commit into
apache:mainfrom
amitcoder79:fix/parquet-vlq-limit

Conversation

@amitcoder79

Copy link
Copy Markdown

Which issue does this PR close?

Closes #12099

Rationale

read_vlq loops 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_shl turns 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_metadata to read the file version as 33 instead of 1.

What changes are included in this PR?

Added a shift > 63 check in the read_vlq loop that returns a new ThriftProtocolError::InvalidVlq error, matching the protobuf and Thrift compact protocol varint specifications. The error converts to ParquetError::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.

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
@etseidl

etseidl commented Nov 9, 2026

Copy link
Copy Markdown
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.

@etseidl etseidl closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parquet: read_vlq accepts varints longer than 10 bytes and wraps the value

2 participants