Skip to content

verify authentication code for zero-length winzip aes entries - #563

Closed
arshsmith1 wants to merge 1 commit into
nih-at:mainfrom
arshsmith1:winzip-aes-empty-hmac
Closed

verify authentication code for zero-length winzip aes entries#563
arshsmith1 wants to merge 1 commit into
nih-at:mainfrom
arshsmith1:winzip-aes-empty-hmac

Conversation

@arshsmith1

Copy link
Copy Markdown
Contributor
  1. winzip_aes_decrypt only runs verify_hmac inside the len > 0 read branch, so a zero-length AES entry (comp_size == salt + password verify + hmac) never has its authentication code checked.
  2. the central directory that supplies comp_size and crc isn't authenticated, so any encrypted entry can be rewritten to look empty with crc 0 and a garbage hmac, and it opens as a valid empty file instead of failing.

Verifying the hmac in ZIP_SOURCE_OPEN when data_length is 0 gets it rejected with ZIP_ER_CRC like any other tampered entry. The regress archive has an empty AES-256 entry with a corrupted hmac; reading it with the right password fails now and would pass before.

dillof added a commit that referenced this pull request Aug 19, 2026
…` was never called.

Fixes PR #563  and security advisory GHSA-c4x8-wr2m-r7x6
@dillof

dillof commented Aug 19, 2026

Copy link
Copy Markdown
Member

Thanks for the bug report and test case.

We've fixed it slightly differently so the error gets reported when closing the source (even without ever reading from it) instead of when opening it. This is in line with all the other end-of-file consistency checks done by sources.

@dillof dillof closed this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants