Skip to content
XSS Disclosed report Advanced CVE-2022-34475

Bypass of HTML Sanitizer API using same origin use element

The HTML Sanitizer API allowed same-origin SVG 'use' elements with absolute URLs to pass through unsanitised. On Firefox, such elements can execute JavaScript, so an attacker who controls a same-origin resource (for example an uploaded file) could achieve script execution even if the resource is served with a Content-Disposition header.

gazheyes Follow

Originally disclosed on Mozilla

  • Fixed in 2 months
  • Paid in 2 months
  • Disclosed after 2 months
Text
I was testing the Mozilla Sanitizer API that was introduced recently:
https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer

I found it was possible to use same origin use elements provided you specify the absolute URL. On Firefox same origin 'use' elements allow JavaScript execution whereas Chrome seems to block them. At least the auto executing part. The attack would work if an attacker has control over a same origin resource e.g. file upload. Even if this resource is served with a content disposition header the attack still works.

Example of same origin use elements causing JavaScript execution:
https://portswigger-labs.net/xss/xss.php?x=%3Csvg%3E%3Cuse%20href=%22//portswigger-labs.net/use_element/upload.php%23x%22/%3E%3C/svg%3E

Firefox (Nightly) version tested:
99.0a1 (2022-02-25)

Tested Sanitizer on here:
https://mozilla.github.io/sanitizer-polyfill/demo/

Input:
<svg><use href="https://mozilla.github.io/sanitizer-polyfill/demo/upload.php#x" />

Output:
<div><svg><use href="https://mozilla.github.io/sanitizer-polyfill/demo/upload.php#x"></use></svg></div>

The original report as published on Mozilla's Bugzilla, by gazheyes. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the sanitiser did not treat same-origin SVG 'use' elements as dangerous, allowing them to pass through even though Firefox executes JavaScript from them.

Impact

An attacker who controls a same-origin resource, such as an uploaded file, could execute JavaScript in Firefox even if the resource is served with a Content-Disposition header; Chrome appears to block the auto-executing part.

What the attacker needed

Attacker controls a same-origin resource; victim uses Firefox; sanitiser used on attacker-influenced HTML

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 report has not been written yet. The Original tab links to the source.

A sanitiser is a tool that removes dangerous parts from HTML before showing it, to stop scripts from running. This report found that the Mozilla sanitiser let through a special SVG tag called 'use' when it pointed to a file on the same website. In Firefox, that tag can run JavaScript, so if an attacker can upload a file to the site, they can make the sanitiser-approved HTML run their code.

What is XSS?

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

More from Mozilla

View all

The newest disclosed reports for this program.

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.