Skip to content
Heist/ feed
Back to feed
Medium

DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)

Type: advisorySources: OSV

DOMPurify is a DOM-only cross-site scripting sanitizer for HTML, MathML, and SVG. Versions prior to 3.4.0 have 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. 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. This allows forbidden elements to survive sanitization with their attributes intact. Version 3.4.0 patches the issue.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2026-41240
Confirmed fixed CVEs
Not specified
Updated in this feed
3 Nov 2026, 15:54 UTC · Revision 1

Source evidence

DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)

core-osv · Original source

Published 23 Apr 2026, 14:54 UTC

DOMPurify is a DOM-only cross-site scripting sanitizer for HTML, MathML, and SVG. Versions prior to 3.4.0 have 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. 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. This allows forbidden elements to survive sanitization with their attributes intact. Version 3.4.0 patches the issue.

osv:CVE-2026-41240
Complete source record
{
  "id": "e7305661d5220115ada9618af2f25ff4de9ad21e9cb926413cf76bf7a3dfc9c6",
  "url": "https://osv.dev/vulnerability/CVE-2026-41240",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "DOMPurify: FORBID_TAGS bypassed by function-based ADD_TAGS predicate (asymmetry with FORBID_ATTR fix)",
    "summary": "DOMPurify is a DOM-only cross-site scripting sanitizer for HTML, MathML, and SVG. Versions prior to 3.4.0 have 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. 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. This allows forbidden elements to survive sanitization with their attributes intact. Version 3.4.0 patches the issue.",
    "evidence": "osv:CVE-2026-41240",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2026-41240",
      "aliases": [
        "CVE-2026-41240",
        "GHSA-h7mw-gpvr-xq4m"
      ],
      "metrics": [
        {
          "type": "CVSS_V4",
          "score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/cure53/dompurify",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "5b16e0b892e82b1779d62b9928b43c4c4ff290b9"
                },
                {
                  "fixed": "c361baa18dbdcb3344a41110f4c48ad85bf48f80"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:cure53:dompurify:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "3.4.0"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "c361baa18dbdcb3344a41110f4c48ad85bf48f80"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  },
                  {
                    "range": [
                      {
                        "fixed": "5b16e0b892e82b1779d62b9928b43c4c4ff290b9"
                      }
                    ],
                    "source": "REFERENCES_TAG",
                    "original_tag": "3.4.0"
                  }
                ]
              }
            }
          ],
          "versions": [
            "3.2.3",
            "3.1.3",
            "3.0.4",
            "2.4.3",
            "2.4.2",
            "2.4.1",
            "2.4.0",
            "2.3.12",
            "2.3.11",
            "2.3.10",
            "2.3.9",
            "2.3.8",
            "2.3.6",
            "2.3.5",
            "2.3.4",
            "2.3.3",
            "2.3.2",
            "2.3.1",
            "2.3.0",
            "2.2.9",
            "2.2.8",
            "2.2.7",
            "2.2.6",
            "2.2.4",
            "2.2.3",
            "2.2.2",
            "2.2.0",
            "2.1.1",
            "2.1.0",
            "2.0.17",
            "2.0.16",
            "2.0.15",
            "2.0.14",
            "2.0.13",
            "2.0.12",
            "2.0.11",
            "2.0.10",
            "2.0.9",
            "2.0.8",
            "2.0.6",
            "2.0.5",
            "2.0.4",
            "2.0.3",
            "2.0.2",
            "2.0.1",
            "2.0.0",
            "1.0.11",
            "1.0.10",
            "1.0.9",
            "1.0.8",
            "1.0.7",
            "1.0.6",
            "1.0.5",
            "1.0.4",
            "1.0.3",
            "1.0.2",
            "1.0.1",
            "1.0.0",
            "0.9.0",
            "0.8.9",
            "0.8.8",
            "0.8.7",
            "0.8.6",
            "0.8.5",
            "0.8.4",
            "0.8.3",
            "0.8.2",
            "0.8.1",
            "0.8.0",
            "0.7.3",
            "0.7.2",
            "0.7.1",
            "0.7.0",
            "0.6.7",
            "0.6.6",
            "0.6.5",
            "0.6.4",
            "0.6.3",
            "0.6.2",
            "0.6.1",
            "0.6.0",
            "0.4.5",
            "0.4.4",
            "0.4.3",
            "0.4.2",
            "0.4",
            "0.3",
            "v0.3",
            "0.1"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-41240.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:30.270946718Z",
      "provider": "osv",
      "references": [
        "https://github.com/cure53/DOMPurify/releases/tag/3.4.0",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/41xxx/CVE-2026-41240.json",
        "https://github.com/cure53/DOMPurify/security/advisories/GHSA-h7mw-gpvr-xq4m",
        "https://nvd.nist.gov/vuln/detail/CVE-2026-41240",
        "https://github.com/cure53/DOMPurify/commit/c361baa18dbdcb3344a41110f4c48ad85bf48f80"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-183",
          "CWE-79"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/41xxx/CVE-2026-41240.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2026-41240",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 497044,
  "published_at": "2026-04-23T14:54:32.426+00:00"
}