Skip to content

Validate PKWARE compressed size before header subtraction#520

Open
rootvector2 wants to merge 1 commit intonih-at:mainfrom
rootvector2:fix-pkware-underflow
Open

Validate PKWARE compressed size before header subtraction#520
rootvector2 wants to merge 1 commit intonih-at:mainfrom
rootvector2:fix-pkware-underflow

Conversation

@rootvector2
Copy link

PKWARE encrypted entries include a 12-byte encryption header that is
accounted for by subtracting ZIP_CRYPTO_PKWARE_HEADERLEN from
st->comp_size in the ZIP_SOURCE_STAT handler.

If a malformed archive reports a compressed size smaller than the
PKWARE header length, the subtraction may wrap because comp_size
is an unsigned integer.

This patch adds validation during source creation to ensure that the
compressed size is present and large enough to contain the PKWARE
header. A guard is also added in the STAT handler as a defense-in-depth
measure.

The change mirrors the validation pattern already used in
zip_source_winzip_aes_decode.c.

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.

1 participant