Repository navigation
Conversation
Validate ColumnMetaData.type (presence and physical type match against schema) and reject negative counts, sizes, and offsets during Thrift decoding.
|
cc @etseidl @Rich-T-kid — fork CI is green. I noticed #12369 already checks negative data/dictionary page offsets and compressed size on column metadata; this PR also validates physical type presence and schema matches plus negative values across the remaining count, size, offset, and Bloom filter fields during Thrift decoding. Happy to coordinate or adjust if you'd prefer these combined or sequenced. |
|
run benchmark metadata |
|
🤖 Benchmark starting (GKE) | trigger Target: metadata Sharding factor: 1 (1 workers). Comparing fix/column-metadata-thrift-validation (23389e1) to 5e2595e (merge-base) diff Run configurationrun benchmark metadata
shards: 1
Trigger commentResults will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: metadata Comparing fix/column-metadata-thrift-validation (23389e1) to 5e2595e (merge-base) diff Run configurationrun benchmark metadata
shards: 1
Trigger commentDetailsPer-runner informationmetadata — shard 1/1Node: gk3-benchmark-cluster-nap-82xxsnow-cf225dd0-bg4k Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench metadataCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
etseidl
left a comment
There was a problem hiding this comment.
Thanks for the effort @ryanvickr, but I don't think I'm inclined to approve this PR. Many of the changes are validating fields that are either completely ignored within the crate or already validated where they are used. The remaining fields that can lead to a panic are already being addressed in #12369, which is tied to the same audit issue you reference.
While I can understand a desire to fully validate the metadata, I don't think it's necessarily this crate's responsibility to provide that blanket validation.
|
Makes sense — thanks for taking a look and running the benchmark! Since #12369 already covers the byte-range fields and Bloom filters are validated where used, I'll go ahead and close this out. One small note in case it's useful: the required-field mask for column metadata currently includes the physical type field, even though the validation function doesn't check for it (so a missing type falls through without an error). Might be worth either dropping it from the required mask or adding the check if you're touching that area in #12369. |
Which issue does this PR close?
Rationale for this change
When decoding
ColumnMetaDatafrom a Parquet footer, the Thrift decoder currently lets a few invalid inputs through:typefield is read and discarded without checking it against the schema, and required-field validation never explicitly checks thattypewas present.Downstream code expects these values to be non-negative and consistent with the schema, so malformed footers can cause arithmetic overflow, wraparound on unsigned casts, or panics when computing byte ranges. Validating them during Thrift decoding catches corrupt footers up front without requiring breaking changes to
ColumnChunkMetaData::byte_range()orColumnChunkMetaDataBuilder::build().What changes are included in this PR?
In
parquet/src/file/metadata/thrift/mod.rs:ColumnMetaData.typeto be present and match the column descriptor's physical type.0) fornum_values,total_uncompressed_size,total_compressed_size,data_page_offset,index_page_offset,dictionary_page_offset,bloom_filter_offset, andbloom_filter_length.Are these changes tested?
Yes — unit tests are included in
parquet::file::metadata::thrift::tests:test_read_column_metadata_rejects_type_mismatchtest_read_column_metadata_missing_type_is_errortest_read_column_metadata_rejects_negative_fields(verifies-1andi64::MIN/i32::MINreturn errors while0remains accepted for all eight fields)Are there any significant user-facing changes?
No breaking API changes.
ColumnChunkMetaData::byte_range(&self) -> (u64, u64)andColumnChunkMetaDataBuilder::buildremain unchanged. Malformed Thrift metadata with missing or mismatchedColumnMetaData.typeor negative counts/sizes/offsets now fails during metadata decoding with aParquetError::General.AI usage disclosure
AI coding assistance was used to adapt the validation logic, draft the unit tests, and draft this PR description; all changes and test results were reviewed by the author.