Skip to content

fix(parquet): reject dictionary pages declaring more values than their bytes hold (#12471) - #12481

Open
Mola-maker wants to merge 1 commit into
apache:mainfrom
Mola-maker:fix/12471-dict-page-num-values
Open

Mola-maker wants to merge 1 commit into
apache:mainfrom
Mola-maker:fix/12471-dict-page-num-values

Conversation

@Mola-maker

@Mola-maker Mola-maker commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

The reader sizes allocations from a dictionary page's declared num_values before decoding it. A 120-byte file declaring i32::MAX values requests about 16 GiB and aborts the process instead of returning an error.

What changes are included in this PR?

Before any allocation, the declared count is checked against the decompressed page length at the smallest plain width of the physical type (e.g. 4 bytes per BYTE_ARRAY value for its length prefix). FLBA pages are also still checked exactly against type_length, as before.

Are these changes tested?

Yes. An end-to-end reader test uses the file from the issue, the three byte-array dictionary decoders each have a unit test, and check_dictionary_page_values has a table test per physical type. Two existing null tests declared 4 values for an empty dictionary; they now declare 0.

Are there any significant user-facing changes?

No.

AI usage disclosure

Harness: Muse
Model: Muse Spark
Effort: default
Role: Muse drafted the investigation, fix, and tests under my direction; I reviewed the diff and ran the tests.

@boring-cyborg boring-cyborg Bot added the parquet parquet crate label Nov 27, 2026
@Mola-maker

Copy link
Copy Markdown
Contributor Author

@etseidl @birkskyum Could you take a look when you have time? This rejects dictionary pages whose declared num_values can't fit in the page bytes, using the file from #12471.

@birkskyum birkskyum left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up. The bound is right for PLAIN dictionaries, and the check runs before every allocation the issue lists (primitive, BYTE_ARRAY, Utf8View and Dictionary readers). The crafted files from the report now fail with the new error at about 7 MB peak, and the parquet-testing files read the same as on main.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parquet: a dictionary page's num_values sizes the dictionary before it is decoded

2 participants