You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parquet reader panics on overlong VLQ integers in RLE / DELTA_BINARY_PACKED page data #12473
BitReader::get_vlq_int (parquet/src/util/bit_util.rs) decodes ULEB128 integers that are read straight from page data: RLE/bit-packed hybrid run headers (RleDecoder::reload) and the DELTA_BINARY_PACKED page and block headers (block_size, mini_blocks_per_block, values_left, first_value, min_delta).
On malformed input it panics instead of returning a ParquetError:
With more than MAX_VLQ_BYTE_LEN (10) continuation bytes, release builds hit assert!(shift <= MAX_VLQ_BYTE_LEN * 7, "Num of bytes exceed MAX_VLQ_BYTE_LEN (10)").
Debug builds panic earlier, with a shift overflow on << 70.
A 10th byte carrying bits beyond bit 63 is silently truncated, so the decoder continues with a wrong value.
A corrupt or malicious Parquet file can therefore crash the reader.
To Reproduce
letmut data = vec![0xFF;11];
data.push(0x01);letmut decoder = RleDecoder::new(3);
decoder.set_data(data.into());// panics
The same happens with DeltaBitPackDecoder::set_data when the header starts with 11 or more bytes that have the high bit set.
Expected behavior
The reader returns an error, as it does for other corrupt page data.
Additional context
The thrift compact protocol's read_vlq (parquet/src/parquet_thrift.rs) uses wrapping_shl, so it doesn't panic, but an overlong varint in the metadata silently decodes to a wrong value.
arrow-avro's read_varint (arrow-avro/src/reader/vlq.rs) already applies the right limits: at most 10 bytes, and the 10th byte must be < 2.
Activity
fix(parquet): return error instead of panicking on overlong VLQ integ…