Repository navigation
Validate the file table against the header size - #234
Conversation
unshield_get_file_table() took the cabinet descriptor offset, the file table offset and the directory/file counts directly from the cabinet file and then read (directory_count + file_count) 32-bit words starting at data + cab_descriptor_offset + file_table_offset, without checking that this range stays within the header buffer. A cabinet with an out-of-range offset or an oversized file or directory count makes the loop read past the end of the allocated buffer. Compute the start offset and the number of bytes the loop will read in 64-bit arithmetic so the additions cannot wrap, reject an empty table, and reject any table that would start past the buffer or extend beyond it before reading. The allocation result is now checked as well. Reported-by: haind-pwn (VulnCheck) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Walkthrough
ChangesFile table validation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
unshield_get_file_table() took the cabinet descriptor offset, the file table offset and the directory/file counts directly from the cabinet file and then read (directory_count + file_count) 32-bit words starting at data + cab_descriptor_offset + file_table_offset, without checking that this range stays within the header buffer. A cabinet with an out-of-range offset or an oversized file or directory count makes the loop read past the end of the allocated buffer. Compute the start offset and the number of bytes the loop will read in 64-bit arithmetic so the additions cannot wrap, reject an empty table, and reject any table that would start past the buffer or extend beyond it before reading. The allocation result is now checked as well. Reported-by: haind-pwn (VulnCheck) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
e53b8a9 to
e2ae618
Compare
|
What this change does: Validates the file-table range before reading archive-controlled offsets and counts. This is a meaningful improvement to the archive parser, with a small and focused diff. I found no new correctness issue in the changed range check. The 64-bit arithmetic prevents the count/offset additions from wrapping, and the allocation failure is handled. Should fix before merging: Add an automated regression test for a table extending past the header and for overflowing 32-bit counts. I ran a standalone probe covering a valid exact-fit table, an oversized table, an offset beyond the header, maximum counts, and an empty table; all behaved as this patch intends. The existing macOS test suite also passed (24/24). Verdict: Worth merging; prioritize this contribution and include the bounds regression test. This protects the table itself; it does not validate every descriptor or string referenced by it. Branch update correction: The initial update used a force-pushed rebase. The original PR commits have now been restored as first-parent history with a merge commit, pushed normally without force. Both the original and previously rebased commits remain reachable. The reviewed file contents are unchanged. Review basis: main |
Restore the original contribution commits as the first-parent history. Keep the reviewed conflict resolutions and current main without rewriting published history again.
|
Thanks! |
unshield_get_file_table() took the cabinet descriptor offset, the file table offset and the directory/file counts directly from the cabinet file and then read (directory_count + file_count) 32-bit words starting at data + cab_descriptor_offset + file_table_offset, without checking that this range stays within the header buffer. A cabinet with an out-of-range offset or an oversized file or directory count makes the loop read past the end of the allocated buffer.
Compute the start offset and the number of bytes the loop will read in 64-bit arithmetic so the additions cannot wrap, reject an empty table, and reject any table that would start past the buffer or extend beyond it before reading. The allocation result is now checked as well.
Summary by CodeRabbit