MODERATE 6.1

CVE-2026-65903

DOMPurify's ADD_TAGS function form bypasses FORBID_TAGS due to short-circuit evaluation

Description

Summary

In src/purify.ts:1117-1123, ADD_TAGS as a function (via EXTRA_ELEMENT_HANDLING.tagCheck) bypasses FORBID_TAGS due to short-circuit evaluation.

The condition:

!(tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])

When tagCheck(tagName) returns true, the entire condition is false and the element is kept — FORBID_TAGS[tagName] is never evaluated.

Inconsistency

This contradicts the attribute-side pattern at line 1214 where FORBID_ATTR explicitly wins first:

if (FORBID_ATTR[lcName]) { continue; }

For tags, FORBID should also take precedence over ADD.

Impact

Applications using both ADD_TAGS as a function and FORBID_TAGS simultaneously get unexpected behavior — forbidden tags are allowed through. Config-dependent but a genuine logic inconsistency.

Suggested Fix

Check FORBID_TAGS before tagCheck:

if (FORBID_TAGS[tagName]) { /* remove */ }
else if (tagCheck(tagName) || ALLOWED_TAGS[tagName]) { /* keep */ }

Affected Version

v3.3.3 (commit 883ac15)

Affected Maven artifacts (2)

ArtifactAffected versionsFixed in
org.mvnpm » dompurifyvia npm dompurify
< 3.4.0
3.4.0
org.webjars.npm » dompurifyvia npm dompurify
< 3.4.0
3.4.0

Blast radius

2affected artifacts
81affected versions
51dependent artifacts (est.)
1,418dependent versions

33% of the dependent artifacts (17) still pull an affected version in their latest release.

DepthDependent versions
Direct
181
2 hops
558
3 hops
429
4 hops
130
5 hops
120

Most used dependents

Computed from the dependency graph of build 20261125.2201 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.

Other ecosystems

Also affects npm (1 package) . See all on OSV