Repository navigation
PE: check SizeOfOptionalHeader and slice bounds in data_directory_offset - #3024
fuzeofficlal wants to merge 1 commit into
Conversation
kotekompotek
left a comment
There was a problem hiding this comment.
LGTM — honoring SizeOfOptionalHeader closes the lie where a truncated optional header claims more directories than it holds; both count_at+4 and entry-end bounds checked against opt_end and data.len. Test constructs the trailing-garbage case.
|
VERIFY-3024: verified Tests
Review against PE/COFF
Overlap: an open-PR search for AI-assisted (Claude Code). |
|
Automated triage for the maintainers. The new checks in Proposed for closing as a guard for a case that cannot occur. The PR will be closed in 48 hours unless the author pushes a change (for example, showing a caller that reaches CI: Generated by Claude Code |
|
Agreed — |
…in data_directory_offset
Summary
IMAGE_FILE_HEADER::SizeOfOptionalHeader(FILE_HEADER_SIZE_OF_OPTIONAL_HEADER = 16) and the input slice length incrates/victory-pe/src/layout.rs::data_directory_offset.data_directory_offsettrustedNumberOfRvaAndSizeswithout checking thatNumberOfRvaAndSizesor the full 8-byte data directory entry[off..off + DATA_DIRECTORY_SIZE)lay within the declared optional header (opt + SizeOfOptionalHeader) or withindata.len(), allowing callers such asvictory-loader/src/prepare.rsto receive offsets past the optional header (into the section table) or past EOF.read_u16, update the synthetic PE32+tests::image()fixture to populateSizeOfOptionalHeader, and add two unit tests coveringSizeOfOptionalHeaderboundary enforcement and truncated 8-byte directory entries at slice end.Verification
rustfmt --edition 2024 --check crates/victory-pe/src/layout.rs: ok.cargo test --locked -p victory-pe -p victory-loader: 38victory-peunit tests + 35victory-loaderunit tests + 4 integration tests passed.cargo clippy --locked -p victory-pe -p victory-loader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 191 files ok.