Skip to content

Fix #2412: reject out-of-range export addresses in parse_exports - #3280

Open
tharun-37 wants to merge 3 commits into
Marvisak:mainfrom
tharun-37:fix/ghidra-export-validation
Open

tharun-37 wants to merge 3 commits into
Marvisak:mainfrom
tharun-37:fix/ghidra-export-validation

Conversation

@tharun-37

Copy link
Copy Markdown

Fix #2412: Export address validation now uses checked_sub() instead of wrapping_sub(), preventing integer overflow when an export address is below image_base or exceeds u32::MAX.

Changes:

  • Addresses below image_base are now rejected with an error
  • Addresses exceeding u32::MAX are now rejected with an error
  • Valid RVAs pass through correctly

Added test rejects_export_address_below_image_base verifying that an export address below image_base is rejected.

@AurumCarlos AurumCarlos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting it out, the diff is now just the parse_exports hunk. A few loose ends:

  • The description still mentions rejects_export_address_below_image_base, but this PR adds no test. Either drop that line, or add a test that really feeds an out-of-range address (the old one passed on the valid path, see my note on #3165).
  • As noted on #3165, object gives image_base + rva with a 32-bit RVA, so this can't trigger today. "Preventing integer overflow" would read better as a defensive check.
  • #3165 is still open with the same title and the other hunks; closing it (or retitling it for what's left) would avoid two PRs for #2412.
  • The new lines look longer than rustfmt allows; cargo fmt should reflow them.

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff and verified locally on Windows 11 x64:

  • Replacing address.wrapping_sub(image_base) as u32 with checked_sub(image_base) + u32::try_from cleanly rejects out-of-range export addresses with PeError::Malformed instead of silently truncating/wrapping.
  • cargo test -p victory-pe -- --test-threads=1: 36 passed, 0 failed.
  • cargo clippy -p victory-pe --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PE: reject out-of-range export addresses in parse_exports instead of wrapping

3 participants