tombox-archive: reject fake EOCDs in comments and bound ZIP64/CD reads #44
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!44
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/44/head"
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?
@dea7hsmiless on GitHub · 2026-11-21 19:11 UTC · original
archive/eocd-bounds→main· +121 −14 · 2 files · 72 commits · closed without mergingLibrary / area:
crates/tombox-archive(ZIP64 central-directory reader / extraction safety validator)Exports changed (exports.txt rows): none
Source of the behaviour: PKWARE APPNOTE:
file tail.
record at the locator's offset.
What changed:
find_eocdnow scans backwards for an EOCD signature whose 22-byterecord plus its declared comment ends exactly at EOF. A fake EOCD
embedded in a real archive comment no longer hides the real EOCD and its
entries.
checked_add(56)against the file length; a past-EOF locator returnsMalformedinstead of an I/O error.checked_addand compared tothe file length. A ZIP64
cd_offsetnearu64::MAXreturnsMalformedinstead of panicking on overflow.
Tests and results:
cargo test -p tombox-archive-> 13 passed, 0 failed.cargo build -p tombox-archive-> exit 0.fake_eocd_in_comment.zip: before -> 0 parsed entries, no findings,"safe to extract", exit 0; after -> 1 parsed entry,
../evil.txtblocked as path traversal, exit 3.
zip64_overflow.zip(cd_offset = 0xFFFF_FFFF_FFFF_FFF8,cd_size = 16): before -> panicattempt to add with overflowatlib.rs:162, exit 101; after ->malformed ZIP: central directory bounds overflow (...), exit 1.comment, ZIP64 CD bounds overflow, ZIP64 EOCD offset past EOF.
zipfile: for a real archive whose commentembeds a fake EOCD, Python reports 0 entries; this parser reports the
real
hello.txt. A normal comment and a 65,535-byte comment also parsecorrectly.
Negative control:
ignores_fake_eocd_inside_commentfail (
left: 0, right: 1).checked_addmaderejects_zip64_cd_bounds_overflowfailwith
attempt to add with overflow.rejects_zip64_eocd_past_eoffail with an I/O error instead of
Malformed.Environment: Windows 11 Pro 10.0.26300, rustc/cargo 1.99.1.
Proven / inferred / not tested:
rules are format-level and synthetic.
the exact end of the file remains ambiguous without scanning local file
headers. This change rejects comment-embedded and malformed EOCDs and
bounds-checks ZIP64/CD reads.
the record's comment must end at EOF.
Dependencies: none. PR #37 is independent (
tombox-xshaderonly).cargo test -p tombox-archivepassesmissingwith a noteNo game files, console DLLs, assets or binaries are included.
@omonkeyz on GitHub · 2026-11-22 13:12 UTC · original
Main's history was rewritten, which auto-closed this PR. It is applied in
0a6490a(merged in81a1252) with your authorship kept, thanks! The added comment lines were stripped on the applied copy (the project keeps code free of comment lines).Pull request closed