{"id":"CVE-2026-25543","aliases":["CVE-2026-25543","GHSA-j92c-7v7g-gj3f"],"related":[],"kind":"vulnerability","state":"published","title":"HtmlSanitizer has a bypass via template tag","summary":"HtmlSanitizer is a .NET library for cleaning HTML fragments and documents from constructs that can lead to XSS attacks. Prior to versions 9.0.892 and 9.1.893-beta, if the template tag is allowed, its contents are not sanitized. The template tag is a special tag that does not usually render its contents, unless the shadowrootmode attribute is set to open or closed. This issue has been patched in versions 9.0.892 and 9.1.893-beta.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"HtmlSanitizer is a .NET library for cleaning HTML fragments and documents from constructs that can lead to XSS attacks. Prior to versions 9.0.892 and 9.1.893-beta, if the template tag is allowed, its contents are not sanitized. The template tag is a special tag that does not usually render its contents, unless the shadowrootmode attribute is set to open or closed. This issue has been patched in versions 9.0.892 and 9.1.893-beta.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nIf the `template` tag is allowed, its contents are not sanitized. The `template` tag is a special tag that does not usually render its contents, unless the `shadowrootmode` attribute is set to `open` or `closed`. \n\nThe lack of sanitization of the template tag brings up two bypasses:\n\n1. it is still possible to forcibly render the contents of a `<template>` tag through mutation XSS. The DOM parsers in browsers such as Chromium have a node depth limit of 512 and tags which are beyond that depth are flattened. This in turn allows elements within `<template>` (which are not sanitized) to be effectively 'popped out'. An example would look like this: `<div>[...]<template><script>alert('xss')</script>` where `[...]` denotes at least another 509 opening `<div>` tags.\n2. If in addition to the template tag, the `shadowrootmode` attribute is allowed through `sanitizer.AllowedAttributes.Add(\"shadowrootmode\");`, the simple payload of `<div><template shadowrootmode=\"open\"><script>alert('xss')</script>` would bypass the sanitizer. This is because such usage of `<template>` attaches a shadow root to its parent: `<div>`, and its contents will be rendered. \n\nNote that the default configuration is not affected because the `template` tag is disallowed by default.\n\n### Patches\n\nThe problem has been patched in versions [9.0.892](https://www.nuget.org/packages/HtmlSanitizer/9.0.892) and [9.1.893-beta](https://www.nuget.org/packages/HtmlSanitizer/9.1.893-beta).\n\n### Workarounds\n\nDisallow the `template` tag. It is disallowed by default.\n\n### Resources\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template","format":"markdown","source":"ghsa"},{"lang":"es","text":"HtmlSanitizer es una librería.NET para limpiar fragmentos y documentos HTML de construcciones que pueden llevar a ataques XSS. Antes de las versiones 9.0.892 y 9.1.893-beta, si la etiqueta template está permitida, su contenido no se sanitiza. La etiqueta template es una etiqueta especial que normalmente no renderiza su contenido, a menos que el atributo shadowrootmode esté configurado como open o closed. Este problema ha sido parcheado en las versiones 9.0.892 y 9.1.893-beta.","source":"nvd"}],"published":"2026-02-03T19:22:06.000Z","modified":"2026-06-17T10:24:49.647Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","score":6.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","score":6.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79","CWE-116"],"affected":[{"ranges":[{"version":"< 9.0.892","status":"affected"},{"version":"< 9.1.893-beta","status":"affected"}],"vendor":"mganss","product":"HtmlSanitizer","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"9.0.892"}],"ecosystem":"NuGet","package":"HtmlSanitizer","purl":"pkg:nuget/HtmlSanitizer","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"9.1.878-beta","status":"affected","fixed":"9.1.893-beta"}],"ecosystem":"NuGet","package":"HtmlSanitizer","purl":"pkg:nuget/HtmlSanitizer","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"9.0.892"},{"status":"affected","introduced":"9.1.878","fixed":"9.1.893"}],"vendor":"htmlsanitizer_project","product":"htmlsanitizer","cpe":"cpe:2.3:a:htmlsanitizer_project:htmlsanitizer:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/mganss/HtmlSanitizer/security/advisories/GHSA-j92c-7v7g-gj3f","tags":["mitigation","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mganss/HtmlSanitizer/commit/0ac53dca30ddad963f2b243669a5066933d82b81","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.nuget.org/packages/HtmlSanitizer/9.0.892","tags":["product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.nuget.org/packages/HtmlSanitizer/9.1.893-beta","tags":["product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25543","tags":["advisory"],"sources":["ghsa"]},{"url":"https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/mganss/HtmlSanitizer","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/mganss/HtmlSanitizer/releases/tag/v9.0.892","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-02-05T18:24:02.525Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-25543","url":"https://www.cve.org/CVERecord?id=CVE-2026-25543","licence":"CVE Terms of Use","modified":"2026-02-05T18:24:09.842Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-j92c-7v7g-gj3f","url":"https://github.com/advisories/GHSA-j92c-7v7g-gj3f","licence":"CC-BY-4.0","modified":"2026-02-28T06:26:27.846Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-25543","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25543","licence":"Public domain","modified":"2026-06-17T10:24:49.647Z"}],"updatedAt":"2026-11-25T22:59:13.514Z","epss":{"score":0.00274,"percentile":0.21155,"date":"2026-12-01T12:00:22.000Z"}}