How I Hacked RemoteBinge’s GIF Upload Filter
The RemoteBinge challenge allowed uploading files that were validated only by checking for the GIF89a magic bytes and the image/gif MIME type. An attacker could upload a PHP file with those bytes prepended, leading to remote code execution on the server.
medium.com
Published on medium.com
Recently, I’ve been diving into the fascinating world of file upload vulnerabilities, sparked by a captivating video from NahamSec. In it, he shared the story of a follower who managed to compromise a Netflix server by exploiting a file upload flaw.
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 validated uploads only by checking the GIF89a magic bytes and the Content-Type header, without verifying the file's actual content or preventing execution of uploaded files.
Impact
An attacker could execute arbitrary commands on the server, potentially leading to full compromise.
What the attacker needed
Access to the file upload form; ability to intercept and modify HTTP requests
How it was found
- Inspect the upload form and find no client-side validation.
- Upload a legitimate GIF to see the success response and file URL.
- Try uploading a PHP file with various bypasses (extension, MIME type, magic bytes) and observe rejections.
- Inspect a valid GIF to find the exact magic bytes GIF89a.
- Create a PHP file starting with GIF89a and set Content-Type to image/gif, then upload it.
- Access the uploaded file with a command parameter to execute code and retrieve the flag.
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 file upload feature let people send files to a server. The server tried to allow only GIF images by checking the file's first few bytes and its declared type. But the check was too simple: by putting the right bytes at the start of a PHP script, the attacker made the server accept it as an image. When the server later ran the file as PHP, the attacker's code executed, giving control over the server.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.