Hunting for Bugs in File Upload Feature:

Hey there, I am Samrat Gupta aka Sm4rty, a Security Researcher and a Bug Bounty Hunter. In this blog, I will be listing down some file upload vulnerabilities.


In most of the application you find file upload feature. This functionality, however, is implemented in many different forms based on the application’s use case. While some applications only allow uploading a profile picture and support only image-related extensions, on the other hand, some applications support other extensions based on their business case.

1. RCE via File Upload:

One of the most interesting attacks that come into mind whenever there is a file upload functionality is Remote Code Execution. There are several ways to execute a code execution with malicious files, one of the most common is to upload a shell and gain further access.

PHP shell for RCE:
Try Uploading this code with .php extension and Try to locate and retrieve the php file from application. In the file url you can add ‘c’ parameter where you can enter commands like ‘whoami’. For example, “

<?php phpinfo();?>
<?php system($_GET[‘c’]);?>

Its will not be this simple in real world application, there will be some restrictions on uploading these php files, We will talk about the file upload bypass techniques below.

Further Reads:

[Bonus] RCE via .gif upload:

2. XSS via File Upload:

While performing testing on file upload functionality, there are multiple ways to execute a cross-site scripting attack scenario. A file upload is a serious opportunity to find cross-site scripting (XSS) to a web application. Below are few ways to achieve XSS via File Upload-
1. XSS via Filename
2. XSS via Metadata
3. XSS via SVG file
4. Blind XSS via SVG

Reproduction Steps along with details of all the above methods can be found at one place in this awesome blog by Brutelogic. Check out the script to get Blind XSS via SVG file here:

Further Reads:

3. SSRF via File Upload:

Server-Side Request Forgery is one of the very interesting and impactful security vulnerability. A file upload functionality that may allow the use of files such as HTML or SVG files. It may an Internal SSRF, Cloud Metadata SSRF or simply an External SSRF.

1. SSRF via Filename.
Try to send URL as filename to get blind SSRF, for example filename= You can also try to change type=”file” to type=”url” within a request.

2. SSRF via SVG Upload:
Try Uploading this code with .svg extension and retrive the svg file from application to check:

<svg width="200" height="200"
xmlns="" xmlns:xlink="">
<image xlink:href="" height="200" width="200"/>

3. SSRF via Iframe in Html:
Try Uploading this code with .html extension and retrive the html file from application to check:

<iframe src=”" width=”500" height=”500"></iframe>

Further Reads:

4. XXE via File Upload:

The file upload functionality, opens the gateway for the XML External Entities, especially when the application accepts the file formats that support XML. Since the SVG format uses XML, an attacker can submit a malicious SVG image and so reach hidden attack surface for XXE vulnerabilities.

Try Uploading this code with .svg extension and retrieve the svg file from application to check:

<?xml version="1.0" standalone="yes"?>
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]>
<svg width="128px" height="128px" xmlns="" xmlns:xlink="" version="1.1">
<text font-size="16" x="0" y="16">&xxe;</text></svg>

Further Reads:

5. CSRF on File Upload:

Cross-Site Request Forgery (CSRF) is an attack that forces authenticated users to submit a request to a Web application against which they are currently authenticated.It is possible to perform CSRF attacks on file upload functionality by creating HTML Form.

Steps of Reproduction:
1. Capture the Upload form Request.
2. Create POC with Burp CSRF POC generator.
3. Open that POC html file in different account in different browser
4. And see if File upload is successful in another account.

Further Reads:

6. Exif MetaData Leakage:

It occurs when a user uploads an image in, the uploaded image’s EXIF Metadata Data does not gets stripped. As a result, anyone can get sensitive information of users like their Geo-location, their Device information like Device Name, Version, Software & Software version used etc.

Steps for Reproduction:

1) Visit this Repo. There are lot of images with metadata.
2) Upload the image to website.
3) Download the uploaded Image from website.
4) Visit this link to check whether exif metadata is not stripped or not. If not then you can report it.

Further Reads:

7. OpenRedirect via SVG File Upload:

Open Redirect with the File Upload functionality is not widely seen or talked about but still possible to execute under specific conditions. It is possible to create a payload that results in redirecting users to an attacker-controlled domain, an open redirection scenario can be crafted.

Steps of Reproduction:

  1. Save the below code as .svg file.
<svg width="200" height="200"
xmlns="" xmlns:xlink="">
<image xlink:href="" height="200" width="200"/>

2. Upload the file, Try to retrive a file.

Further Reads:

8. Large File DOS:

Often there is a size restriction associated with the File Upload functionality that may range from 5 MB to 200 MB or even smaller/larger depending upon the application logic. However if validation checks are not present, it may allow an attacker to upload a file with a relatively large size resulting in resource consumption that may lead to a Denial of Service situation.

To check for this issue, one can follow below simple steps:

  1. Create a file that is larger in the size than defined upper limit. For example, an image file having a 500 MB file size.
  2. Now, upload the file, and if the application accepts the file and starts processing it, browser the application from another device to see if there’s any sluggish behavior or connectivity error.

Further Reads:

9. File Upload Bypass:

It is when the server validates the file that is uploaded by comparing its extension, this validation are used to stop the attacker from uploading various malicious file. There are a list of bypasses available which we can use to bypass this security filters.

Here are few amazing Resources where all those file Upload bypasses can be easily found:

  1. PayloadAllTheThings File Upload Bypass.
  2. Unrestricted File Upload~Owasp
  3. Hacktricks ~ File Upload Methodology

10. File Name Vulnerability:

Here are a few Vulnerability which can be achieved in file upload vulnerability by changing file name. Its easy to test and worth having in your checklist. You can change the file name to following name to achieve respective bugs.

  1. Path Traversals: ../../../tmp/lol.png
  2. SQL Injection: sleep(10) — -.jpg
  3. XSS: <svg onload=alert(document.comain)>.jpg/png
  4. Command Injection: ; sleep 10;.jpg
  5. DOS: Rename your file to a long string and upload, It may cause DOS.

Thanks for Reading. Any Suggestions are always welcomed!!

If you haven’t Subscribed yet, Please Do Subscribe. You can Buy me a coffee and Follow me on Twitter.




Just a Cybersec Guy.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Ola Finance Rolls out Security Revamp

Metaverse IDO /∆ massive `repercussions’ when the Crown is frowned upon/€500,OOO.00/Visibility`Tax

Singapore Police awards Xfers for fighting cyber-crime and recovering S$14,500 for scam victim

Did you know you are being watched?

Futureswap: Not your keys. Not your perpetuals.

Download Vulnerability Review Report 2018 — Top Desktop Apps

{UPDATE} Bright Paw Hack Free Resources Generator

DataVisor Global Fraud Watch April 2021

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Just a Cybersec Guy.

More from Medium

Bug Bounty: Open Xmlrpc.php vulnerability on WordPress site.

A Peculiar Case of XSS and my first bug

IDOR vulnerability on invoice and weak password reset leads to account take over

RCE in .tgz file upload