Skip to content

GH-55476: [C++] Sanitize IPC message body length handling - #55634

Merged
pitrou merged 2 commits into
apache:mainfrom
pitrou:gh55476-ipc-body-length
Nov 17, 2026
Merged

pitrou merged 2 commits into
apache:mainfrom
pitrou:gh55476-ipc-body-length

Conversation

@pitrou

@pitrou pitrou commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

In the IPC reader, when a subset of column is asked for, we allocate an entire buffer with the same size as the body size advertised in the IPC message.

That allocation uses the default memory pool instead of a user-configured memory pool, which defeats any user-defined protection against memory expansion attacks using e.g. CappedMemoryPool.

This issue was initially detected and reported privately by Wei-Lun Li (GH account b84330808 - thank you!). We decided that it did not warrant private treatment according to our current security guidelines, as it does not threaten confidentiality or integrity.

What changes are included in this PR?

Slightly refactor IPC message reading functions to allow passing a custom memory pool for the case where the message-reading function needs to allocate memory itself (instead of relying on the RandomAccessFile to do it).

Are these changes tested?

By existing unit tests, and by manual checking against a crafted invalid IPC file. While the crafted file would entail a huge memory allocation on without this PR, with this PR the IPC file reader errors out after detecting that the IPC message's body length is invalid.

Are there any user-facing changes?

An existing API is deprecated and superseded by a more flexible signature. These functions are unlikely to be called by user code, however.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@pitrou

pitrou commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

CI failures are unrelated. Would you like to take a look @adamreeve @wgtmac @WillAyd ?

@pitrou
pitrou force-pushed the gh55476-ipc-body-length branch from e902169 to d5d2c80 Compare November 17, 2026 10:24
@pitrou

pitrou commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@github-actions crossbow submit -g cpp

@pitrou

pitrou commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

I'll be waiting for the original private submitter to tell how they want to be credited.

@github-actions

This comment was marked as outdated.

@pitrou
pitrou force-pushed the gh55476-ipc-body-length branch from d5d2c80 to f6862be Compare November 17, 2026 12:23
@pitrou

pitrou commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@github-actions crossbow submit -g cpp

@github-actions

Copy link
Copy Markdown

Revision: f6862be

Submitted crossbow builds: ursacomputing/crossbow @ actions-2f2560a425

Task Status
example-cpp-minimal-build-static GitHub Actions
example-cpp-minimal-build-static-system-dependency GitHub Actions
example-cpp-tutorial GitHub Actions
test-build-cpp-fuzz GitHub Actions
test-conda-cpp GitHub Actions
test-conda-cpp-valgrind GitHub Actions
test-debian-13-cpp-amd64 GitHub Actions
test-debian-13-cpp-i386 GitHub Actions
test-debian-experimental-cpp-gcc-15 GitHub Actions
test-fedora-42-cpp GitHub Actions
test-ubuntu-22.04-cpp GitHub Actions
test-ubuntu-22.04-cpp-bundled GitHub Actions
test-ubuntu-22.04-cpp-emscripten GitHub Actions
test-ubuntu-22.04-cpp-no-threading GitHub Actions
test-ubuntu-24.04-cpp GitHub Actions
test-ubuntu-24.04-cpp-gcc-13-bundled GitHub Actions
test-ubuntu-24.04-cpp-gcc-14 GitHub Actions
test-ubuntu-24.04-cpp-minimal-with-formats GitHub Actions
test-ubuntu-24.04-cpp-thread-sanitizer GitHub Actions

@pitrou

pitrou commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

CI failures are unrelated.

@pitrou
pitrou merged commit a6dc1c9 into apache:main Nov 17, 2026
58 of 62 checks passed
@pitrou
pitrou deleted the gh55476-ipc-body-length branch November 17, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants