When it comes to cross-site scripting, we want to find those script injection points that are frequently overlooked.  A common source of stored cross-site scripting vulnerabilities is the file upload.  Not only can we store a script in the application, but this script may be downloaded by other users.  When we first explorer our application, file uploads should be a huge red flag for any web application penetration tester.

There are several factors that may affect whether the application is vulnerable to uploaded file attacks:

  • The application may restrict file extensions.
  • The application may inspect the file’s contents to ensure that it complies with an expected format.
  • The application might check the file Content-Type header.

Some of these checks can be bypassed using the right files.  When examining the upload’s functionality, we should first upload a simple HTML file containing a proof-of-concept script.  If it’s accepted, try downloading the file.  If your script executes, we know that the application is vulnerable.

In most cases, the application will block the file upload or download, either because the file extension is not correct or the Content-Type header is not what is expected.  We can try bypassing these checks in a few different ways:

  • Change the file’s extension.  For example, if we had a file named “test.txt” and the application only accepts files with the .jpg file extension, try renaming the file to “test.txt.jpg” or simply “test.jpg”.
  • Use and intercepting proxy to change the Content-Type header.  Some applications will expect a specific Content-Type header.  Change it to the specific header that matches the file type expected.
  • Insert the script after clicking the upload button using an intercepting proxy.
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About Jean Fleury

Naval officer, privateer, cyber security professional. Traded in my five-ship squadron for a computer and Burp Suite license.

Category

Web Application Penetration Testing

Tags

, , , , , , , ,