The vulnerability CVE-2026-76845 in adm-zip versions 0.5.9 through 0.6.0 allows for arbitrary file overwrite due to improper handling of symbolic links during archive extraction. The core issue lies in how the library's internal utility functions, specifically Utils.makeDir, Utils.writeFileTo, and Utils.writeFileToAsync, interact with the filesystem. These functions previously used Node.js fs.statSync, fs.existsSync, and fs.open (or their asynchronous counterparts) without adequate checks for symbolic links or the O_NOFOLLOW flag.
When an attacker could create a symbolic link within the extraction destination that pointed outside the intended root directory, these functions would resolve the symlink and operate on the target file or directory. This allowed an attacker to overwrite arbitrary files on the system (if overwrite was enabled during extraction) or create directories outside the intended path.
The provided patch addresses this by:
- Introducing
lstatSync (and lstat for async operations), which provides information about the file itself, not the file it refers to if it's a symbolic link.
- Adding explicit checks within
Utils.makeDir, Utils.writeFileTo, and Utils.writeFileToAsync to traverse path components and verify that none of them are symbolic links. If a symbolic link is found, an error is thrown, preventing the malicious operation.
Therefore, the identified vulnerable functions are those that directly performed file system operations without these crucial symlink checks, allowing the exploitation to occur.