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
Check valid byte_range in parquet Column Chunk reading? #6255
When reading a corrupt file, currently, arrow-rs would have:
/// Returns the offset and length in bytes of the column chunk within the filepubfnbyte_range(&self) -> (u64,u64){let col_start = matchself.dictionary_page_offset(){Some(dictionary_page_offset) => dictionary_page_offset,None => self.data_page_offset(),};let col_len = self.compressed_size();assert!(
col_start >= 0 && col_len >= 0,"column start and length should not be negative");(col_start asu64, col_len asu64)}
Would we better check the range here?
Describe the solution you'd like
Checking the range when building the group reader or in "byte_range()"
Describe alternatives you've considered
/// Returns the offset and length in bytes of the column chunk within the filepubfnbyte_range(&self) -> Result<(u64,u64)>{let col_start = matchself.dictionary_page_offset(){Some(dictionary_page_offset) => dictionary_page_offset,None => self.data_page_offset(),};let col_len = self.compressed_size();if col_len < 0 || col_len < 0{returnErr(ParquetError::General("column start and length should not be negative".to_string(),));}(col_start asu64, col_len asu64)}
@alamb I'm willing to try this but I'm not so familar with parquet-rs. Do you think this would better be checked in ColumnChunkMetaData::byte_range or ColumnChunkMetaData::from_thrift? Or this is already checked, we don't require this?
@alamb I'm willing to try this but I'm not so familar with parquet-rs. Do you think this would better be checked in ColumnChunkMetaData::byte_range or ColumnChunkMetaData::from_thrift? Or this is already checked, we don't require this?
I am not sure -- I think the first thing we should do is get a reproducer. Let me see if I can whip up some tests
This still panics on 60.1.0 (file/metadata/mod.rs:1043), and we hit it while fuzzing a Parquet viewer with libFuzzer, so it is reachable from untrusted files. In case a deterministic reproducer helps, this rewrites a valid file's footer so column 0 has a negative data_page_offset:
[dependencies]
parquet = { version = "60.1.0", features = ["arrow"] }
arrow-array = "60.1.0"bytes = "1"
thread 'main' panicked at parquet-60.1.0/src/file/metadata/mod.rs:1043:9:
column start and length should not be negative
Note that ParquetMetaDataReader accepts the negative offset and the panic only happens later, when the column chunk is read. Validating in ColumnChunkMetaData::from_thrift (or when building it) would turn this into an error at open time.
Activity
mapleFU commentedon Aug 15, 2024
@alamb I'm willing to try this but I'm not so familar with parquet-rs. Do you think this would better be checked in
ColumnChunkMetaData::byte_rangeorColumnChunkMetaData::from_thrift? Or this is already checked, we don't require this?alamb commentedon Aug 15, 2024
I am not sure -- I think the first thing we should do is get a reproducer. Let me see if I can whip up some tests
alamb commentedon Aug 15, 2024
See #6261 / #6262
alamb commentedon Aug 15, 2024
That looks good to me, FWIW
Raise RuntimeError instead of fatal when a damaged file makes a read …
elshanhsynv commentedon Nov 8, 2026
This still panics on 60.1.0 (
file/metadata/mod.rs:1043), and we hit it while fuzzing a Parquet viewer with libFuzzer, so it is reachable from untrusted files. In case a deterministic reproducer helps, this rewrites a valid file's footer so column 0 has a negativedata_page_offset:Note that
ParquetMetaDataReaderaccepts the negative offset and the panic only happens later, when the column chunk is read. Validating inColumnChunkMetaData::from_thrift(or when building it) would turn this into an error at open time.