Skip to main content

Boteraser | Website and Server Security Solutions

🛡️ CVE-2026-65902 — dompurify

🟡 CVSS 6.1 — Medium ⚠️ Exploit Public CWE-501 OSV
6.1
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

DOMPurify: Hook mutation of data.allowedTags / data.allowedAttributes permanently pollutes DEFAULT_ALLOWED_TAGS / DEFAULT_ALLOWED_ATTR

# Hook mutation of data.allowedTags / data.allowedAttributes permanently pollutes DEFAULT_ALLOWED_TAGS / DEFAULT_ALLOWED_ATTR

CWE: CWE-501 (Trust Boundary Violation — hook-scoped mutation leaks to global default sets) via CWE-693 (Protection Mechanism Failure — the default allow-list is silently widened for all subsequent sanitize calls)

Summary

The data.allowedTags and data.allowedAttributes fields passed to uponSanitizeElement and uponSanitizeAttribute hooks are direct references to the library's live ALLOWED_TAGS / ALLOWED_ATTR sets. For sanitize calls that don't supply an explicit cfg.ALLOWED_TAGS / cfg.ALLOWED_ATTR array, those live sets are themselves direct references to the module-level DEFAULT_ALLOWED_TAGS / DEFAULT_ALLOWED_ATTR constants. A hook that mutates these fields — a natural-looking pattern for "allow X for this iteration" — permanently writes new entries into the default constants for the DOMPurify instance's lifetime. Every subsequent sanitize call that doesn't override the config inherits the widened defaults, so an attacker payload that uses the poisoned tag/attribute name survives sanitization. removeAllHooks(), clearConfig(), and even passing a fresh cfg: {} do not recover; only constructing a new DOMPurify instance does.

The maintainer's existing defense at src/purify.ts:696-700 explicitly clones DEFAULT_ALLOWED_TAGS before mutating it via cfg.ADD_TAGS (array form), demonstrating awareness of this exact class. The hook path remained uncovered.

Affected

  • DOMPurify ≤ 3.4.5, including main at 7996f1dc78eb8b7922388aed75d94a9f8fad9a36
  • Any application that installs a hook on uponSanitizeElement or uponSanitizeAttribute that writes to data.allowedTags[...] = true or data.allowedAttributes[...] = true and later sanitizes attacker-influenced content with default config (no explicit cfg.ALLOWED_TAGS / cfg.ALLOWED_ATTR array)

Vulnerability details

[A] — data.allowedTags is a reference to ALLOWED_TAGS

src/purify.ts:1206-1209:

```ts

_executeHooks(hooks.uponSanitizeElement, currentNode, {

tagName,

allowedTags: ALLOWED_TAGS, // [A] direct reference; hook mutation

// mutates the very ALLOWED_TAGS the

// library checks on the next element

});

```

src/purify.ts:1494-1500 (the matching attribute hook):

```ts

const hookEvent = {

attrName: '',

attrValue: '',

keepAttr: true,

allowedAttributes: ALLOWED_ATTR, // [A'] same pattern

forceKeepAttr: undefined,

};

```

[B] — ALLOWED_TAGS = DEFAULT_ALLOWED_TAGS for default-cfg sanitize calls

src/purify.ts:527-531:

```ts

ALLOWED_TAGS =

objectHasOwnProperty(cfg, 'ALLOWED_TAGS') &&

arrayIsArray(cfg.ALLOWED_TAGS)

? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc)

: DEFAULT_ALLOWED_TAGS; // [B] reference assignment; ALLOWED_TAGS

// IS the DEFAULT_ALLOWED_TAGS object

```

(The ALLOWED_ATTR = DEFAULT_ALLOWED_ATTR path at :532-536 is symmetric.)

The mismatch

A hook author who writes data.allowedTags['script'] = true reasonably expects per-call scope — the API name is *"data"*, suggesting per-event payload. But [A] makes this a direct reference, and [B] makes that reference equal to the module-level default for the common default-cfg path. The hook's mutation therefore writes to a *constant* that every subsequent default-cfg sanitize call rebinds to.

The maintainer already recognized this class for the ADD_TAGS array path — src/purify.ts:696-700:

```ts

} else if (arrayIsArray(cfg.ADD_TAGS)) {

if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {

ALLOWED_TAGS = clone(ALLOWED_TAGS); // explicitly clone DEFAULT before

// mutating to avoid this pollution

}

addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);

}

```

The same defensive clone is missing from the hook code paths.

Proof of concept

```js

// 1) fresh DOMPurify, default config — script is blocked

DOMPurify.sanitize('<svg><script>alert(1)</script></svg>');

// → "<svg></svg>"

// 2) install a hook that mutates data.allowedTags (natural-looking pattern)

DOMPurify.addHook('uponSanitizeElement', (node, data) => {

data.allowedTags['script'] = true;

});

// 3) one sanitize call WITH the hook — script survives (expected during the hook)

DOMPurify.sanitize('<svg><script>alert(1)</script></svg>');

// → "<svg><script>alert(1)</script></svg>"

// 4) remove the hook

DOMPurify.removeAllHooks();

DOMPurify.clearConfig();

// 5) sanitize attacker content with default config — POLLUTION PERSISTS

DOMPurify.sanitize('<svg><script>alert(1)</script></svg>');

// → "<svg><script>alert(1)</script></svg>" ← script survived without any hook

// 6

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. A user must be tricked into taking some action. The scope is changed, meaning a successful attack can affect components beyond the vulnerable one. Rated impact: confidentiality low, integrity low, availability none.

CVSS metrics in full

The score comes from this vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

  • Attack vector: Network — reachable from anywhere that can route to the service.
  • Attack complexity: Low — the attack works reliably, with no preparation.
  • Privileges required: None — an unauthenticated stranger can try it.
  • User interaction: Required — someone has to click, open or visit something.
  • Scope: Changed — a successful attack reaches components beyond the vulnerable one.
  • Confidentiality impact: Low — limited, and the attacker does not choose what is affected.
  • Integrity impact: Low — limited, and the attacker does not choose what is affected.
  • Availability impact: None.

Weakness class

CVE-2026-65902 is classified as CWE-501: Trust Boundary Violation. The product mixes trusted and untrusted data in the same data structure or structured message.

Affected software

CVE-2026-65902 is recorded against 1 package.

  • dompurify

Timeline and source

Published on 15 June 2026 and last revised on 7 August 2026. A public exploit is known to exist, which raises the urgency of patching considerably. A vendor advisory or fix has been published. Record sourced from OSV.

References

github.com (Web)
github.com (Package)

Other advisories for this package

dompurify has other advisories on record. If you are patching this one, these are worth checking on the same host:

Same weakness in other software

These advisories are the same class of weakness (CWE-501: Trust Boundary Violation) in other software:

Details

Severity MEDIUM
CVSS Score 6.1
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
CWE CWE-501
Public Exploit ⚠️ Yes
Source OSV
Published 2026-06-15
Updated 2026-08-20
Modified 2026-08-07

Affected Packages

Software From version Fixed in
dompurify

Exploit Protection

Are you running dompurify?

CVE-2026-65902 carries CVSS 6.1 Medium rating and a public exploit already exists. BotEraser checks your installation against this and other known CVE records, and blocks IPs associated with exploit activity.

Check My Site For CVE-2026-65902 →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.

Browse related advisories

All advisoriesCVECVE 2026