$13,000 for a Filename Inside a Zip: Path Traversal During Archive Extraction to RCE
The archive extraction logic joined zip entry names directly onto the extraction directory without checking the resolved path stayed inside it, so a crafted entry name with traversal sequences wrote a file to an arbitrary location. An attacker with bulk-import access could place a PHP file in a web-accessible directory and run commands on the server.
Archive extraction code almost always trusts the archive. That trust is the entire vulnerability class here — a zip file’s internal structure defines, among other things, the relative path each entry should be extracted to, and if the extraction logic joins that path directly onto a destination directory without…
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
The extraction code joined the zip entry's internal name onto the destination directory without resolving the final path and confirming it stayed inside that directory.
Impact
Remote code execution on the application server, achievable by any user with bulk-import upload access, via a crafted but otherwise unremarkable-looking zip archive.
What the attacker needed
Bulk-import upload access; ability to craft a zip with custom entry names; guess a writable, web-accessible path
The fix
The extraction path validation was patched within four days, and the program audited other archive-processing features, finding one additional affected import path.
How it was found
- Create a zip with a harmless PDF entry and a second entry whose internal name contains traversal sequences pointing to a guessed web-accessible writable path.
- Put a minimal PHP command-execution payload as the content of the second entry.
- Upload the zip through the bulk-import feature as an ordinary user.
- Request the guessed output path with a command parameter and observe command output, confirming execution.
- Remove the planted file immediately after confirmation.
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.
When you upload a zip, the server unpacks each file inside it to a folder. The name of each file inside the zip is just text, and if the server trusts that text, a name like many '../' steps can make the server write the file outside the intended folder. Here that let the attacker drop a script into a public web folder, which the server then ran.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.