Bypassing File Upload Defenses: My Journey from Simple Bypass to Near RCE
The file upload feature allowed a PHP file to be uploaded by tampering with a client-side parameter that specified allowed MIME types and the stored filename. The uploaded file was then served as a download rather than executed, so the attacker could not achieve remote code execution.
Hello Hackers, Today in this write-up I am going to tell you how I am able to bypass file upload restrictions to upload php or any files and found malicious file download vulnerability in one of the bugcrowd program. And after finding this vulnerability how you can chain this vulnerability to RCE (Remote Code…
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 trusted a client-supplied parameter (js_session) to decide allowed MIME types and the stored filename, instead of enforcing these on the server side.
Impact
The attacker could upload a malicious PHP file, but it was served as a download rather than executed, so remote code execution was not achieved; the report was rated P5.
What the attacker needed
A user account with avatar upload; ability to intercept and modify requests
The fix
The server should enforce allowed file types and filenames on the server side, not rely on a client-supplied parameter.
How it was found
- Upload a normal PNG image and intercept the request to the third-party upload service.
- Observe the js_session parameter containing allowed MIME types and store path.
- Modify the js_session parameter to add application/x-httpd-php and change the filename to poc.php.
- Replace the image content with PHP code and send the request.
- Receive a 200 response with the URL of the uploaded file.
- Click save and then open the image in a new tab; the file is downloaded, not 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.
A file upload feature let users upload pictures, but the list of allowed file types was controlled by the user's browser. The attacker changed that list to include PHP files and also changed the saved filename to end in .php. The server accepted the file, but when opened it was downloaded instead of run, so no code execution happened.
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.