
Cloud Vulnerability DB
A community-led vulnerabilities database
A crafted ZIP file makes ZipArchive::new run for seconds to minutes. A 99 KB file takes 8 seconds and a 400 KB file takes 4 minutes. The call ends in an error, so the caller gets nothing back and can't stop it early. Spreadsheets and Word documents are ZIP files too: calamine, docx-rs and umya-spreadsheet all stall on the same file.
It affects 9.5.1, the latest release, and every release back to 2.2.2, with default features and settings. master (2b9a0e5c5) is the same.
It's a denial of service. I'd rate it High (CVSS 3.1 7.5, AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H), the vector you used for GHSA-9hj8-73fh-9963.
find_central_directory_end tries every EOCD signature near the end of the file. For one that may be ZIP64, it looks for the ZIP64 EOCD record anywhere between the locator's offset and the locator. A crafted locator sets that offset to 0, so the whole file is searched.
Three things multiply:
find_central_directory.rs:445). The cache from #1142 stopped the rescanning, not the reparsing.Zip64CentralDirectoryEnd::parse allocates and reads record_size - 44 bytes (blocks.rs:538) before the exact-length check rejects the record (find_central_directory.rs:349).Spreadsheets, Word documents, EPUBs and JAR files are all ZIP archives, so this reaches well past code that thinks of itself as unzipping. I opened the 99 KB file with three crates that read Office files, using each one's normal open call:
| Crate | zip version | Call | Time |
|---|---|---|---|
| calamine 0.38.0 | 9.5.1 | open_workbook_auto_from_rs | 23 s |
| docx-rs 0.4.22 | 8.6.0 | read_docx | 7.9 s |
| umya-spreadsheet 3.1.1 | 8.6.0 | reader::xlsx::read_reader | 7.8 s |
| calamine takes three times as long because it tries xlsx, xlsb and ods in turn, and each attempt opens the ZIP again. | |||
| So an attacker needs only an upload form, such as a spreadsheet import or a document preview. A 400 KB file holds a CPU core for 4 minutes, and one upload per core keeps every core busy for that long. If the server opens files inside an async handler, each upload also blocks a runtime worker, so the same handful of uploads stops it answering anyone. Nothing in the library protects the caller: the default settings are enough, the error comes back only after the time is spent, and limits on entry count or extracted size never get a chance to run. | |||
ZipWriter::new_append and zip::unstable::read::ZipIterable::try_new run the same search (7.9 s on the 99 KB file). | |||
Workarounds: opening with Config { archive_offset: ArchiveOffset::Known(x) } takes 3.6 ms on the 99 KB file, because it tries only one ZIP64 position. It requires that there be exactly x bytes of non-ZIP data before the first file in the archive. read_zipfile_from_stream and ZipStreamReader::new are similarly fast, and require that the reader already be positioned at the first file. |
Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."