My first RCE: a tale of good ideas and good friends
A server-side image processing service was vulnerable to ImageTragick, allowing an attacker to execute arbitrary commands by supplying a crafted image URL. The author confirmed remote code execution by causing the server to make an outbound request containing the username of the web server process.
TLDR: Through the help of two friends, some bash tricks, the use of Tomnomnom’s tool meg, and a service vulnerable to ImageTragick, I found my first RCE (and my first critical!) within the first two months of bug bounty hunting.
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 server used a vulnerable version of ImageMagick that did not properly sanitise image files, allowing command injection through crafted image content.
Impact
An attacker could execute arbitrary commands on the server, though the process did not run as root.
What the attacker needed
Server processes images from user-supplied URLs; vulnerable ImageMagick version; attacker can host a file
How it was found
- Start a simple HTTP server on a VPS to receive requests.
- Use meg to send requests with many parameters pointing to the server to a large list of hosts.
- Observe pings on the simple server to identify which host and parameter caused the request.
- Host an image on the server and request the vulnerable host with the image URL to confirm it fetches and processes the image.
- Modify the ImageTragick proof-of-concept to execute a command that sends the username back to the server.
- Receive the request containing the username, confirming remote code execution.
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.
ImageTragick is a flaw in an image processing tool that lets an attacker run commands on the server by uploading a specially crafted image. Here, the server fetched an image from a URL the attacker controlled, and that image contained instructions that made the server run a command. This gave the attacker control over 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.