fix(pe): validate section raw data bounds #219
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/219"
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 Marvisak/VIctory. Originally posted by DiegoFR20 on 2026-11-24T01:33:51Z.
Summary
Motivation
ImageInfo::parse()previously accepted a synthetic PE image whose section header declared more raw data than the file contained.This could allow
rva_to_file_offset()to return an offset beyond the available file bytes.Testing
cargo test -p victory-pecargo test --workspacecargo clippy -p victory-pe --all-targets -- -D warningsAll passed locally.
Compatibility question
Should the parser strictly reject sections whose declared raw-data ranges extend beyond EOF, or does VIctory intentionally support partially truncated PE images?
Opening as a draft to confirm the expected behavior before requesting a merge.
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T05:14:08Z.
Thanks @DiegoFR20 for tightening the raw section-data bounds while preserving valid boundary cases.
I tested commit
e57e76a7b4058e50d665ddcc9a11eb3cd4de4e7dwith:All 3 targeted tests passed (0 failed; 7 filtered):
rejects_section_extending_beyond_filerejects raw section data whose end exceeds the input image.accepts_section_ending_at_file_boundaryaccepts data ending exactly at EOF.accepts_section_with_zero_raw_sizeaccepts a virtual section with no raw bytes.These are synthetic PE parser boundary tests; they do not load a real executable.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T10:11:36Z.
Review: APPROVED
Tested
e57e76aon Windows 11, RTX 5070, MSVC:cargo test -p victory-pe10 passed,cargo clippy -p victory-pe --all-targetsclean.u64withchecked_add, so an overflowingPointerToRawData + SizeOfRawDatais also rejected. The check runs before any data directory is resolved, sorva_to_file_offsetcan no longer hand out an offset past EOF.file_size == 0matches how BSS-style sections work. I also checked the tests:opt + 240is the right section-table offset for the PE32+ optional header thatsynthetic_imagebuilds.AI-assisted (Claude Code).