Skip to content

fix(ipc): Don't overflow the footer size check in VerifyFooter and DecodeFooter - #1014

Merged
paleolimbot merged 1 commit into
apache:mainfrom
shashank11yadav:fix/ipc-footer-size-overflow
Nov 17, 2026
Merged

paleolimbot merged 1 commit into
apache:mainfrom
shashank11yadav:fix/ipc-footer-size-overflow

Conversation

@shashank11yadav

Copy link
Copy Markdown
Contributor

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.

…codeFooter

The footer size plus the size field and magic was summed in size_t and
narrowed to int32_t, so a footer size close to INT32_MAX wrapped to a
negative number, skipped the ESPIPE check and led to an out-of-bounds
read. Compute the sum as int64_t, and add the same check to
ArrowIpcDecoderDecodeFooter, which had none.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.55%. Comparing base (ee22361) to head (da46db7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1014   +/-   ##
=======================================
  Coverage   78.55%   78.55%           
=======================================
  Files         106      106           
  Lines       17297    17298    +1     
  Branches     2066     2067    +1     
=======================================
+ Hits        13587    13588    +1     
  Misses       2446     2446           
  Partials     1264     1264           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paleolimbot paleolimbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@paleolimbot
paleolimbot merged commit 1292ac0 into apache:main Nov 17, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArrowIpcDecoderVerifyFooter() reads out of bounds when the footer size is close to INT32_MAX

3 participants