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.
The lack of sanitization of the template tag brings up two bypasses:
<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.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. Note that the default configuration is not affected because the template tag is disallowed by default.
The problem has been patched in versions 9.0.892 and 9.1.893-beta.
Disallow the template tag. It is disallowed by default.
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template
{
"nvd_published_at": "2026-02-04T22:16:00Z",
"cwe_ids": [
"CWE-116"
],
"severity": "MODERATE",
"github_reviewed": true,
"github_reviewed_at": "2026-02-03T19:22:06Z"
}