pe: intake_exe.py bounds-checks RVA reads and TLS callback slots by SizeOfRawData instead of Misc.VirtualSize #744
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#744
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?
@Ammmae0x on GitHub · 2026-11-23 00:26 UTC · original
Commit or build
fd2486f(upstream/main)Reproduction
Run against a temporary copy of the source-built fixture
out/build/dev/intake_forward_caller.exe(whose.datasection hasVirtualAddress=0xc000,Misc_VirtualSize=0x2b9,SizeOfRawData=0x200):Expected behavior
Consistent with the Windows PE loader and
tools/pe_map.cpp:95(const DWORD span = s.Misc.VirtualSize ? s.Misc.VirtualSize : s.SizeOfRawData;):section_for()(tools/intake_exe.py:81-88) and TLS callback slot counting (tools/intake_exe.py:109) should bound section spans byMisc_VirtualSize(falling back toSizeOfRawDatawhenMisc_VirtualSize == 0, and clamped toSizeOfImage), notSizeOfRawDataalone.read_rva()(tools/intake_exe.py:90-95) should zero-pad bytes in the uninitialized virtual tail[SizeOfRawData, Misc_VirtualSize)wherepe.get_data()returns fewer bytes (orb""), while continuing to reject truncated file-backed bytes withinSizeOfRawData.Acceptance criteria:
section_for(),read_rva(), and the TLS callback slot bound intools/intake_exe.py:81-111to honorMisc_VirtualSizeand zero-fill uninitialized BSS tail reads.tests/intake/check.pyplacing a TLS directory / zero-terminated callback table in a section's virtual tail (Misc_VirtualSize > SizeOfRawData) and verifyingintake_exe.inspect_executable()parses it cleanly.Observed behavior
section_for()(tools/intake_exe.py:84) checksoffset + length <= s.SizeOfRawData, andinspect_executable()(tools/intake_exe.py:109) computesslots = (section.VirtualAddress + section.SizeOfRawData - table) // 8. Additionally,read_rva()(tools/intake_exe.py:92-94) requireslen(pe.get_data(rva, length)) == length, which fails for virtual-tail RVAs becausepefilereturnsb""pastSizeOfRawData.Running the reproduction prints:
Environment
Windows 10 Pro 24H2 (build 26100.7623), Python 3.12.8 (
out\pe-env\Scripts\python.exe).Checklist
AI-assisted.
@R0Y00 on GitHub · 2026-11-23 01:08 UTC · original
Please keep section membership separate from file-backed bytes. An RVA can be inside the virtual section and still have no payload in the file. Prove that the entire requested field is file-backed before unpacking it, and give a clear error for a truncated TLS slot or table. A source-built section with a raw prefix and zero-filled tail can cover both cases.
@R0Y00 on GitHub · 2026-11-23 01:52 UTC · original
#760 is the merge candidate for this issue. I pushed
5b7b7b5to match pe_map when a section has no raw-data pointer. The targeted source-built TLS check passed locally, including the virtual tail, the missing raw pointer, the section boundary and the unterminated table. The new Windows CI runs are still required.The inspector checks the file-backed prefix separately and only supplies zeroes where the mapped section has no file backing. Thanks to both authors. #759 independently covered the same behavior and caught the missing raw-pointer case. Please hold further duplicate changes while #760 is verified.