arrow icon indicating copy to clipboard operation
arrow copied to clipboard

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

Open Awesome06 opened this issue 2 weeks ago • 0 comments

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++

Awesome06 avatar Nov 18 '26 10:11 Awesome06