Repository navigation
fix: Reject message sizes that overflow the header size - #984
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #984 +/- ##
=======================================
Coverage 78.52% 78.52%
=======================================
Files 106 106
Lines 17195 17199 +4
Branches 2064 2065 +1
=======================================
+ Hits 13502 13506 +4
Misses 2431 2431
Partials 1262 1262 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
@pedrobtz I've updated CI to fix the failures. Can you rebase or merge the latest main into your PRs? I'll re-run CI on them and work through them over the next few days. |
A message size near INT32_MAX overflowed decoder->header_size_bytes when the 4- or 8-byte prefix was added to it. Check it before adding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pedrobtz
force-pushed
the
fix-ipc-header-size-overflow
branch
from
October 22, 2026 15:27
955651a to
93d2209
Compare
This was referenced Nov 12, 2026
Closed
paleolimbot
pushed a commit
that referenced
this pull request
Nov 17, 2026
…ooter (#1014) Fixes #1013 The footer size check in ArrowIpcDecoderVerifyFooter() and ArrowIpcDecoderDecodeFooter() adds the header size, sizeof(int32_t) and the magic length in size_t and stores the result in an int32_t. ArrowIpcDecoderPeekFooter() only rejects negative footer sizes, so a footer size near INT32_MAX (for example 0x7FFFFFFE) makes the sum wrap to a negative value. The ESPIPE check then passes, and the footer pointer ends up about 2 GiB past the end of the buffer, which VerifyFooter and DecodeFooter then read. This change: - Computes the sum as int64_t in both functions, and prints it with PRId64 in the VerifyFooter message. - Adds to ArrowIpcDecoderDecodeFooter() the same ESPIPE check that VerifyFooter() has, before the footer pointer is computed. DecodeFooter() had no size check, so it now returns ESPIPE for short input instead of reading past the buffer. The approach matches the message header fix in #984 and the check in ArrowIpcDecoderDecodeHeader(). Testing: - New test NanoarrowIpcTest.NanoarrowIpcFooterSizeOverflow (src/nanoarrow/ipc/decoder_test.cc): a 16-byte buffer with footer size 0x7FFFFFFE. It checks that VerifyFooter() returns ESPIPE with the expected message, and that DecodeFooter() returns ESPIPE after PeekFooter(). - Ran with the CMake build: nanoarrow_ipc_decoder_test passes. The new test passes with the fix and fails without it. - clang-format 16.0.6 (--dry-run --Werror) and codespell 2.2.5 on the changed files: clean. Not run: the full ctest suite, `pre-commit run --all-files`, and the Meson CI job.
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.
ArrowIpcDecoderReadHeaderPrefix()adds the 4- or 8-byte prefix to the message size read from the input, and stores the sum in theint32_tdecoder->header_size_bytes. A message size nearINT32_MAXoverflows that sum, which is undefined behaviour. UBSan reports it assigned integer overflow: 8 + 2147483647 cannot be represented in type 'int32_t'. The size is now checked for that overflow before it is added. The negative-size check moves first, so it still runs before the sum.The new
NanoarrowIpcCheckHeaderSizeOverflowtest peeks a header with sizeINT32_MAXafter the continuation marker, and a pre-0.15 header with sizeINT32_MAX - 3. Both now returnEINVAL. Without the fix, the test fails under UBSan at the addition.The input was found by fuzzing the IPC reader in the zuarrow R package, which vendors nanoarrow.
ctestpasses with ASan and UBSan (410 tests). The changed files are formatted with the pinned clang-format 16.0.6.🤖 Generated with Claude Code