VulnWatch by ve1ve2
medium 6.5 EPSS 0.20%

GHSA-8hxf-qr8p-62x4: zip: AES Entry HMAC Authentication Bypass on Premature EOF

Source:
OSV.dev
Published:
Fetched:
Updated:
Affects:
zip

https://osv.dev/vulnerability/GHSA-8hxf-qr8p-62x4 ↗

osvcrates.iofix-available

zip: AES Entry HMAC Authentication Bypass on Premature EOF ### Summary An AES-encrypted (AE-x) entry's authentication code is verified only when the reader's byte counter lands exactly on zero. If the bounded entry reader reaches the archive's actual EOF before the attacker-controlled, header-declared `compressed_size`, the counter remains positive, the HMAC is never read or compared, and the truncated, unauthenticated plaintext is returned as a clean end of stream. A zero-payload entry also returns before authentication. An attacker who does not know the password can modify an archive so chosen or modified plaintext is accepted with no error. ### Details [`src/aes.rs:246-292`](https://github.com/zip-rs/zip2/blob/6f09b3064ec87c3a69ea9f3413f9f9638b4aa446/src/aes.rs#L246-L292): ```rust fn read(&mut self, buf: &mut [u8]) -> io::Result { if self.data_remaining == 0 { // @audit insufficient check return Ok(0); } // get the number of bytes to read, compare as u64 to make sure we can read more than // 2^32 bytes even on 32 bit systems. let bytes_to_read = self.data_remaining.min(buf.len() as u64) as usize; let read = self.reader.read(&mut buf[0..bytes_to_read])?; self.data_remaining -= read as u64; // Update the hmac with the encrypted data self.hmac.update(&buf[0..read]); // decrypt the data self.cipher.crypt_in_place(&mut buf[0..read]); // if there is no data left to read, check the integrity of the data if self.data_remaining == 0 { debug_assert!( !self.finalized, "Tried to use an already finalized HMAC. This is a bug!" ); if self.finalized { return Err(Error::new( ErrorKind::InvalidData, "Tried to use an already finalized HMAC", )); } self.finalized = true; // Zip uses HMAC-Sha1-80, which only uses the first half of the hash // see https://www.winzip.com/win/en/aes_info.html#auth-faq let mut read_auth_code = [0; AUTH_CODE_LENGTH]; self.reader.read_exact(&mut read_auth_code)?; let computed_auth_code = &self.hmac.finalize_reset().into_bytes()[0..AUTH_CODE_LENGTH]; // use constant time comparison to mitigate timing attacks if !constant_time_eq(computed_auth_code, &read_auth_code) { return Err(Error::new( ErrorKind::InvalidData, "Invalid authentication code, this could be due to an invalid password or errors in the data", )); } } Ok(read) } ``` `data_remaining` starts at `compressed_size - (2 + 10 + salt_length)` ([`src/aes.rs:144-145`](https://github.com/zip-rs/zip2/blob/6f09b3064ec87c3a69ea9f3413f9f9638b4aa446/src/aes.rs#L144-L145)), where `compressed_size` comes straight from the attacker-controlled central directory. Nothing cross-checks the declared data span against the archive's structural boundaries: `ZipFileData::find_content()` is just `reader.take(self.compressed_size)` ([`src/ty Affected: crates.io:zip Fixed in: 9.0.0 References: https://github.com/zip-rs/zip2/security/advisories/GHSA-8hxf-qr8p-62x4 https://nvd.nist.gov/vuln/detail/CVE-2026-115906 https://github.com/zip-rs/zip2/commit/ec265db0b0602f8ffb9479327397bddefb7e2216 https://github.com/zip-rs/zip2 https://github.com/zip-rs/zip2/releases/tag/v9.0.0

Linked vulnerabilities (2)

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

zip: AES Entry HMAC Authentication Bypass on Premature EOF

CWE: CWE-1284, CWE-354Aliases: CVE-2026-115906
CVE-2026-115906 medium 6.5 EPSS 0.20% (p9) NVDCVE.orgGHSA
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

zip: AES Entry HMAC Authentication Bypass on Premature EOF

CWE: CWE-1284, CWE-354Aliases: GHSA-8hxf-qr8p-62x4