Test files › Archives › absolute-path.zip

ZIP containing absolute paths

Archive whose entry name is an absolute path (/tmp/qa-absolute.txt).

↓ Download absolute-path.zip
Filenameabsolute-path.zip
FormatZIP
Size161 bytes (161 bytes)
MIME typeapplication/zip
SHA-2569ea841f8c6258f058270bae465ccc538dc3d85d445dae479db0df4d2c6e6cba3
What this file catchesThe less-tested cousin of Zip Slip. Extractors must strip leading slashes and drive letters rather than honouring an absolute destination.

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("absolute-path.zip", "out")
    print("extracted")
except ValueError as e:
    print(e)

Run against this file, it prints: blocked: '/tmp/qa-absolute.txt' escapes the target folder

Related guides and tools

Sample ZIP fileUpload validation checklistFile signaturesCheck a file's real typeVerify its SHA-256

Download & verify

curl -fsSL -o "absolute-path.zip" "https://files.hexaqa.com/archive/absolute-path.zip"
curl -fsSL "https://files.hexaqa.com/archive/absolute-path.zip" | sha256sum # expect: 9ea841f8c6258f058270bae465ccc538dc3d85d445dae479db0df4d2c6e6cba3

More archives test files

corrupt-central-directory.zipempty.zipmixed-content-50mb.zipmodest-zip-bomb.zipnested-10-deep.zipsingle-file.gzstored.7zunicode-entry-names.zip

← All Archives files