CVE-2026-65903
JSON

5.1medium

DOMPurify before 3.4.0 ADD_TAGS Function Bypasses FORBID_TAGS

Severity
5.1medium CVSS:4.0 by VulnCheck
Exploit likelihood
4.13% (higher than 91% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
VulnCheck
Also known as
GHSA-39q2-94rc-95cp

Description

DOMPurify before 3.4.0 contains a logic error in the ADD_TAGS function where short-circuit evaluation allows forbidden tags to bypass FORBID_TAGS restrictions. Attackers can craft input containing tags listed in FORBID_TAGS that are also added via ADD_TAGS function, causing them to be retained in sanitized output.

Affected

Product or packageVersionsReported by
cure53 DOMPurifybefore 3.4.0
Not affected: 3.4.0
CVE List, NVD
dompurify (npm)before 3.4.0GitHub Advisory Database

All scores

VulnCheck5.1medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
VulnCheck6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

Classification

CWE-697CWE-783

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

DOMPurify before 3.4.0 contains a logic error in the ADD_TAGS function where short-circuit evaluation allows forbidden tags to bypass FORBID_TAGS restrictions. Attackers can craft input containing tags listed in FORBID_TAGS that are also added via ADD_TAGS function, causing them to be retained in sanitized output.

GitHub Advisory Database

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)

NVD (es)

DOMPurify anterior a la versión 3.4.0 contiene un error lógico en la función ADD_TAGS donde la evaluación de cortocircuito permite que las etiquetas prohibidas eludan las restricciones de FORBID_TAGS. Los atacantes pueden elaborar una entrada que contenga etiquetas listadas en FORBID_TAGS que también se añaden a través de la función ADD_TAGS, provocando que se retengan en la salida saneada.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-65903 changed 2026-07-23CVE Terms of Use
GitHub Advisory DatabaseGHSA-39q2-94rc-95cp changed 2026-09-10CC-BY-4.0
NVDCVE-2026-65903 changed 2026-10-24Public domain