The vulnerability, CVE-2026-77301, describes an uncontrolled memory allocation issue in adm-zip. The core problem is that the library allocates memory for an entry's output buffer based on the declared uncompressed size in the ZIP file's central directory, without first validating this size against the actual compressed data or a reasonable maximum. This allows an attacker to create a small, specially crafted ZIP file that declares an extremely large uncompressed size, forcing the application to attempt a massive memory allocation, leading to a denial-of-service.
The vulnerability description explicitly states the root cause: 'zipEntry.js does Buffer.alloc(<declared uncompressed size>) before checking the declared size against the compressed size / available bytes.' It also mentions that zip.getEntries()[0].getData() triggers this behavior.
To identify the fix, I first attempted to use the commit URL provided in the vulnerability details, but it addressed a different, albeit related, decompression bomb issue in inflater.js. I then compared the latest vulnerable version (v0.5.17) with the first patched version (v0.6.1) to find all commits in between. The commit with the message 'Fixed preallocation security issue' (SHA: 2450dcf417aa29df49270237d18c5245794da3e2) was identified as the relevant patch.
Upon examining the diff for this commit, specifically in zipEntry.js, the following change was found:
- The line
var data = Buffer.alloc(_centralHeader.size); was removed.
- For
STORED entries, Buffer.alloc(compressedData.length) was introduced, ensuring allocation is based on the actual compressed data length.
- For
DEFLATED entries, the explicit Buffer.alloc was removed, and the inflater.inflate() method was made responsible for buffer management, which is implicitly capped by maxOutputLength (a fix from a related commit).
This change directly addresses the vulnerability by preventing the pre-allocation of an excessively large buffer based on an untrusted declared size. The getData method within zipEntry.js is the function that contains this vulnerable allocation logic and is directly called during exploitation, making it the primary vulnerable function.