Skip to content

fix(ipc): Reject message sizes that overflow the header size - #984

Open
pedrobtz wants to merge 1 commit into
apache:mainfrom
pedrobtz:fix-ipc-header-size-overflow
Open

pedrobtz wants to merge 1 commit into
apache:mainfrom
pedrobtz:fix-ipc-header-size-overflow

Conversation

@pedrobtz

Copy link
Copy Markdown

ArrowIpcDecoderReadHeaderPrefix() adds the 4- or 8-byte prefix to the message size read from the input, and stores the sum in the int32_t decoder->header_size_bytes. A message size near INT32_MAX overflows that sum, which is undefined behaviour. UBSan reports it as signed 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 NanoarrowIpcCheckHeaderSizeOverflow test peeks a header with size INT32_MAX after the continuation marker, and a pre-0.15 header with size INT32_MAX - 3. Both now return EINVAL. 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.

ctest passes with ASan and UBSan (410 tests). The changed files are formatted with the pinned clang-format 16.0.6.

🤖 Generated with Claude Code

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.60%. Comparing base (efe4274) to head (955651a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #984   +/-   ##
=======================================
  Coverage   78.59%   78.60%           
=======================================
  Files         106      106           
  Lines       17153    17157    +4     
  Branches     2043     2044    +1     
=======================================
+ Hits        13482    13486    +4     
  Misses       2422     2422           
  Partials     1249     1249           

☔ 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

Copy link
Copy Markdown
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
pedrobtz force-pushed the fix-ipc-header-size-overflow branch from 955651a to 93d2209 Compare October 22, 2026 15:27
@pedrobtz

Copy link
Copy Markdown
Author

Thanks! I've rebased all seven onto main (55df060): #984, #985, #986, #987, #988, #989 and #990. Each still passes ctest locally with ASan and UBSan.

This branch has not been deployed

No deployments
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.

3 participants