[PATCH] COFF: Validate auxiliary x_endndx bounds

Alhuda Khan alhuda@research.digiscrypt.com
Tue Nov 24 11:46:29 GMT 2026


Hi,

Please find attached a patch for an out-of-bounds read in the COFF linker.

Reject COFF tag auxiliary entries whose x_endndx exceeds the input object's raw symbol-table entry count. Without this validation, a malformed COFF object can cause an out-of-bounds read while processing tag symbols in _bfd_coff_link_input_bfd. Check the index before calculating the end pointer used by the symbol-processing loop.

To reproduce, a relocatable PE x86-64 link of the attached tag-bad.o:

    ld -m i386pep -r -o out.o tag-bad.o

triggers an AddressSanitizer heap-buffer-overflow read in _bfd_pex64i_swap_sym_in (called from _bfd_coff_link_input_bfd), one byte past the external symbol-table buffer. Full ASan output is attached. With the patch, the linker rejects the input with "bad value" and the error is gone.

Signed-off-by: Alhuda Khan <alhuda@research.digiscrypt.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-COFF-Validate-auxiliary-x_endndx-bounds.patch
Type: application/octet-stream
Size: 1319 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20261124/887e7a9a/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before_xendndx.log
Type: application/octet-stream
Size: 3598 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20261124/887e7a9a/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tag-bad.o
Type: application/octet-stream
Size: 545 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20261124/887e7a9a/attachment-0001.o>


More information about the Binutils mailing list