Skip to content
XSS Write-up Intermediate

Stored XSS via SVG Upload Bypassing WAF

A file upload feature accepted SVG files and stored attacker-controlled content that was later rendered as HTML, so a crafted SVG could run script in a victim's browser. The author first tried a script payload in the file name, which the WAF blocked, then placed the payload in the file's metadata, which bypassed the filter and triggered the XSS.

medium.com

Published on medium.com

Just sharing one of my findings — a stored XSS that managed to slip past the WAF

Faxcel, 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

Likely the upload feature accepted SVG files and served them from a location where the browser rendered their embedded script, while the WAF only inspected file names and URLs rather than file contents or metadata.

Impact

An attacker could store script that runs in the browser of anyone who opens the uploaded file, though the first attempt was blocked by the WAF and only the metadata variant succeeded.

What the attacker needed

Ability to upload assets; victim opens the uploaded file

The fix

The upload feature should reject or sanitise SVG files, or serve uploaded files with a content type and headers that prevent script execution, rather than relying on a WAF that only checks names and URLs.

How it was found

  1. Upload a file with the .svg extension through the asset upload feature.
  2. Intercept the upload request and change the file name to include a script payload.
  3. Read the response to find the directory path where the uploaded file is stored.
  4. Try to access the file directly and observe that the WAF blocks it.
  5. Re-upload the SVG with the payload placed in the file's metadata instead of the name.
  6. Access the file from the same upload directory and see the XSS trigger.

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 stored cross-site scripting (XSS) bug means a site saves something an attacker wrote and later shows it to other users as if it were part of the page. Here the site let people upload SVG image files, and SVG files can contain script. The attacker hid script inside the file's metadata, so the site's filter missed it and the script ran when the file was opened.

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.