pe: check live page protection in pe_map_export #167
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!167
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/167/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@raulmoracode on GitHub · 2026-11-21 17:51 UTC · original
raulmoracode:pe/export-page-readability→main· +78 −5 · 3 files · 1 commits · merged 2026-11-21 18:08 UTCChange
pe_map_exportread the export directory, the address table, the name table and the ordinal table after a bounds check againstSizeOfImageonly. A mapped section can lack read access, by its characteristics or after a run-time reprotect, so the lookup could dereference an unreadable page.This applies the live protection check that
readable()already performs for the TLS directory and callback list:docs/experiments.mdno longer records the check as missing.Fixes #163
Verification
Commit
e5b2605on Windows 10 22H2 build 19045.6466, VS Build Tools 2022 17.14, MSVC 14.44.35207, Windows SDK 10.0.26100, CMake 4.4.4, Python 3.12.10.Result:
The full CPU group also passes:
ctest --preset dev --no-tests=error -R '^cpu_'reported 16/16, includingcpu_native_seh,cpu_native_sectionandcpu_native_tls.Negative control: with
tools/pe_map.cppreverted to the parent commit andpe_maprebuilt, the same test fails:Evidence and follow-up
The new check is
check_unreadable_exportintests/cpu/native_map_check.py. It uses the source-builtcpu_register_probe.dll, finds the section that contains the export directory, and rewrites that section'sCharacteristicson a temporary copy: once withoutIMAGE_SCN_MEM_READ, and once withIMAGE_SCN_MEM_EXECUTEonly. Both copies must resolve no export. The unmodified image is still covered bycheck_empty_export_slot, so the control that a valid export resolves is unchanged.pe_map_releaseaccepting a pointer thatpe_map_imagedid not return is a separate question, opened as #164 so it does not widen this change.Checklist
AI-assisted.