{"id":"CVE-2026-25543","aliases":["EUVD-2026-5328","GHSA-j92c-7v7g-gj3f"],"status":"published","title":"HtmlSanitizer has a bypass via template tag","description":"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.","severity":{"version":"4.0","score":6.3,"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","level":"medium","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-11","score":0.00274,"percentile":0.19989,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-116","CWE-79"],"published":"2026-02-03T19:22:06Z","modified":"2026-10-28T02:30:48Z","fixes":[{"ecosystem":"NuGet","package":"HtmlSanitizer","fixed_in":["9.0.892","9.1.893-beta"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"NuGet","package":"HtmlSanitizer","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"9.0.892"}]}]},{"source":"ghsa","ecosystem":"NuGet","package":"HtmlSanitizer","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"9.1.878-beta"},{"fixed":"9.1.893-beta"}]}]},{"source":"osv","ecosystem":"NuGet","package":"HtmlSanitizer","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"9.0.892"}]}],"versions":["1.0.4925.29815","1.0.4927.30873","1.1.5243.28448","1.1.5297.28403","1.1.5338.17998","2.0.5449.20550","2.0.5548.24932","2.0.5595.22183","2.0.5595.30325","2.0.5623.30465","2.0.5735.24296","3.0.5781.31354-beta","3.0.66-beta","3.1.67-beta","3.1.75-beta","3.1.76","3.1.79","3.1.91","3.1.93","3.1.98","3.2.100-beta","3.2.103","3.2.105","3.2.96-beta","3.3.122-beta","3.3.125-beta","3.3.126-beta","3.3.127-beta","3.3.128-beta","3.3.129-beta","3.3.130-beta","3.3.131-beta","3.3.132-beta","3.3.142","3.3.143-beta","3.3.144-beta","3.3.145-beta","3.3.146-beta","3.3.147-beta","3.3.148-beta","3.4.152-beta","3.4.156","3.5.168-beta","3.5.169-beta","4.0.179","4.0.180","4.0.181","4.0.182","4.0.183","4.0.185","4.0.187","4.0.197","4.0.199","4.0.201","4.0.204","4.0.205","4.0.207","4.0.210","4.0.217","5.0.215-beta","5.0.218-beta","5.0.250-beta","5.0.266-beta","5.0.274-beta","5.0.298","5.0.304","5.0.310","5.0.319","5.0.331","5.0.342","5.0.343","5.0.353","5.0.355","5.0.372","5.0.376","5.0.404","6.0.409-beta","6.0.423-beta","6.0.430-beta","6.0.437","6.0.441","6.0.453","7.0.470-beta","7.0.473","7.1.475","7.1.488","7.1.509","7.1.512","7.1.542","8.0.601","8.0.645","8.0.690-beta","8.0.691-beta","8.0.692","8.0.718","8.0.723","8.0.744","8.0.746","8.0.795","8.0.811","8.0.838","8.0.843","8.0.865","8.1.717-beta","8.1.719-beta","8.1.722-beta","8.1.745-beta","8.1.747-beta","8.1.748-beta","8.1.796-beta","8.1.812-beta","8.1.839-beta","8.1.844-beta","8.1.870","9.0.873","9.0.876","9.0.881","9.0.884","9.0.886","9.0.889"]},{"source":"osv","ecosystem":"NuGet","package":"HtmlSanitizer","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"9.1.878-beta"},{"fixed":"9.1.893-beta"}]}]}],"products":[{"vendor":"htmlsanitizer_project","product":"htmlsanitizer"},{"vendor":"mganss","product":"htmlsanitizer"}],"references":[{"url":"https://github.com/mganss/HtmlSanitizer/security/advisories/GHSA-j92c-7v7g-gj3f","tags":["x_refsource_CONFIRM","Mitigation","Patch","Vendor Advisory","advisory","web"]},{"url":"https://github.com/mganss/HtmlSanitizer/commit/0ac53dca30ddad963f2b243669a5066933d82b81","tags":["x_refsource_MISC","Patch","fix","web"]},{"url":"https://www.nuget.org/packages/HtmlSanitizer/9.0.892","tags":["x_refsource_MISC","Product","Release Notes","web"]},{"url":"https://www.nuget.org/packages/HtmlSanitizer/9.1.893-beta","tags":["x_refsource_MISC","Product","Release Notes","web"]},{"url":"https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template","tags":["web"]},{"url":"https://github.com/mganss/HtmlSanitizer/releases/tag/v9.0.892","tags":["web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25543","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-j92c-7v7g-gj3f"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/25xxx/CVE-2026-25543.json","tags":["advisory"]},{"url":"https://github.com/mganss/HtmlSanitizer","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2026-25543","title":"HtmlSanitizer has a bypass via template tag","description":"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.","status":"published","published":"2026-02-04T21:45:25.665Z","modified":"2026-02-05T18:24:09.842Z","cvss":[{"version":"4.0","score":6.3,"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","level":"medium","assessor":"cna"}],"cwes":["CWE-116"],"updated_at":"2026-11-02T13:41:30.911526Z"}],"euvd":[{"id":"EUVD-2026-5328","description":"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.","status":"published","published":"2026-02-04T21:45:25Z","modified":"2026-02-05T18:24:09Z","cvss":[{"version":"4.0","score":6.3,"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","level":"medium"}],"updated_at":"2026-11-02T19:48:43.229255Z"}],"ghsa":[{"id":"GHSA-j92c-7v7g-gj3f","title":"HtmlSanitizer has a bypass via template tag","description":"### 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 `\u003ctemplate\u003e` 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 `\u003ctemplate\u003e` (which are not sanitized) to be effectively 'popped out'. An example would look like this: `\u003cdiv\u003e[...]\u003ctemplate\u003e\u003cscript\u003ealert('xss')\u003c/script\u003e` where `[...]` denotes at least another 509 opening `\u003cdiv\u003e` tags.\n2. If in addition to the template tag, the `shadowrootmode` attribute is allowed through `sanitizer.AllowedAttributes.Add(\"shadowrootmode\");`, the simple payload of `\u003cdiv\u003e\u003ctemplate shadowrootmode=\"open\"\u003e\u003cscript\u003ealert('xss')\u003c/script\u003e` would bypass the sanitizer. This is because such usage of `\u003ctemplate\u003e` attaches a shadow root to its parent: `\u003cdiv\u003e`, 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","status":"published","published":"2026-02-03T19:22:06Z","modified":"2026-02-27T20:27:34Z","cvss":[{"version":"4.0","score":6.3,"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","level":"medium"}],"cwes":["CWE-79","CWE-116"],"updated_at":"2026-11-02T14:39:28.962954Z"}],"nvd":[{"id":"CVE-2026-25543","description":"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.","status":"published","published":"2026-02-04T22:16:00.523Z","modified":"2026-06-17T10:24:49.647Z","cvss":[{"version":"4.0","score":6.3,"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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X","level":"medium","assessor":"secondary"},{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"primary"}],"cwes":["CWE-116","CWE-79"],"updated_at":"2026-11-02T14:12:05.149641Z"}],"osv":[{"id":"CVE-2026-25543","title":"HtmlSanitizer has a bypass via template tag","description":"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.","status":"published","published":"2026-02-04T21:45:25.665Z","modified":"2026-10-28T02:30:48.527251064Z","cvss":[{"version":"4.0","score":6.3,"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","level":"medium"}],"cwes":["CWE-116"],"updated_at":"2026-11-02T15:44:59.438965Z"},{"id":"GHSA-j92c-7v7g-gj3f","title":"HtmlSanitizer has a bypass via template tag","description":"### 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 `\u003ctemplate\u003e` 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 `\u003ctemplate\u003e` (which are not sanitized) to be effectively 'popped out'. An example would look like this: `\u003cdiv\u003e[...]\u003ctemplate\u003e\u003cscript\u003ealert('xss')\u003c/script\u003e` where `[...]` denotes at least another 509 opening `\u003cdiv\u003e` tags.\n2. If in addition to the template tag, the `shadowrootmode` attribute is allowed through `sanitizer.AllowedAttributes.Add(\"shadowrootmode\");`, the simple payload of `\u003cdiv\u003e\u003ctemplate shadowrootmode=\"open\"\u003e\u003cscript\u003ealert('xss')\u003c/script\u003e` would bypass the sanitizer. This is because such usage of `\u003ctemplate\u003e` attaches a shadow root to its parent: `\u003cdiv\u003e`, 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","status":"published","published":"2026-02-03T19:22:06Z","modified":"2026-02-28T06:26:27.846949Z","cvss":[{"version":"4.0","score":6.3,"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","level":"medium"}],"cwes":["CWE-116","CWE-79"],"updated_at":"2026-11-02T15:46:50.336262Z"}]}}
