pe_map_export reads export tables without checking page protection #163
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#163
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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:50 UTC · original
Affected file
tools/pe_map.cpp,pe_map_exportDescription
pe_map_exportbounds-checks the export directory, the address table, the name table and the ordinal table againstSizeOfImage, but it never checks the live page protection before reading them. Image bounds alone do not make bytes readable: a mapped section can lack read access, either by its characteristics or after a run-time reprotect.readable()already exists in the same file and is used for the TLS directory and the TLS callback list. The export lookup does not use it.docs/experiments.mdrecords the gap: "pe_map_exportdoes not yet apply this check to the export tables."Expected behavior
A lookup against a copy whose export section is mapped without read access returns
nullptr. A valid copy resolves the same export as before. An export target on an execute-only page is still returned, because that address can be called.Observed behavior
With the export section mapped
PAGE_NOACCESS,pe_map_exportdereferences the export directory and the host process terminates:Reproduction
cpu_register_probe.dlland clearIMAGE_SCN_MEM_READ(0x40000000) in the section that contains the export directory. A second copy setsIMAGE_SCN_MEM_EXECUTEinstead, which maps the sectionPAGE_EXECUTE.pe_map_imageand callpe_map_export(base, b"probe").The exact Python steps are the
check_unreadable_exportcheck proposed in the linked pull request. On currentmainthe call crashes; with that check added, both copies returnnullptrand the existing exports still resolve.Impact
A malformed or deliberately reprotected image can crash the host instead of failing the lookup, inside the path that resolves exports from mapped images.
Environment
Windows 10 22H2 build 19045, VS Build Tools 2022 17.14, MSVC 14.44.35207, Windows SDK 10.0.26100, CMake 4.4.4, Python 3.12.10, commit
c1a65f0. No GPU is used by this check.AI-assisted.