dompurify@3.4.12

DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It runs as JavaScript and works in all modern browsers, as well as in Node.js (via jsdom). DOMPurify is written by security people who have vast background in web a

  • latest version

    3.4.18

  • latest non vulnerable version

  • first published

    12 years ago

  • latest version published

    3 days ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the dompurify package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • M
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via the _sanitizeAttributes function when PARSER_MEDIA_TYPE is set to application/xhtml+xml. In XHTML mode, transformCaseFunc is the identity function rather than stringToLowerCase, so the guard that removes attributeName attributes whose value contains href compares the preserved-case name attributeName against the lowercase literal "attributename" and never matches. An attacker can supply SVG content containing an <animate> or <set> element with attributeName="href" and a SMIL values list ending in a javascript: URI, which bypasses link filtering and executes a script in the victim's browser when the parent link is clicked.

    Note: This is only exploitable when PARSER_MEDIA_TYPE: 'application/xhtml+xml' is explicitly set and the allowlist includes animate (or set) together with attributeName.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.17 or higher.

    <3.4.17
    • H
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via _handleHookDetachedNode() in src/purify.ts when IN_PLACE mode is used with a hook that removes a node other than the hook's own node (such as a parent, ancestor, or unvisited sibling). The function only checks whether currentNode itself lost its parent, so when a hook removes currentNode.parentNode or a later sibling, the detached subtree is never walked or neutralized by DOMPurify. Event handlers on elements in that detached subtree remain armed, and handlers such as img onerror fire after sanitize() returns, resulting in DOM XSS.

    Note: This is only exploitable when IN_PLACE: true is used together with a hook (any of beforeSanitizeElements, uponSanitizeElement, afterSanitizeElements, beforeSanitizeAttributes, or afterSanitizeAttributes) that removes a node other than the hook's own node.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.17 or higher.

    <3.4.17
    • C
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via a sanitization bypass in _scrubTemplateExpressions when SAFE_FOR_TEMPLATES is enabled alongside a DOM-returning mode. The post-walk safety net _scrubTemplateExpressions (src/purify.ts:1717) recurses into <template>.content but never into attached shadow roots. An attacker who controls a DOM node carrying an attached shadow root can split a template expression (e.g. ${...}, {{...}}, or <%...%>) across text nodes separated by disallowed elements. After sanitization removes those elements, the fragments become adjacent and reconstitute a complete expression that a downstream template engine evaluates, resulting in cross-site scripting or template injection.

    Note: This is only exploitable when SAFE_FOR_TEMPLATES: true is set together with a DOM-returning mode (RETURN_DOM: true, RETURN_DOM_FRAGMENT: true, or IN_PLACE: true), and the sanitized content is fed into a downstream template evaluator.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.17 or higher.

    >=3.4.4 <3.4.17
    • H
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via a bypass in the sanitization logic that allows malicious HTML to survive the purification pass. An attacker can inject a payload into user-controlled input that DOMPurify fails to strip, resulting in arbitrary script execution in the victim's browser context.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.17 or higher.

    <3.4.17
    • L
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via a non-default configuration that allows certain literal text elements, where the LITERAL_TEXT_CLOSE regex-based closing-tag detection logic can be bypassed, allowing an attacker to inject unsanitized HTML that executes arbitrary scripts in the victim's browser. The fix removes the regex-based approach and introduces a lookupAccessor helper alongside Set-based tracking to harden element handling.

    Note: This is only exploitable when a non-default DOMPurify configuration is used; the default configuration is not affected.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.17 or higher.

    <3.4.17
    • C
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via the SAFE_FOR_TEMPLATES sanitization path when combined with a DOM-returning mode (RETURN_DOM, RETURN_DOM_FRAGMENT, or IN_PLACE). Template expressions such as {{...}}, ${...}, and <%...%> survive sanitization inside the text content of an attached shadow root, allowing an attacker to inject template payloads that are subsequently evaluated by a downstream template engine.

    Note: This is only exploitable when SAFE_FOR_TEMPLATES: true is set alongside a DOM-returning mode, a DOM node with an already-attached shadow root is passed to the sanitizer, and the resulting shadow root content is fed into a template evaluator.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.17 or higher.

    >=3.4.4 <3.4.17
    • M
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via insufficient sanitization in the HTML purification logic, allowing an attacker to inject and execute arbitrary JavaScript in a victim's browser by supplying malicious HTML input that bypasses DOMPurify's filtering.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.16 or higher.

    <3.4.16
    • M
    Cross-site Scripting (XSS)

    dompurify is a DOM-only XSS sanitizer for HTML, MathML and SVG.

    Affected versions of this package are vulnerable to Cross-site Scripting (XSS) in the IN_PLACE sanitization process when a hook removes an element, leaving its detached descendants with executable event handlers. An attacker can execute arbitrary JavaScript code in the application's origin by supplying crafted HTML that leverages this behavior. This is only exploitable if the application uses the IN_PLACE configuration along with a hook that removes a containing element.

    How to fix Cross-site Scripting (XSS)?

    Upgrade dompurify to version 3.4.13 or higher.

    <3.4.13