Skip to content

[C++][IPC] Validate buffer bounds and replace raw pointer arithmetic in MessageDecoder #55669

Open

Description

@Awesome06

Describe the enhancement requested

Describe the enhancement requested

In cpp/src/arrow/ipc, a few areas in streaming decoding and decompression can be made safer against invalid input buffers:

  1. MessageDecoderImpl::ConsumeDataChunks in message.cc uses raw pointer offsets (static_cast<uint8_t*>(out) + offset) and manual memcpy increments across chunk buffers. We can replace this with arrow::util::span and check available chunk bytes before copying.
  2. DecompressBuffer in reader.cc does not reject negative uncompressed sizes (uncompressed_size < -1) or cases where compressed_size == 0 && uncompressed_size > 0. We can also add an opt-in decompression ratio limit via IpcReadOptions (using MultiplyWithOverflow) for services reading untrusted streams.
  3. Untrusted FlatBuffers tables call std::vector::reserve (e.g. in metadata_internal.cc) without checking if the declared count fits within the remaining buffer bytes.
  4. Pass IpcReadOptions into MessageDecoder so streaming decoders can configure these limits.

Component(s)

C++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions