Skip to content

[ELF] Reject out-of-bounds ELF sections and header tables - #8612

Merged
zznop merged 2 commits into
devfrom
test_fix_elf_parsing_bugs
Oct 2, 2026
Merged

zznop merged 2 commits into
devfrom
test_fix_elf_parsing_bugs

Conversation

@zznop

@zznop zznop commented Oct 1, 2026

Copy link
Copy Markdown
Member

This PR adds two bounds checks:

  • Reject section-header tables that extend beyond EOF before parsing entries.
  • Reject section contents that extend beyond EOF before storing or processing them. Exempt SHT_NULL and SHT_NOBITS, which have no file-backed contents.

I have validated these fixes against the binaries in this archive (which hang on 6.1):
binja-elf-hangs.zip

I have also tested all binaries in the user-provided archive: tangential storm travels capably

Closes https://github.com/Vector35/binaryninja/issues/1593

@zznop zznop added this to the Krypton R2 milestone Oct 1, 2026
@zznop
zznop requested a review from plafosse October 1, 2026 19:02
@zznop zznop self-assigned this Oct 1, 2026
zznop added 2 commits October 2, 2026 09:53
Validate the complete table against the file size using overflow-safe
arithmetic. This prevents truncated tables from creating thousands of
invalid, overlapping sections and stalling section-map construction.
Validate section offsets and sizes with overflow-safe bounds checks before
storing or processing sections. This prevents malformed sections from
triggering excessive string typing and section-map construction.
Exempt SHT_NULL and SHT_NOBITS, which have no file-backed contents.
@zznop
zznop force-pushed the test_fix_elf_parsing_bugs branch from e299129 to cd6705d Compare October 2, 2026 14:22
@zznop
zznop merged commit cd6705d into dev Oct 2, 2026
5 checks passed
@zznop
zznop deleted the test_fix_elf_parsing_bugs branch October 2, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants