ZIP Slip and Archive Extraction Attacks
What you'll learn: How attackers hide path-traversal sequences inside compressed archives to overwrite critical system files during extraction.
The Trojan Archive
You've learned about path traversal attacks like ../../../etc/passwd. Now imagine packaging that malicious path inside a ZIP, TAR, or other archive file. When a vulnerable application extracts the archive without validation, files can land anywhere on the filesystem—not just in the intended upload directory.
This is ZIP Slip: a deceptively simple but devastating attack where archive entries contain filenames like:
../../../var/www/html/shell.php
../../../../etc/cron.d/backdoor
../../config/database.yml
When extraction code naively trusts these paths, it writes files to locations you never intended.
How It Works
- Attacker creates an archive with malicious filenames containing
..sequences - Application receives and extracts the archive without sanitizing entry names
- Extraction library follows the path traversal, writing files outside the target directory
- Critical files get overwritten—configuration files, executables, web roots, or scheduled tasks
Real-World Impact
ZIP Slip affects applications in any language that extract archives without proper validation. Attackers can:
- Overwrite application code with web shells
- Modify configuration files to escalate privileges
- Replace system binaries or startup scripts
- Plant backdoors in writable system directories
The vulnerability exists in the extraction logic, not the archive format itself. Libraries like Python's zipfile, Java's ZipInputStream, and many others will happily extract to dangerous paths unless you validate entry names before extraction.
Key Takeaway: ZIP Slip exploits occur when applications extract archives without validating that each entry's destination path stays within the intended target directory—always check and sanitize archive entry names before writing files.