Scripts: map PE export RVAs only into file-backed bytes #2652
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2662"
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?
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T05:29:41Z.
The PE export inspector can read unrelated file bytes when export metadata extends beyond the file-backed part of a section. Bound RVA mapping, fixed-width reads, and string scanning to the section's raw bytes and the end of the file. PE section format
What is in it
SizeOfRawData. Check the entire export directory and each name, ordinal, and address table entry before reading it.Tested
c2ee10e4, the original two-section fixture read a name from the next section. Public head0841c094rejected that RVA but still accepted a string and a table entry that crossed the raw boundary. The updated head649d3856rejects each with an RVA-specific diagnostic.python -B -m unittest discover -s scripts -p 'test_*.py'passed 28 tests with 0 failures. The PE32 and PE32+ alias and forwarder regressions passed.kernel32.dlloutput matched both upstream and the prior PR head byte for byte, across 1,700 and 1,672 output lines respectively.git diff --checkpassed.Not tested
Retail title PE files, Rust or GPU tests, and a retail title run. This changes only the Python export inspector and its synthetic fixtures.
AI use
OpenAI Codex (GPT-6.2 Sol) implemented the original RVA fix and regression. OpenAI Codex (GPT-6, exact variant unavailable) implemented and integrated the wider read bounds, ran the Python suite and DLL comparisons, and drafted this description.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:37:18Z.
Triage (#1607) – head
649d385No open PR limits pe_exports.py reads to a section's file-backed bytes. #1814 adds bounds checks against the file size but keeps
max(VirtualSize, SizeOfRawData). #1685 maps RVAs in the image headers and #1494 checks NumberOfRvaAndSizes; both are different changes, but #1685 will conflict withraw_span. Most of the lines already on main come from the test helpermake_export_image, which was moved out of the existing test.An RVA in the zero-filled tail, or a table entry that crosses the end of a section's raw data, now raises instead of reading the next section's file bytes, and the tests cover both cases. No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T09:09:45Z.
merge-check
base:
1c8b551475head:
649d3856e7merge: clean (
git merge --no-editonto1c8b5514,git diff --checkclean;scripts/re/pe_exports.pyandscripts/test_pe_exports.py, +119/-39)build: not run (Tier 0 Python script diff; no Rust code changed)
tests:
python -m unittest discover -s scripts -p "test_pe_exports.py" -v-> 4 passed, 0 failed (base1c8b5514: 1 passed; 3 new boundary tests passed);python -m unittest discover -s scripts -p "test_*.py"-> 68 passed, 1 error (test_discord_mirror.pyon Windows, same failure on base1c8b5514). Rust workspace tests not run (Tier 0).review: Read the full diff (+119/-39). Tracks each section's
SizeOfRawDatainstead ofmax(VirtualSize, SizeOfRawData), validates every export directory/table entry and NUL-terminated string lies wholly within file-backed section bytes (scripts/re/pe_exports.py:15-33,39-48), and rejects RVAs landing in zero-filled virtual tails or crossing section ends. The 3 new tests cover zero-filled tails, overlay reads, unterminated strings, and straddling table entries. No problems found.performance: none (offline PE inspection script in
scripts/re/; zero runtime impact)verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Python 3.15.2, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T14:21:15Z.
Code review location:
scripts/test_pe_exports.py; line 93Could these raw-boundary fixtures also run against a PE32 (0x10B) image? make_export_image supports both formats, and the existing alias/forwarder test is parameterized for 0x10B and 0x20B, but these new zero-filled-tail, string-termination, and table-entry boundary cases all use PE32+. The export data-directory offset differs between optional-header formats, so running the boundary cases against both would cover the PE32 parsing path too. AI-assisted review (model: GPT-6; tool name unavailable in this session).
Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T14:21:15Z.
Review: COMMENTED
AI-assisted review (model: GPT-6; tool name unavailable in this session).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.