Skip to content

fix(parquet): cap Thrift binary allocation to avoid OOM on malformed lengths - #12133

Closed
amitcoder79 wants to merge 1 commit into
apache:mainfrom
amitcoder79:fix/parquet-thrift-alloc-cap
Closed

amitcoder79 wants to merge 1 commit into
apache:mainfrom
amitcoder79:fix/parquet-thrift-alloc-cap

Conversation

@amitcoder79

Copy link
Copy Markdown

Which issue does this PR close?

Closes #12100

Rationale

ThriftReadInputProtocol::read_bytes_owned reads a length from the Thrift stream and passes it directly to Vec::with_capacity. A malformed file can declare a multi-terabyte binary field, causing an OOM abort before any bytes are read. PR #10979 added similar checks for read_thrift_vec; this covers the Read-based Thrift decoder.

What changes are included in this PR?

Cap the initial allocation at 8 MB. The actual read (io::copy + take) is already bounded by the stream, so an overlong declared length returns UnexpectedEof rather than allocating the declared amount. The Vec grows as needed for legitimate large values.

Are there any user-facing changes?

Malformed Thrift files that previously caused an OOM abort now return an error. No behavior change for valid files.

…lengths

ThriftReadInputProtocol::read_bytes_owned passes the declared length
directly to Vec::with_capacity. A malformed file can declare a
multi-terabyte value, causing an immediate OOM abort before any bytes
are read.

Cap the initial allocation at 8 MB. The actual read is already bounded
by io::copy + take, so an overlong declared length returns
UnexpectedEof rather than allocating the declared amount upfront.

Closes apache#12100
@etseidl

etseidl commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for your submission, but #12100 has already been assigned. In the future, to avoid duplication of effort, please instruct your agent not to perform work on issues that have an asignee.

@etseidl etseidl closed this Nov 9, 2026
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: page header Thrift binary reads reserve Vec::with_capacity(len) from an unchecked length

2 participants