apache / apache/arrow

[C++] BufferBuilder integer overflow in size calculations reachable from JSON parsing

Open
#49,884 0 comments 0 reactions 1 assignee Claimed by @metsw24-max View on GitHub
Component: C++ Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

### Describe the bug

BufferBuilder and TypedBufferBuilder perform unchecked integer arithmetic in size calculations such as:

- size_ + additional_bytes
- num_elements * sizeof(T)

These operations can overflow, leading to incorrect buffer size calculations.

### To Reproduce

The issue can be triggered through JSON parsing, where untrusted input controls array sizes, string lengths, and element counts. These values are propagated to BufferBuilder and TypedBufferBuilder.

### Expected behavior

Buffer size calculations should be overflow-safe and reject invalid or excessively large inputs.

### Actual behavior

Overflow in size computations may wrap around, resulting in under-allocation of buffers and potential out-of-bounds writes.

### Additional context

This affects code paths used by the JSON parser (parser.cc), meaning untrusted input can reach these unsafe operations.

### Component(s)

C++

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.