Critical Bug Chaining: Upload Form ➜ CSRF ➜ Extension Bypass
A warranty registration page allowed file uploads but only checked the file extension, rejecting common PHP extensions. The attacker bypassed this by using a mixed-case extension (.PhP), which the server accepted and executed, leading to remote code execution.
Published on medium.com
Back in 2019, a Facebook post by Donnazmistuck in my mind. He shared a tip that seemed minor at the time — using alternative file extensions like .PhP.txt, .phtml, or even .PhP.jpg to bypass file upload restrictions.
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's file extension check was case-sensitive and only blocked lowercase .php, while the web server still executed .PhP as PHP.
Impact
An attacker could execute arbitrary code on the production server, leading to full compromise.
What the attacker needed
Access to the upload form; ability to host a malicious HTML page
The fix
The vulnerability should be fixed by validating file content and MIME type, using a whitelist of allowed extensions, storing uploads outside the web root, and using random filenames.
How it was found
- Found a warranty registration page with a file upload form for receipts.
- Tried common extension bypasses like .PhP.txt, .phtml, .PhP.jpg, and .PhP.pdf, all rejected.
- Viewed the page source and found a direct form action endpoint.
- Created a CSRF-like HTML form to upload a file to that endpoint.
- Uploaded a PHP file with the extension .PhP, which was accepted and executed.
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 website let people upload receipt files but tried to block dangerous file types by checking the name ending. The attacker changed the capitalisation of the extension to .PhP, which the server still treated as a PHP script and ran it. This let the attacker run commands 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.