Stored XSS on trix editor version 2.1.1
The Trix rich-text editor failed to properly sanitise HTML pasted into it, so a crafted attachment payload containing an image with an error handler ran script in the page. An attacker could get JavaScript to execute in a victim's session, potentially performing unauthorised actions or disclosing sensitive information.
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 3 months
- Paid in 3 days
- Disclosed after 5 months
The Trix editor is vulnerable to arbitrary code execution when copying and pasting content from the web or other documents with markup into the editor. The vulnerability stems from improper sanitization of pasted content, allowing an attacker to embed malicious scripts which are executed within the context of the application.
Vulnerable Version
2.1.1
Steps to Reproduce
- Run this HTML code on browser.
<!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.min.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":"<img src=1 onerror=alert(document.domain)>XSS POC"}"></div>me`);
</script>
</body>
</html>
- Click
copy meand paste it in trix editor.

- Alert will pop up.
This could be a bypass of recent Trix Editor CVE : CVE-2024-34341 Ref : https://github.com/basecamp/trix/security/advisories/GHSA-qjqp-xr96-cj99
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 editor's paste handling accepted a data-trix-attachment attribute containing HTML and inserted it without sanitising the embedded markup.
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 copies attacker-crafted content; victim pastes it into Trix editor
How it was found
- Open a local HTML page that loads the vulnerable Trix editor and writes a crafted element into the page.
- Select the text labelled 'copy me' and copy it.
- Paste the copied content into the Trix editor.
- Observe the alert firing, showing script execution.
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 accepts content copied from other pages. Here it trusted that copied content too much, so embedded markup ran as code in the browser. This is cross-site scripting, and it could let an attacker act in the user's session.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.