Repository navigation
PE: validate directory and table bounds in parser and loader (#106) - #1367
slopgobblercobbler wants to merge 1 commit into
Conversation
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Review: this is the parse-step rejection my #836 proposal asked for — validating directory descriptors and block sizes once, in the parser ( |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Thanks for the thorough review and verification, @pickles976! To answer your two coverage questions directly:
|
|
Regression run of Against the limits in CONTRIBUTING.md: 101 % of AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, AI use: Claude Code (Claude Opus 5.5) built both trees and ran |
…stream xcl-dev#1367) Ports live head 8dbc465 (still OPEN vs upstream/main). pe.rs: directory descriptor/block sizes bounded by remaining dir data; export AddressOf tables bounded by dir+image; thunk slot/entry RVAs + name strings checked_add-bounded with size_of_image clamps; Mapped rva_to_offset/tail image clamps; all 5 parser tests as-is. loader.rs: section va+mapped outside-image fail; import IAT-slot and delay-HMODULE outside-image fails. Loader reloc guards + page-span clamp already on linux (xcl-dev#291 / section_protect_range helper) — not re-ported. Failing-first: truncated_directories_are_rejected FAILED pre-fix; Mapped-layout probe proved past-dir-end acceptance pre-fix (removed). Gates: both checks 0 errors, lib 737/0/1 (+5), title e2e 12 GPU-only FAILs, retail HOLDS at +0x2237320.
|
Nothing has happened on this PR for 3 days, so it is marked |
|
Overlaps: #291 adds the same relocation-target bound in AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Addresses #106 Item 3 (PE parser & loader bounds checking):
Prevents out-of-bounds reads and panics on truncated or malformed PE binaries:
pe.rs: inimports,delay_imports, andrelocations, validates that directory descriptor and block sizes do not exceed remaining directory data (block <= d.size - pos), returningErr(PeError::BadRva)instead of attempting out-of-bounds slice indexing.pe.rs: inexports, validatesAddressOfFunctions,AddressOfNames, andAddressOfNameOrdinalstable spans against directory bounds andsize_of_image.pe.rs: inthunks, validates slot and entry IAT RVAs against image bounds and checkschecked_addon name RVA strings.loader.rs: validates section mapping bounds (s.va + s.mapped_size() <= size), relocation targets, import IAT slots, delay-import module handles, and clamps page protection spans.What is in it
crates/xcl/src/pe.rs:truncated_directories_are_rejected,import_directory_without_null_terminator_exceeding_size_is_error,delay_import_without_null_terminator_exceeding_size_is_error,export_tables_exceeding_directory_bounds_is_error, andthunks_with_out_of_bounds_iat_slot_is_error.crates/xcl/src/loader.rs:Tested
cargo test -p xcl -- pe(17 passed, 0 failed).cargo test -p xcl -- loader(2 passed, 0 failed).cargo test --workspace(707 passed, 0 failed).upstream/main(930e8b4).Not tested
AI use
author-pebounds,verify-pebounds). Verified and reviewed independently.