You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stack buffer overflow reading encrypted entry with small compressed_size #1094
Found a stack buffer overflow in 4.2.2. When an encrypted entry's central directory compressed_size is smaller than the encryption header + footer, the decrypt streams compute a negative bytes_to_read and pass it down. mz_stream_os_read casts it to size_t for fread, which drains ~4 KB into the caller's buffer. For STORE + encrypted entries the destination is the caller's buffer, so anything under ~4 KB overflows with bytes from the archive.
Repro: AES-256 STORE entry, CD compressed_size patched 5528 -> 12, opened with the right password through the low-level mz_zip API over a file-backed stream. ASan: stack-buffer-overflow, WRITE of size 4027 past a 1024-byte stack buffer. Trace: fread <- mz_stream_os_read (mz_strm_os_posix.c:121) <- mz_stream_wzaes_read (mz_strm_wzaes.c:188) <- mz_stream_raw_read <- mz_zip_entry_read.
Same thing with PKWARE, compressed_size 5512 -> 5, writes 4044 bytes.
Scope: only the low-level mz_zip API with a file-backed stream. mz_zip_reader_open_file and the in-memory paths return 0 on the negative size, and the CLI fails cleanly. DEFLATE entries land in zlib's internal buffer so no overflow on glibc there, but the accounting is still wrong.
Fix idea: clamp bytes_to_read at 0 in mz_stream_wzaes_read and mz_stream_pkcrypt_read, and/or reject the entry in mz_zip_entry_open_int when compressed_size < header + footer for encrypted entries.
PoC archives and the reproducer harness are attached.
#1072 - zip: verify WinZip AES authentication on read close [open]
📝 Issue Planner
Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.
Create Plan
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your .coderabbit.yaml:
issue_enrichment:
auto_enrich:
enabled: false
💬 Have feedback or questions? Drop into our discord!
Activity
coderabbitai commentedon Dec 1, 2026
🔗 Related PRs
#1072 - zip: verify WinZip AES authentication on read close [open]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
merrowd commentedon Dec 1, 2026
The password for both PoC archives is test123. It is also hardcoded in the attached harness_os.c (line 38).