#0405
An application extracts ZIP archives uploaded by users. For each entry in the archive, it builds the destination path by joining the extract directory with the entry's path.
ZIP archives can contain entries with paths like ../../evil.sh. When extracted naively, this writes files outside the intended directory.
This is the Zip Slip vulnerability — it allows an attacker to overwrite arbitrary files on the server, including cron jobs, startup scripts, or application code.
Zip Slip has affected dozens of popular libraries and frameworks across Java, Go, Python, and Ruby. Extracting archives without path validation can lead to arbitrary file write and remote code execution.
validateZipEntry so it rejects entry paths that escape the extract directory.'Zip slip detected' when the resolved entry path does not start with extractDir.validateZipEntry('/tmp/extract', '../../evil.sh')// → throws Error('Zip slip detected')
validateZipEntry('/tmp/extract', '/etc/cron.d/evil')// → throws Error('Zip slip detected')
validateZipEntry('/tmp/extract', 'docs/readme.txt')// → returns '/tmp/extract/docs/readme.txt'
../../evil.sh) and absolute paths (/etc/cron.d/evil).