# Stored XSS on trix editor version 2.1.1

Trix editor 2.1.1 fails to sanitize pasted HTML5 attachment content, so copying a crafted div and pasting it into the editor executes attacker JavaScript.

- Payout: $1,000
- Severity: high
- Program: Basecamp
- Found by: thwin_htet
- Disclosed: 2024-11-04
- CVE: CVE-2024-34341
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/2521419
- Library page: https://bugbountylibrary.com/r/h1%3A2521419
- Tags: area:web domain:web impact:integrity kind:bounty platform:hackerone sev:high tech:nodejs technique:incomplete-fix technique:source-review vuln:xss

**Target:** Trix rich-text editor paste handler (data-trix-attachment HTML5 content)
**Root cause:** Pasted content with a data-trix-attachment JSON attribute of contentType text/html5 is rendered without sanitizing the embedded HTML, allowing script-bearing markup like img onerror.
**Steps:**
1. Load trix@2.1.1 UMD build and render a `<trix-editor>`.
2. Inject a copyable element via `document.write` containing `<div data-trix-attachment='{"contentType":"text/html5","content":"<img src=1 onerror=alert(document.domain)>XSS POC"}'>`.
3. Select and copy the element, then paste into the Trix editor.
4. The img onerror fires, executing `alert(document.domain)`.
**How found:** Researcher suspected the prior CVE-2024-34341 fix was incomplete and tested pasting HTML5 attachment content through the data-trix-attachment attribute, finding the embedded HTML still unsanitized.
**Exploitation:** Attacker hosts a page that writes the crafted attachment div to the clipboard via copy; victim pastes into a Trix editor, executing JS in the app origin to perform actions or exfiltrate session data.
**Insight:** When a sanitizer fix lands for a rich-text editor, retest the paste/attachment serialization path (data-* JSON attributes with contentType html5) rather than the normal input path, since the fix often only covers one entry point.

## Proof of concept (copied exactly from the original report)

**HTML PoC with data-trix-attachment payload**

```
document.write(`copy<div data-trix-attachment="{&quot;contentType&quot;:&quot;text/html5&quot;,&quot;content&quot;:&quot;&lt;img src=1 onerror=alert(document.domain)&gt;XSS POC&quot;}"></div>me`);
```

