Skip to content
XSS Write-up Beginner

Finding DOM XSS via File Upload

The Dropify jQuery plugin inserts the uploaded file's name into the page as HTML without escaping it. An attacker could upload a file with a crafted name containing a script, which would then execute in the browser when the filename is displayed.

0Xdarsh Follow

Published on medium.com

As a pentester or bug hunter, discovering vulnerabilities in web applications can be both challenging and rewarding. One common vector that deserves attention is DOM-based Cross-Site Scripting (DOM XSS). we’ll dive into a specific case involving the Dropify file upload library, highlighting how a seemingly innocuous…

0Xdarsh, on medium.com

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

The plugin uses jQuery's .html() method to insert the unsanitised filename, so any HTML or script in the name is interpreted by the browser.

Impact

An attacker could execute scripts in the user's session, manipulate the page, or redirect to malicious sites, with greater risk in applications handling sensitive data or authentication.

What the attacker needed

Ability to upload a file with a crafted name; application uses Dropify to display filenames

The fix

The plugin should use .text() instead of .html() to insert the filename safely, and applications should sanitise input and use a strong Content Security Policy.

How it was found

  1. Create a file whose name contains a script payload.
  2. Upload the file through the application's file upload feature.
  3. When the application displays the filename, the script executes.

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.

When you upload a file, the website often shows the file's name on the page. This plugin takes that name and treats it as HTML code instead of plain text. If someone names their file with a script, the browser runs that script, which is called cross-site scripting (XSS).

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.