Repository navigation
fix(parquet): cap Thrift binary allocation to avoid OOM on malformed lengths - #12133
Closed
amitcoder79 wants to merge 1 commit into
Closed
amitcoder79 wants to merge 1 commit into
amitcoder79 wants to merge 1 commit into
Conversation
…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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #12100
Rationale
ThriftReadInputProtocol::read_bytes_ownedreads a length from the Thrift stream and passes it directly toVec::with_capacity. A malformed file can declare a multi-terabytebinaryfield, causing an OOM abort before any bytes are read. PR #10979 added similar checks forread_thrift_vec; this covers theRead-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 returnsUnexpectedEofrather 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.