Skip to content

[C++][Parquet] Possible int64 overflow in page index read range bounds check #50292

Description

@metsw24-max

Describe the bug, including details regarding any error messages, version, and platform.

RowGroupPageIndexReaderImpl::CheckReadRangeOrThrow in cpp/src/parquet/page_index.cc validates that a column chunk's page-index location lies inside the coalesced WillNeed read range using raw signed int64 additions:

if (index_location.offset < index_read_range->offset ||
    index_location.offset + index_location.length >
        index_read_range->offset + index_read_range->length) {

The offset/length come from the Thrift ColumnChunk metadata. For a column outside a WillNeed selection these are not otherwise bounds-checked here, so an offset near INT64_MAX wraps offset + length to a negative value (signed-overflow UB, confirmed under UBSan). The out-of-range check then passes, and GetColumnIndex/GetOffsetIndex go on to compute buffer_offset = location.offset - range.offset and read length bytes at buffer->data() + buffer_offset, an out-of-bounds read.

The neighbouring merge_range logic in the same file already uses AddWithOverflow; this check should do the same.

Component(s)

C++, Parquet

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions