Repository navigation
GH-55400: [C++][IPC] Validate body_length in ReadMessage and ReadMessageAsync - #55401
Closed
ShivanshhhG wants to merge 1 commit into
Closed
ShivanshhhG wants to merge 1 commit into
ShivanshhhG wants to merge 1 commit into
Conversation
…adMessageAsync Validate that body_length is non-negative and does not overflow signed 64-bit integer addition when added to metadata_length in ReadMessageInternal and ReadMessageAsync before issuing reads. Closes apache#55400. Signed-off-by: SHIVANSH-ux-ys <singaser78@gmail.com>
|
Thanks for opening a pull request! This pull request has been automatically closed because you currently have 4 open pull requests, which is more than the limit of 3. Due to the increase in pull requests opened by AI bots, and in order to keep the review queue manageable, Apache Arrow limits contributors without repository access to at most 3 concurrently open pull requests. This helps make sure each pull request gets the attention it needs and that work in progress does not go stale. Once one of your other open pull requests has been merged or closed, you are welcome to reopen this one. See also: |
|
|
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.
Rationale for this change
In
ipc::ReadMessage(offset, metadata_length, body_length, file)andipc::ReadMessageAsync,body_lengthis added tometadata_lengthto issue a single IO read for the entire message buffer. However,body_lengthwas not validated before issuing the read:body_lengthvalues causedReadAt/ReadAsyncto read fewer bytes thanmetadata_length, butSliceBuffer(metadata, 0, metadata_length)still sliced using the expected length, resulting in out-of-bounds reads during decoding.body_lengthvalues could overflow 64-bit signed integer addition (metadata_length + body_length).What changes are included in this PR?
body_length >= 0inReadMessageInternal(whenbody_lengthis provided) andReadMessageAsync.internal::AddWithOverflowto guard against arithmetic overflow when addingmetadata_length + body_length.Status::Invalidif validation fails.cpp/src/arrow/ipc/read_write_test.ccverifying invalid and overflowingbody_lengthare rejected in both synchronous and asynchronous overloads.Are these changes tested?
Yes, covered by unit tests in
cpp/src/arrow/ipc/read_write_test.cc(TestReadMessage.ReadBodyWithInvalidLength).Are there any user-facing changes?
Direct calls to
ipc::ReadMessageandipc::ReadMessageAsyncwith negative or overflowingbody_lengthnow returnStatus::Invalidinstead of proceeding with invalid buffer reads.