From 89a8ec58b14c661a52641728fa6f083081ae5578 Mon Sep 17 00:00:00 2001 From: Stefan Bucataru Date: Mon, 12 Oct 2026 18:11:49 -0400 Subject: [PATCH] fix(tools): validate empty ELF dynamic symbol table bounds --- tools/import_audit.py | 1 + tools/tests/test_import_audit.py | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/tools/import_audit.py b/tools/import_audit.py index f0fd82f2d..eaa65f225 100644 --- a/tools/import_audit.py +++ b/tools/import_audit.py @@ -157,6 +157,7 @@ def elf_exports(path, data): continue if entry != 24 or size % 24 or link >= len(sections) or sections[link][1] != 3: raise AuditError(f"{path}: invalid dynamic symbol table (entry size {entry}, size {size}, string table section {link})") + take(data, offset, size, path, "dynamic symbol table") strings_offset, strings_size = sections[link][4], sections[link][5] take(data, strings_offset, strings_size, path, "dynamic string table") indexes = [candidate for candidate in sections if candidate[1] == 18 and candidate[6] == section_index] diff --git a/tools/tests/test_import_audit.py b/tools/tests/test_import_audit.py index 1e84d84ea..07e1e9f98 100644 --- a/tools/tests/test_import_audit.py +++ b/tools/tests/test_import_audit.py @@ -102,6 +102,13 @@ def exporting(*names): return build_elf([(name, 1, GLOBAL_FUNCTION) for name in names]) +def with_elf_symbol_table_range(image, offset, size): + image = bytearray(image) + section_offset = struct.unpack_from("