pe: validate forwarded export ordinals in pe_inventory #561
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/567"
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 R0Y00/Xbox2Windows. Originally posted by Neoplayer on 2026-11-22T12:47:32Z.
Change
Validate forwarded export ordinals in
tools/pe_inventory.py(resolve_desktop) via_parse_forwarded_ordinal(), matching the mapper contract intools/pe_map.cpp:target.partition(".")+dll.stripping) and keep the originalstep["forwarder"]text in the chain before validation so unresolved inputs stay visible in the report.#...forwarder targets as ASCII decimal integers in1..65535by accumulating digits with a65535upper bound (avoiding Python'sintstring-length limit exception on arbitrarily long digit strings) and report out-of-range (#0,#65536), empty (#), negative (#-1), non-decimal/non-ASCII, or oversized digit strings asinvalid_forwarder.#1,#65535) and negative (#0,#,#65536,#12abc,#-1, non-ASCII\u0661, and 10,000-digit decimal/0strings) test cases intests/intake/paths_check.py, asserting thatchain[-1]["forwarder"]keeps the original unresolved forwarder string.Verification
Commit under test:
06e148bon macOS arm64 (Python 3.12.13,pefile==2024.8.26):python3 -B tests/intake/paths_check.py: exit 0.python3 -B tests/dependency_paths_check.py:dependency_paths: the pinned hash reaches the conditional target; a different hash reports unverified_loader_hash and no conditional edge, exit 0.python3 -B tests/form_coverage_check.py:form coverage checks passed.python3 -B tests/docs_links_check.py:Self-test passed. Checked 10 Markdown files and 119 links.python3 -B tests/bidi_controls_check.py:Self-test passed. Checked 549 tracked source, script and build/CI files: no bidirectional controls.git diff --check: exit 0.Windows MSVC builds and native Windows
GetProcAddresscomparisons were not run on this macOS host; Windows builds run in GitHub Actions CI.Evidence and follow-up
All fixtures are source-built in-memory synthetic export tables in
tests/intake/paths_check.py. Any future change to dot splitting inpe_inventory.pyshould follow a source-built WindowsGetProcAddresscomparison covering explicit.dll, multi-dot module/namespace candidates, and#0.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T13:42:38Z.
The offline inventory can keep the original forwarder text. Please keep the existing dot-splitting rule for this change and validate forwarded ordinals as ASCII decimal 1–65535, matching the mapper contract. Keep unresolved input visible in the report. Please cover
#0, overflow, a nondecimal suffix and a very long decimal string. Accumulating with a 65535 limit avoids Python's input-length exception and keeps the rest of the inventory running.Before changing the separator, please add a source-built Windows
GetProcAddresscomparison. Use different return markers to distinguish candidates for an explicit.dll,front.Ns.Value, andmy.lib.Value; record the marker or error with both candidates present, only one present, and neither present. Please also record what native Windows returns for a#0forwarder. The ordinal validation can land independently of that investigation.Imported from R0Y00/Xbox2Windows. Originally posted by Neoplayer on 2026-11-22T14:11:28Z.
Updated in
06e148bper your feedback:partition(".")+dll.dot-splitting rule unchanged intools/pe_inventory.py._parse_forwarded_ordinal()to validate#...forwarders strictly as ASCII decimal1..65535(matchingtools/pe_map.cpp), accumulating digit-by-digit with an early> 0xFFFFstop so 10,000-digit strings do not trigger Python'sintstring-length limit.step["forwarder"] = targetbefore validation so unresolved forwarders stay visible inchain[-1]["forwarder"]alongsidestatus == "invalid_forwarder".tests/intake/paths_check.pyto cover#1,#65535,#0,#65536,#,#12abc,#-1, non-ASCII digits, and 10,000-digit decimal/zero strings (assertingchain[-1]["forwarder"]is preserved), and deferred separator exploration to a future WindowsGetProcAddresscomparison.