Skip to content
Path traversal Advisory Intermediate

GHSL-2020-198: Path manipulation via Zip entry files (ZipSlip) in adm-zip

The extractAllTo method in adm-zip tried to prevent path traversal but only checked that the target folder path was a prefix of the extracted file path, allowing files to be written to sibling folders with names starting with the target folder's name. An attacker could craft a zip file to overwrite files outside the intended extraction directory.

ghsecuritylab Follow

Originally disclosed on GitHub Security Lab

The extractAllTo method allows extracting all files in a zip file to a specified target folder. It tries to ensure that no files are extracted outside this folder, so even if zip file entries have paths containing .. elements the files should still end up in the target folder.

ghsecuritylab, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The path validation used a simple prefix check instead of ensuring the resolved path stays within the target directory.

Impact

An attacker could overwrite files outside the intended target folder, leading to file system manipulation and data corruption, though exploitation is difficult because paths must match as described.

What the attacker needed

Attacker can provide a crafted zip file; victim uses adm-zip to extract it

The fix

The vulnerability was fixed by updating the path validation to properly prevent extraction outside the target folder.

How it was found

  1. Create a zip file with an entry whose path contains '..' and a sibling folder name that starts with the target folder name.
  2. Call extractAllTo with the target folder name.
  3. The file is extracted to the sibling folder instead of the target folder.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you unzip a file, the program should keep all files inside the folder you choose. This library tried to do that but made a mistake: it only checked if the destination path started with the folder name, so a file could be written to a different folder that also starts with the same name. An attacker could use this to overwrite files outside the intended folder.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by ghsecuritylab

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.