XSS via paste and Clipboard API and SVG + image onerror handler
Firefox's clipboard content sanitisation could be bypassed when pasting HTML copied from a malicious page, allowing an SVG image error handler to run script. An attacker could achieve script execution in the context of a site where the victim pastes the copied content.
Originally disclosed on Mozilla
- Fixed in 32 days
- Paid in 43 days
- Disclosed after 32 days
When fuzzing Firefox clipboard API content sanitization on pasting, I found sanitizer bypass with payload <svg><style><image href=1 onerror=alert(document.domain)>. When user copy from crafted malicious website, then paste the content, XSS will execute. It leads to universal XSS on latest stable release of Firefox, Firefox 78.3.0esr (64-bit), and Firefox Nightly 82.0a1 (2020-09-20).
Steps to reproduce:
- Go to https://sourc7.appspot.com/bugzilla/0447f4d26c48bd8d0526dce173f57b3ac5235b7b.html
- Click Copy Text
- Go to https://output.jsbin.com/gocizet/ (TinyMCE Rich Editor form)
- Paste with Ctrl+V or Right click -> Paste into TinyMCE form
- XSS will execute [pop alert(document.domain)]
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 clipboard HTML sanitiser did not strip event handler attributes on elements nested inside SVG style content, so the onerror handler survived sanitisation.
Impact
Script could run in the context of any site where the victim pastes the copied content, which the author calls universal XSS, affecting current stable and nightly Firefox builds.
What the attacker needed
Victim copies content from attacker page; victim pastes into a rich text editor; Firefox browser
How it was found
- Open the attacker page that offers a copy button.
- Click the copy button so the crafted HTML is placed on the clipboard.
- Open a page containing a rich text editor.
- Paste the clipboard content into the editor.
- The script runs and shows an alert with the page's domain.
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.
When you copy something from a web page and paste it into an editor, the browser tries to clean the copied HTML so no scripts come along. Here that cleaning step missed a trick: a hidden image inside an SVG graphic was allowed through, and when the image failed to load its error handler ran code. The result is that script from the attacker's page runs inside the site where you pasted.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.