Test files › Archives › zip-slip-traversal.zip
Zip Slip path traversal test file
Archive containing an entry named ../../../../tmp/qa-zip-slip.txt. The payload is a harmless text marker, but the path escapes the extraction directory.
↓ Download zip-slip-traversal.zip| Filename | zip-slip-traversal.zip |
| Format | ZIP |
| Size | 357 bytes (357 bytes) |
| MIME type | application/zip |
| SHA-256 | bf5ee2334900a786100f6b030fa929e1a6101b1075f501ff8d7be41c0b38107e |
What this file catchesExtractors that join the entry name to the destination without normalising and re-checking containment (Zip Slip, CVE-2018-1002200 and dozens of siblings). A correct extractor rejects this entry; a vulnerable one writes outside the target directory.
Handle it in code
Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.
Python
Check every entry before extracting anything. Python's extractall already strips "../" and leading slashes, but silently, so the file lands somewhere the archive did not say. Rejecting makes the attack visible and matches what other languages need.
import os, zipfile
def safe_extract(archive, dest):
dest = os.path.realpath(dest)
with zipfile.ZipFile(archive) as z:
for info in z.infolist():
target = os.path.realpath(os.path.join(dest, info.filename))
if os.path.commonpath([dest, target]) != dest:
raise ValueError(f"blocked: {info.filename!r} escapes the target folder")
z.extractall(dest)
try:
safe_extract("zip-slip-traversal.zip", "out")
print("extracted")
except ValueError as e:
print(e)Run against this file, it prints: blocked: '../../../../tmp/qa-zip-slip.txt' escapes the target folder
Related guides and tools
Download & verify
curl -fsSL -o "zip-slip-traversal.zip" "https://files.hexaqa.com/archive/zip-slip-traversal.zip"
curl -fsSL "https://files.hexaqa.com/archive/zip-slip-traversal.zip" | sha256sum
# expect: bf5ee2334900a786100f6b030fa929e1a6101b1075f501ff8d7be41c0b38107e