binutils Newspaper
NOVEMBER 30, 2026
bfd — Proposed

BFD: Fix out-of-bounds access in stabs linking and remote memory reads

Patches BFD to prevent out-of-bounds memory access during stabs processing and remote memory reads by adding necessary bounds checks.

This patch addresses two distinct out-of-bounds memory access vulnerabilities in the BFD library. The first, in stabs.c, allows a malformed .stabstr table with an invalid string index after an N_BINCL entry to cause ld to read past the buffer. The second, in elfcode.h’s bfd_from_remote_memory, involves unchecked 64-bit additions for segment and section header ends, which can lead to wrapped values and subsequent buffer overflows. The fixes introduce crucial bounds checks for string indices and arithmetic operations to prevent these issues.

In the Thread 1 participant
  1. mustafa proposer

    Submits a patch to fix out-of-bounds memory access in BFD related to stabs linking and remote memory reads.

    “Two places in bfd trust offsets from the input without checking them. _bfd_link_section_stabs, when it looks ahead after an N_BINCL, builds a pointer from stabstrbuf, the running string offset and the n_strx of the N_BINCL entry and reads it up to a NUL. The check that is done for the entries in the main loop is missing here, so a large n_strx makes ld read far outside the .stabstr buffer and c…”

In Details

This patch addresses two distinct vulnerabilities in BFD. The first, in bfd/stabs.c, concerns _bfd_link_section_stabs where the look-ahead for N_BINCL entries doesn't validate the n_strx against the .stabstr table size, leading to potential reads beyond the buffer. The second, in bfd/elfcode.h, affects bfd_from_remote_memory by performing unchecked 64-bit arithmetic on ELF header fields (p_offset + p_filesz, e_shoff + e_shnum * e_shentsize) and segment end calculations, which can result in integer overflow and incorrect memory region validation. The fixes add necessary bound…

For Context
BFD
Binary File Descriptor library, a part of GNU Binutils providing a common API for various object file formats.
stabs
A debugging information format used in older Unix systems and still supported by some compilers and tools. It stores symbolic information in a structured text format within object files.
N_BINCL
A stab entry type that signifies the beginning of a file inclusion, similar to a preprocessor #include directive.
.stabstr
The string table associated with stab debugging information, containing the textual representation of stab entries.
out-of-bounds access
An error condition where a program attempts to read or write memory outside the allocated buffer or array boundaries.
ELF
Executable and Linkable Format, a standard file format for executables, object code, shared libraries, and core dumps used on many Unix-like systems.
segment
In ELF, a program segment (defined by a Program Header) that is loadable into memory.
Filed Under: bfdsecurityvulnerabilitystabself