Facebook's imagetragick story.
Facebook's image processing service used a vulnerable ImageMagick library to convert images fetched from a user-supplied URL in the 'picture' parameter of the share dialog. An attacker could upload a malicious image that caused ImageMagick to execute shell commands, leading to remote code execution on Facebook's converter instance.
Meta
Published on 4lemon.ru
I want to believe that all of you know about ImageMagick and its Tragick. This issue was found in the end of the April, 2016 and due to many processing plugins depends on the ImageMagick library this issue has a huge impact.
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
Impact
An attacker could execute arbitrary shell commands on Facebook's image converter instance, though outbound network access was limited to DNS, which was used for data exfiltration.
What the attacker needed
Facebook share dialog accessible; attacker controls a URL for the picture parameter; attacker controls a DNS server
The fix
The vulnerability was fixed by Facebook after the report.
How it was found
- The attacker noticed the 'picture' parameter in Facebook's share dialog accepts a URL.
- Facebook fetched the image from that URL using its external hit service.
- The fetched image was passed to a converter instance running a vulnerable ImageMagick library.
- The attacker supplied a crafted image that used ImageMagick's MVG format to run a shell command.
- The command performed DNS lookups to an attacker-controlled domain, exfiltrating data such as directory listings and user ID.
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.
ImageMagick is a tool that converts images. A bug in it (called ImageTragick) let a specially crafted image file run commands on the server that processed it. Here, Facebook fetched an image from a URL you control and then converted it, so the attacker could make the server run commands and send data back out via DNS lookups.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.