Skip to content
RCE Write-up Intermediate

Unrestricted File Upload Leads to SSRF and RCE

An image upload feature passed user-supplied files to a vulnerable ImageMagick library, so a crafted image could make the server fetch an attacker URL and run shell commands. The author confirmed both SSRF and remote code execution, and also found a GhostScript path to RCE.

Muhammad Adel Follow

Published on itsfading.github.io

Peace be upon you all, I am going to share with you a vulnerability that I have found almost a year ago and it is remarkable for me because it was the first critical one for me anyway let’s jump in.

ItsFadinG, on itsfading.github.io

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 upload endpoint passed untrusted image files to an outdated ImageMagick build affected by the ImageTragick flaws, without validating or sandboxing the processing.

Impact

An attacker could make the server send requests to internal or external hosts and could execute commands on it, leading to full compromise.

What the attacker needed

An image upload feature; server uses vulnerable ImageMagick; attacker can submit a crafted file

How it was found

  1. Find the file upload feature on the PHP target.
  2. Run the upload through a Burp plugin that tests for file upload flaws.
  3. See the plugin flag the target as vulnerable to CVE-2016-3714.
  4. Upload a crafted image and watch a Burp Collaborator interaction to confirm SSRF.
  5. Upload a crafted image with a command in the fill URL to attempt RCE.
  6. Upload a GhostScript file to get a second RCE path.

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.

The site let people upload images and then used a tool called ImageMagick to process them. That tool had a known flaw where a specially crafted image file could tell the server to visit a web address or run a command. Because the server trusted the file, the attacker could make it do things on their behalf.

What is RCE?

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

More by Muhammad Adel

View all

1 more disclosed report, best first.

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.