CVE-2026-61784: xhtml-purifier has HTML attribute-injection (sanitizer bypass) that leads to XSS

Published Sep 24, 2026
·
Updated

xhtml-purifier does not HTML-entity-encode attribute values when serializing its sanitized output. In attributeString() (XHTMLPurifier.js, around line 148) the attribute value is concatenated directly into a double-quoted attribute without encoding. As a result, an attacker-controlled value in any allowed attribute (class, style, title, alt, src, href) can include a double-quote character to break out of the attribute and inject an additional attribute, such as a JavaScript event handler (for example onmouseover or onerror). The injected handler survives sanitization and executes when the output is rendered, which is a sanitizer bypass leading to cross-site scripting. The fix HTML-entity-encodes attribute values before serialization.

Other sources

xhtml-purifier is a Node.js library to take in raw/unknown/untrusted HTML and output cleaned, purified, trusted HTML. Versions prior to 0.4.3 do not HTML-entity-encode attribute values when serializing its sanitized output. In attributeString() (XHTMLPurifier.js, around line 148) the attribute value is concatenated directly into a double-quoted attribute without encoding. As a result, an attacker-controlled value in any allowed attribute (class, style, title, alt, src, href) can include a double-quote character to break out of the attribute and inject an additional attribute, such as a JavaScript event handler (for example onmouseover or onerror). The injected handler survives sanitization and executes when the output is rendered, which is a sanitizer bypass leading to cross-site scripting. The fix in version 0.4.3 HTML-entity-encodes attribute values before serialization.

— MITRE

Affected Software

2 affected componentsFixes available
npm/xhtml-purifier<0.4.3
npm/xhtml-purifier<=0.4.1
0.4.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/xhtml-purifier to a version that resolves this vulnerability.

    Fixed in 0.4.3
  2. Upgrade

    Upgrade xhtml-purifier to a version that resolves this vulnerability.

    Fixed in 0.4.3

Event History

Sep 24, 2026
CVE Published
via MITRE·05:35 PM
Data Sourced
via MITRE·05:35 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:17 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·07:33 PM
Data Sourced
via GitHub·07:33 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed to this issue?

Applications using npm/xhtml-purifier versions earlier than 0.4.3 to sanitize untrusted HTML are exposed if they render the sanitizer's output. The affected attributes include allowed attributes such as class, style, title, alt, src, and href.

2

What does an attacker need to exploit the flaw?

An attacker needs a way to supply HTML that is processed by the vulnerable sanitizer and later rendered in a browser. They can place a double quote in an allowed attribute value to escape the serialized attribute and add an event-handler attribute, such as onmouseover or onerror; execution also requires the relevant user interaction or error condition.

3

What should be done if an immediate upgrade is not possible?

The provided data identifies version 0.4.3 as the fix, which HTML-entity-encodes attribute values before serialization. No alternative mitigation is specified.

4

How can teams determine whether they are affected?

Check whether the application depends on npm/xhtml-purifier at a version earlier than 0.4.3 and uses it on attacker-controlled HTML. Review whether its sanitized output is rendered, since rendering is what enables the injected event handler to execute.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203