MediumGHSA-qm2q-9f3q-2vcvCVE-2024-43368

Trix has a cross-site Scripting vulnerability on copy & paste

Published 14 Aug 2024 · Updated 4 Feb 2026

Is your project on an affected trix?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several JavaScript apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected package

trixnpm
Affected
<2.1.4
Fixed in
2.1.4
Update to the fixed version for your release line, for example:npm install trix@2.1.4

Details

The Trix editor, versions prior to 2.1.4, is vulnerable to XSS when pasting malicious code. This vulnerability is a bypass of the fix put in place for https://github.com/basecamp/trix/security/advisories/GHSA-qjqp-xr96-cj99. In https://github.com/basecamp/trix/pull/1149, we added sanitation for Trix attachments with a text/html content type. However, Trix only checks the content type on the paste event's dataTransfer object. As long as the dataTransfer has a content type of text/html, Trix parses its contents and creates an Attachment with them, even if the attachment itself doesn't have a text/html content type. Trix then uses the attachment content to set the attachment element's innerHTML.

Impact

An attacker could trick a user to copy and paste malicious code that would execute arbitrary JavaScript code within the context of the user's session, potentially leading to unauthorized actions being performed or sensitive information being disclosed.

Patches

Update Recommendation: Users should upgrade to Trix editor version 2.1.4 or later, which incorporates proper sanitization of input from copied content.

Workarounds

This is not really a workaround but something that should be considered in addition to upgrading to the patched version. If affected users can disallow browsers that don't support a Content Security Policy, then this would be an effective workaround for this and all XSS vulnerabilities. Set CSP policies such as script-src 'self' to ensure that only scripts hosted on the same origin are executed, and explicitly prohibit inline scripts using script-src-elem.

References

  • https://github.com/basecamp/trix/pull/1156
  • https://github.com/basecamp/trix/releases/tag/v2.1.4
  • https://github.com/basecamp/trix/pull/1149
  • https://github.com/basecamp/trix/security/advisories/GHSA-qjqp-xr96-cj99
  • MDN docs for `DataTransfer`

Credits

This vulnerability was reported by HackerOne researcher thwin_htet.

Is GHSA-qm2q-9f3q-2vcv in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected trix, and gives you the command that fixes it.

More advisories for trix

  • MediumCVE-2026-73428Trix: Stored XSS via HTMLParser attribute injection on paste · 24 Jul 2026
  • LowCVE-2026-73427Trix is vulnerable to XSS through JSON deserialization bypass in drag-and-drop (Level0InputController) · 29 Mar 2026
  • MediumCVE-2026-73426Trix has a Stored XSS vulnerability through serialized attributes · 12 Mar 2026
  • MediumGHSA-g9jg-w8vm-g96vTrix has a stored XSS vulnerability through its attachment attribute · 31 Dec 2025
  • LowCVE-2025-46812Trix vulnerable to Cross-site Scripting on copy & paste · 8 May 2025
  • MediumCVE-2025-21610Trix allows Cross-site Scripting via `javascript:` url in a link · 3 Jan 2025
All 9 advisories for trix

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.