pe: reject entry points outside the mapped image #2595
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2595
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2595"
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?
@XeNS1 on GitHub · 2026-11-25 16:25 UTC · original
XeNS1:codex/pe-entry-point-image-bound-20261125→main· +54 −2 · 1 files · 1 commits · openAn image with a nonzero
AddressOfEntryPoint >= SizeOfImagecurrently parses successfully. The loader retains that original RVA and later callsbase + entry_rvafor an executable orDllMain, afterprepare()has cleared the entry point in the copy given to Windows. Reject the invalid RVA inImageInfo::parsebefore it reaches those calls.Zero still denotes an absent entry point; existing acceptance of in-image RVAs is preserved. This only checks the declared mapped image extent, without introducing section, executable-permission or file-backing requirements. Two hand-built PE32+ tests cover EXE/DLL inputs at the boundary, beyond it and at
u32::MAX, plus zero, a normal in-image RVA and the last in-image byte (12 cases).Claim: PE-ENTRY-POINT-IMAGE-BOUND, coordination comment. This is separate from TLS callback checks (#324, #2532) and export address validation (#2412).
Validation on Linux x86-64 with Rust/Cargo 1.100.0, two build/test workers:
0x2000is accepted for an image of size0x2000; the new control test passes. Both new tests pass after the fix.cargo test -p victory-pe --locked --offline -j 2 -- --test-threads=2: 34 passed, 4 failed. A separate clean checkout of base67e8ae1gives 32 passed and the same four failures:parses_own_test_binary,rejects_iat_outside_image,rva_to_file_offset_maps_entry_point, andrva_to_file_offset_rejects_offsets_past_4_gib. These existing tests expect their own executable to be a Windows PE; on Linux it is ELF (Unknown file magic). No tests were changed or disabled to conceal this.cargo clippy -p victory-pe --all-targets --all-features --locked --offline -j 2 -- -D warnings, package rustfmt check,git diff --check, and asset policy (184 repository files / 1 staged file) pass.Windows and the pinned Rust 1.98.1 toolchain were not run locally; the repository's Windows CI remains the full-suite check. All new fixtures are generated from source in memory. No game files were accessed or included, and no guest code was executed.
Reference: Microsoft PE format specification, Optional Header standard / Windows-specific fields.
AI-assisted implementation and validation: OpenAI Codex.
@Marvisak on GitHub · 2026-11-25 22:22 UTC · original
Automated triage for the maintainers.
Proposed close: a guard for a case that does not occur. The check in
ImageInfo::parse(victory-pe/src/image.rs) is correct as written, and CI (check) passes. But the only images whose entry point VIctory calls are the title's own executable and its DLLs. Those are well-formed images, and their entry points lie inside them. A hand-made PE withAddressOfEntryPoint >= SizeOfImageis not an input the loader meets, and the inspect commands only print the field. This is the same kind of hardening as the earlier TLS-callback bounds PR (#324), which was also proposed for closing.This PR will be closed in 48 hours unless the author pushes a change (for example a real image that reaches this path) or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
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.