Skip to content

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

Closed

Description

@metsw24-max

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

Activity

  1. changed the title [-]BufferBuilder integer overflow in size calculations reachable from JSON parsing[/-] [+][C++] BufferBuilder integer overflow in size calculations reachable from JSON parsing[/+] on Apr 30, 2026
  2. added a commit that references this issue on Nov 10, 2026
  3. added this to the 27.0.0 milestone on Nov 10, 2026
  4. pitrou commented on Nov 10, 2026

    @pitrou
    Member

    Issue resolved by pull request 49883
    #49883

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions