PE: reject out-of-range export addresses in parse_exports (fixes #2412) #2420
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!2420
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2420"
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?
@pushkarreddyy on GitHub · 2026-11-25 13:11 UTC · original
pushkarreddyy:fix/pe-export-rva-overflow→main· +26 −3 · 1 files · 1 commits · closed without mergingFixes #2412.
Root Cause
In
crates/victory-pe/src/image.rs(parse_exports), export RVAs were computed fromobject'sReadTarget::Address { address }usingaddress.wrapping_sub(image_base) as u32. If a malformed PE export address is belowimage_baseoraddress - image_base > u32::MAX,wrapping_subandas u32silently wrap/truncate to an invalid 32-bit RVA instead of returningPeError::Malformed.Implementation Details
export_rva(address: u64, image_base: u64) -> Result<u32, PeError>usingchecked_sub(image_base)andu32::try_from, returningPeError::Malformedon underflow oru32overflow.parse_exportsto callexport_rva(address, image_base)?.Verification
export_rva_rejects_underflow_and_u32_overflowunit test incrates/victory-pe/src/image.rsverifying valid RVAs, underflow belowimage_base, and overflow pastu32::MAX.check(workspace build, clippy-D warnings, and tests) is green.Scope & Limitations
@pushkarreddyy on GitHub · 2026-11-25 13:36 UTC · original
Hi @Marvisak — this PR resolves #2412 (rejecting out-of-range export addresses in
parse_exportswithPeError::Malformedinstead of wrapping/truncating), with unit tests and CI (check) passing. Ready for review and merge whenever convenient!@kotekompotek on GitHub · 2026-11-25 13:53 UTC · original
Reviewed:
wrapping_sub→checked_sub+u32::try_fromis the right fix — a PE64 export RVA must be a u32 above the image base. Test covers both reject directions and the happy path.@pushkarreddyy on GitHub · 2026-11-25 14:19 UTC · original
Thank you @kotekompotek for the review! Testers on untested Windows 10/11 and Wine/Proton configurations are welcome to verify.
AI-assisted: yes (Gemini 4 Neon)
@Marvisak on GitHub · 2026-11-25 15:29 UTC · original
Automated triage for the maintainers.
Proposed close. The error this adds cannot happen. In
image.rsparse_exports, the address comes fromobject's generic export iterator, which (as the existing comment says) builds it as the image base plus the 32-bit RVA from the export table. So onmain,address.wrapping_sub(image_base) as u32always gives back the exact RVA; the value cannot be below the image base or more thanu32::MAXabove it except through a wrap that the current code already undoes correctly, and the newexport_rvawould turn that case into an error. The unit test only calls the helper with values the iterator cannot produce.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.
Generated by Claude Code
@DenRakEiw on GitHub · 2026-11-25 13:19 UTC · original · approved these changes
Verified against
origin/main(940d32f):parse_exports(#2412) is clean and well-tested.cargo test -p victory-pe: 37/37 passed (includingexport_rva_rejects_underflow_and_u32_overflow).cargo clippy -p victory-pe --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 13:25 UTC · original · approved these changes
Tested locally: merged into main
940d32f69b,cargo test -p victory-pe --lockedon macOS arm64 — 33 passed, and the 4 failures are exactly the known pre-existing image::tests macOS-environment ones (identical on main). Approving — out-of-range export addresses rejected in parse_exports.@pushkarreddyy on GitHub · 2026-11-26 15:19 UTC · original
Closing this PR after reviewing the triage verification on
main:parse_exports,object's generic export iterator constructs addresses asimage_base + rva, soaddress.wrapping_sub(image_base) as u32onmainalready recovers the exact 32-bit RVA (including wrapped sums).mainalready handles correctly.Thank you for the verification.
AI-assisted: yes (Gemini 4 Neon)
Pull request closed