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 package | Versions | Reported by |
|---|---|---|
| cure53 DOMPurify | before 3.4.0 Not affected: 3.4.0 | CVE List, NVD |
| dompurify (npm) | before 3.4.0 | GitHub Advisory Database |
All scores
| VulnCheck | 5.1medium CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N |
| VulnCheck | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| GitHub | medium CVSS:4.0 | CVSS: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
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
| https://github.com/cure53/DOMPurify/security/advisories/GHSA-39q2-94rc-95cp | exploit, third-party-advisory, vendor-advisory, web | |
| https://www.vulncheck.com/advisories/dompurify-before-add-tags-function-bypasses-forbid-tags | third-party-advisory | |
| https://github.com/cure53/DOMPurify | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-65903 changed 2026-07-23 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-39q2-94rc-95cp changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-65903 changed 2026-10-24 | Public domain |