Skip to content
Path traversal Write-up Intermediate

ZIP Slip Surprise: How I Turned a File Upload into Remote Code Execution

A ZIP backup upload feature extracted archives without validating file paths, allowing path traversal. The attacker bypassed filters with double URL encoding and overwrote files to achieve remote code execution as root.

iski Follow

Published on medium.com

Free link 🎈

Iski, on medium.com

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 write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application extracted ZIP archives without properly validating that file paths stayed within the target directory, and its filter was not recursive.

Impact

The attacker achieved remote code execution as root, leading to complete server compromise and access to internal networks.

What the attacker needed

File upload feature for ZIP backups; server runs as root; web root writable

The fix

The application should validate every file path in a ZIP archive before extraction, use allow lists, run with least privilege, and store uploaded files outside the web root.

How it was found

  1. Upload a benign ZIP file to confirm the extraction feature works.
  2. Craft a ZIP with a path traversal sequence to escape the extraction directory.
  3. Bypass the path validation filter using double URL encoding.
  4. Upload the malicious ZIP to overwrite a cron file and exfiltrate /etc/passwd.
  5. Upload a ZIP containing a PHP web shell to the web root.
  6. Access the web shell to execute commands as root.

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 write-up has not been written yet. The Original tab links to the source.

A ZIP Slip bug happens when a website unpacks a ZIP file but doesn't check that the files inside stay in the intended folder. An attacker can craft a ZIP with file paths that climb out of that folder and overwrite important files, potentially taking over the server.

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 iski

View all

186 more disclosed reports, best first.

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.