sanitize-html XSS Vulnerability via XMP Tag Bypass (CVE-2026-44990)
sanitize-html version 2.17.3 and earlier is vulnerable to cross-site scripting (XSS) due to the improper handling of the `xmp` tag, allowing attackers to inject arbitrary HTML and JavaScript code.
The sanitize-html library, a widely used HTML sanitizer for Node.js, contains a critical cross-site scripting (XSS) vulnerability (CVE-2026-44990) affecting version 2.17.3 and earlier. The vulnerability arises from the omission of the xmp tag from the default nonTextTags list in the library’s configuration. This oversight, combined with the special handling of xmp content in the ontext handler, allows attacker-controlled content within a disallowed xmp element to be rendered as live HTML or JavaScript. The issue was identified and disclosed on May 14, 2026. Exploitation can lead to arbitrary JavaScript execution in a user’s browser, impacting applications that rely on sanitize-html for input sanitization.
Attack Chain
- The attacker crafts malicious HTML containing JavaScript code wrapped within an
<xmp>tag (e.g.,<xmp><script>alert(1)</script></xmp>). - The application utilizes
sanitize-htmlversion 2.17.3 or earlier with default settings to sanitize the malicious HTML. - Due to the omission of
xmpfrom thenonTextTagslist,sanitize-htmldoes not treat thexmptag as a container to be completely discarded. - The
ontexthandler insanitize-htmlappends the content within thexmptag directly to the output without proper escaping. - The sanitized output, still containing the unescaped JavaScript code from within the
<xmp>tag, is stored in the application’s database or displayed to other users. - When a user views the stored or displayed content, the browser renders the unescaped JavaScript code within the now-live HTML structure.
- The attacker’s JavaScript code executes in the user’s browser, potentially stealing sensitive information, performing actions on behalf of the user, or defacing the application.
Impact
This XSS vulnerability allows a remote attacker to inject arbitrary JavaScript into a user’s browser. Successful exploitation can lead to session hijacking, sensitive data theft, account takeover, and defacement of the application. Applications that rely on sanitize-html for input sanitization and render the output as trusted HTML are vulnerable. The severity is rated as critical due to the ease of exploitation and potential impact.
Recommendation
- Upgrade to
sanitize-htmlversion 2.18.0 or later, where this vulnerability is resolved. - As a temporary workaround, configure
sanitize-htmlto explicitly disallow thexmptag or to escape its content. - Deploy the Sigma rule
Detect sanitize-html XSS via XMP Tag Bypassto identify exploitation attempts (process_creation). - Review and update any existing sanitization configurations to ensure that potentially dangerous tags are properly handled.
Detection coverage 2
Detect sanitize-html XSS via XMP Tag Bypass
highDetects CVE-2026-44990 exploitation -- attempts to inject JavaScript code through the `xmp` tag using `sanitize-html` library.
Detect sanitize-html XSS via XMP Tag img Bypass
highDetects CVE-2026-44990 exploitation -- attempts to inject JavaScript code via onerror event in img tag within xmp using `sanitize-html` library.
Detection queries are available on the platform. Get full rules →