CVE-2026-65899: DOMPurify before 3.4.9 Trusted Types Policy State Contamination

Published Jun 15, 2026
·
Updated

Impact

A DOMPurify instance that is reused across trust boundaries can stay bound to a previously supplied TRUSTEDTYPESPOLICY even after clearConfig() is called. A later caller that requests RETURNTRUSTEDTYPE receives a TrustedHTML object created by the old policy, not by a clean default configuration.

If the old policy is unsafe or controlled by a less-trusted integration, this turns a later "default" sanitize call into script execution at a Trusted Types sink. TRUSTEDTYPESPOLICY: null on the later call also does not clear the retained policy. dompurify-trusted-types-policy-survives-clearconfig-poc.js

Affected version

Tested against DOMPurify 3.4.8, repository commit 825e617753ac1169306a542d3174a77f717a0cf6.

Root cause

parseConfig() overwrites trustedTypesPolicy when cfg.TRUSTEDTYPESPOLICY is truthy, but the default/null path only initializes the internal policy when trustedTypesPolicy === undefined. Once a custom policy has been set, later default config parsing leaves it in place.

Relevant code:

- src/purify.ts:786-812 accepts and stores cfg.TRUSTEDTYPESPOLICY. - src/purify.ts:813-832 does not reset an existing policy when config has no policy or has TRUSTEDTYPESPOLICY: null. - src/purify.ts:2123-2125 signs the final serialized HTML with the retained policy when RETURNTRUSTEDTYPE is true. - src/purify.ts:2133-2136 clearConfig() only clears CONFIG and SETCONFIG; it does not reset trustedTypesPolicy or emptyHTML.

Local PoC

Run from the DOMPurify checkout, or set DOMPURIFYREPO:

bash node /home/dompurify-trusted-types-policy-survives-clearconfig-poc.js

Observed output:

json { "result": { "baseline": "<b>baseline</b>", "duringPolicy": "<img src=x onerror=alert(\"TTPOLICYSURVIVEDCLEARCONFIG\")>", "afterClearString": "<img src=\"x\">", "afterClearTrustedType": "[object TrustedHTML]", "afterClearTrusted": "<img src=x onerror=alert(\"TTPOLICYSURVIVEDCLEARCONFIG\")>", "afterNullTrusted": "<img src=x onerror=alert(\"TTPOLICYSURVIVEDCLEARCONFIG\")>", "mountedHTML": "<img src=\"x\" onerror=\"alert(&quot;TTPOLICYSURVIVEDCLEARCONFIG&quot;)\">" }, "dialogs": [ "TTPOLICYSURVIVEDCLEARCONFIG" ] }

The important part is the split behavior after cleanup:

- purify.clearConfig(); purify.sanitize(...); returns a normal sanitized string (<img src="x">), because the later call is not asking for a Trusted Type. - purify.clearConfig(); purify.sanitize(..., { RETURNTRUSTEDTYPE: true }); still uses the old policy and returns attacker-controlled TrustedHTML. - Passing { TRUSTEDTYPESPOLICY: null, RETURNTRUSTEDTYPE: true } also still returns attacker-controlled TrustedHTML.

Preconditions

This is a shared-instance state contamination issue. It matters when one DOMPurify instance is reused by multiple integrations, plugins, request handlers, or components with different trust levels, and a cleanup step relies on clearConfig() to restore safe defaults.

This is not a default string-input bypass. An attacker must be able to influence a prior TRUSTEDTYPESPOLICY on the reused instance, or a less-trusted integration must have installed an unsafe policy.

Severity

impact is XSS at a Trusted Types sink in applications that reuse a DOMPurify instance across trust boundaries. Attack complexity is high because exploitation depends on prior policy injection or a less-trusted integration and a later RETURNTRUSTEDTYPE sink.

Suggested fix

Make clearConfig() reset Trusted Types state as part of restoring defaults, or have parseConfig() explicitly clear trustedTypesPolicy and emptyHTML when TRUSTEDTYPESPOLICY: null is supplied.

Other sources

DOMPurify 3.0.0 before 3.4.9 does not reset the retained Trusted Types policy when clearConfig() is called, so a DOMPurify instance reused across trust boundaries stays bound to a previously supplied TRUSTEDTYPESPOLICY. A later caller that requests RETURNTRUSTEDTYPE output receives a TrustedHTML object created by the old (potentially unsafe) policy rather than a clean default, which can lead to script execution at a Trusted Types sink. Passing TRUSTEDTYPESPOLICY: null on the later call also does not clear the retained policy.

— MITRE

Affected Software

7 affected componentsFixes available
DOMPurify DOMPurify<3.4.9
Cure53 DOMPurify>=3.0.0<3.4.9
npm/dompurify<3.4.9
3.4.9
ubuntu/node-dompurify*
ubuntu/node-dompurify*
ubuntu/node-dompurify*
debian/node-dompurify<=2.4.1+dfsg+~2.4.0-2+deb12u1, <=2.4.1+dfsg+~2.4.0-2+deb12u2, <=3.1.7+dfsg+~3.0.5-2
3.4.12+dfsg-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/dompurify to a version that resolves this vulnerability.

    Fixed in 3.4.9
  2. Upgrade

    Upgrade debian/node-dompurify to a version that resolves this vulnerability.

    Fixed in 3.4.12+dfsg-1
  3. Upgrade

    Upgrade DOMPurify to a version that resolves this vulnerability.

    Fixed in 3.4.9

Event History

Jun 15, 2026
Advisory Published
via GitHub·08:12 PM
Data Sourced
via GitHub·08:12 PM
DescriptionWeaknessAffected Software
Jul 23, 2026
CVE Published
via MITRE·01:16 PM
Data Sourced
via MITRE·01:16 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·02:01 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·02:18 PM
DescriptionSeverityWeakness
Event
via NVD·02:18 PM
Jul 28, 2026
Data Sourced
via NVD·03:53 PM
RemedyAffected Software
Nov 24, 2026
Data Sourced
via OSV·02:56 PM
Affected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-65899?

CVE-2026-65899 has a medium severity rating of 6.1.

2

How do I fix CVE-2026-65899?

To fix CVE-2026-65899, upgrade DOMPurify to version 3.4.9 or later.

3

What is the impact of CVE-2026-65899?

The impact of CVE-2026-65899 is that it allows for Trusted Types policy state contamination across trust boundaries.

4

What software is affected by CVE-2026-65899?

CVE-2026-65899 affects versions of DOMPurify prior to 3.4.9.

5

When was CVE-2026-65899 published?

CVE-2026-65899 was published on July 23, 2026.

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