CVE-2026-113657: sanitize-html Package XSS Vulnerability via SMIL Animation Namespace-Prefix Bypass
Summary
CVE-2026-113657: sanitize-html 2.17.7 introduced animatesUrlAttribute() to block SVG animation elements (animate, animateColor, animateMotion, animateTransform, set) when their attributeName targets a URL sink like href. Affects sanitize-html versions >= 2.17.7, < 2.18.0. Fixed in 2.18.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The sanitize-html package is a widely used library in the Node.js ecosystem that allows developers to sanitize HTML content, ensuring that it is safe for use in web applications. It provides features to control which HTML tags and attributes are allowed, making it particularly useful for applications that handle user-generated content. However, a vulnerability was discovered in version 2.17.7 that affects its ability to properly sanitize SVG animations, leading to potential cross-site scripting (XSS) attacks.
Vulnerability Detail
The vulnerability arises from the introduction of the animatesUrlAttribute() function in sanitize-html 2.17.7, which was intended to block SVG animation elements targeting URL sinks. However, this protection can be bypassed when the animation element uses a namespace prefix, such as 'svg:animate'. The function fails to recognize the prefixed tag names, allowing attackers to inject JavaScript via SMIL animations. This can lead to XSS attacks, particularly when applications set allowedTags to false, which is common in rich-text editors that want to preserve SVG content.
How To Fix
Latest published version: 2.18.1 as of 23 Oct 2026
npm install sanitize-html@2.18.1
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
2.18.0
This is the first release that contains the fix.
npm install sanitize-html@2.18.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If immediate updating is not possible, a temporary workaround is to manually strip namespace prefixes from tag names in your sanitization logic. Here’s a code snippet to illustrate this:
const localTagName =
name.
toLowerCase().slice(name.lastIndexOf(':') + 1);
if (svgAnimationTags.indexOf(localTagName) === -1) { /* handle the case */ }
Conclusion
The sanitize-html package has a vulnerability that allows for XSS attacks via SMIL animations when using namespace prefixes. It is crucial to update to version 2.18.0 or later to mitigate this risk. Additionally, developers can implement workarounds until they can apply the patch.
See every vulnerability recorded for sanitize-html →
FAQ
The CVSS score of this vulnerability is 3.7, indicating a low severity level.
sanitize-html versions 2.17.7 and later are affected by this vulnerability.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. You can check your application using the Vulert playground without any signup.
This vulnerability can lead to cross-site scripting (XSS) attacks, allowing attackers to execute arbitrary JavaScript in the context of the user's browser.
Yes, you can implement a workaround by manually stripping namespace prefixes from tag names in your sanitization logic.
References
Related vulnerabilities
Recent vulnerabilities recorded for sanitize-html.