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.
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 2 months
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>
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.