viirya opened a new issue, #12473: URL: https://github.com/apache/arrow-rs/issues/12473
**Describe the bug** `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** ```rust let mut data = vec![0xFF; 11]; data.push(0x01); let mut 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. Found while discussing #12467. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
