Skip to content
RCE Write-up Intermediate

How a Simple ZIP Upload Revealed a Critical Remote Code Execution Flaw

The application accepted ZIP uploads without validating the archive contents, and the backend processed files inside the ZIP through a PHP stream wrapper. An attacker could upload a ZIP containing a PHP file and have it executed by the server, achieving remote code execution.

harshtalavaniya05 Follow

Published on medium.com

A few weeks ago, during a routine security assessment for a redacted application, I stumbled upon something that reminded me why simple features are often the most dangerous ones.

Harsh Talavaniya, 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 backend used a PHP stream wrapper to include files from an uploaded ZIP without validating or restricting the archive contents, allowing attacker-controlled PHP to be executed.

Impact

An attacker could achieve remote code execution, potentially leading to full server compromise, arbitrary file read, and sensitive data exposure.

What the attacker needed

Ability to upload a ZIP file; Backend uses ZIP stream wrappers

The fix

The application should validate and sanitise the contents of uploaded ZIP archives and avoid processing internal archive files through executable stream wrappers.

How it was found

  1. Create a harmless PHP file that produces simple output.
  2. Compress that file into a ZIP archive.
  3. Upload the ZIP through the application's upload feature.
  4. Request the uploaded archive using a crafted path that references the internal PHP file.
  5. Observe that the server executes the internal file and returns its output.

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 file is a container that can hold other files. This application let people upload ZIPs but did not check what was inside them. The server then treated a file from inside the ZIP as a program and ran it, which let the uploader run their own code on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.