binutils Newspaper
NOVEMBER 30, 2026
mach-o — Proposed — Sentiment 7 / 10

mach-o: fix out-of-bounds read in bfd_mach_o_read_prebound_dylib

Fixes an out-of-bounds read vulnerability in Mach-O binary parsing.

This patch (v3) addresses an out-of-bounds read vulnerability in the bfd_mach_o_read_prebound_dylib function when parsing Mach-O binaries. The vulnerability arose from pointer arithmetic with offsets that could underflow, leading to incorrect memory access. The fix removes the problematic pointer arithmetic, ensuring reads stay within validated file offsets. While this resolves the out-of-bounds access, the author notes a remaining possibility of semantically incorrect output if an offset points into the ‘modules bitmap,’ a condition not explicitly checked by sibling readers. They offer to add a specific check for this overlap if preferred.

In the Thread 2 participants
  1. Venkateswara Reddy Challa proposer

    Submits v3 of a fix for an out-of-bounds read in Mach-O parsing, removing pointer arithmetic that caused underflows and ensuring reads stay within validated offsets.

    “On the remaining lower-bound / overlap point: with the pointer arithmetic gone, both reads now stay within their validated load-command-relative file offsets, so there is no out-of-bounds access left -- only the possibility of semantically garbage output if the name offset points into the modules bitmap. That overlap case is not checked by the sibling readers either, so v3 stays consistent with t…”
  2. Jan Beulich reviewer

    Acknowledges the fix for out-of-bounds reads but reiterates concerns about potential semantic garbage output due to overlapping data if the name offset is not properly validated.

    “From: Venkateswara Reddy Challa <venkatchallaceh@gmail.com> Date: Fri, 16 Oct 2026 16:40:33 +0530 Subject: [PATCH v3] mach-o: fix out-of-bounds read in bfd_mach_o_read_prebound_dylib bfd_mach_o_read_prebound_dylib() read the file-controlled name and linked_modules offsets of an LC_PREBOUND_DYLIB load command, checked only that each was not greater than the load command length, then derived two…”

Technical Tradeoffs

  • Fixes a critical out-of-bounds read vulnerability by removing unsafe pointer arithmetic.
  • Maintains consistency with other Mach-O readers by not adding explicit checks for semantic garbage output from overlapping data, which could be added as a separate enhancement.

In Details

This patch addresses a security vulnerability in the Mach-O file parser within binutils' BFD library. Specifically, the bfd_mach_o_read_prebound_dylib function incorrectly calculates memory offsets for LC_PREBOUND_DYLIB load commands. By subtracting a fixed constant from file offsets without ensuring a lower bound, pointer arithmetic could underflow, leading to reads outside the intended buffer. The fix removes this unsafe arithmetic. A reviewer notes that while the out-of-bounds read is fixed, the potential for semantic garbage output remains if offsets point into unrelated data, a scena…

For Context
mach-o
Mach Object file format, the standard executable file format used by macOS, iOS, and other Apple operating systems. Binutils includes support for parsing and manipulating these files.
out-of-bounds read
A memory access error where a program attempts to read data from a memory location outside the boundaries of an allocated buffer. This can lead to crashes or security vulnerabilities.
load command
Structures within a Mach-O file that describe the layout and characteristics of the file, such as segments, libraries, and other metadata.
LC_PREBOUND_DYLIB
A specific Mach-O load command that lists prebound dynamic libraries. This command contains information about library names and their offsets within the load command structure.
BFD
Binutils 'Binary File Descriptor' library. It provides a common interface for reading and writing various object file formats, including Mach-O.
Filed Under: mach-osecurityvulnerabilityparserbfd