NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · NuGet

CVE-2026-25543: HtmlSanitizer has a bypass via template tag

mediumCVSS 4.0 6.3GHSA-j92c-7v7g-gj3f

Impact 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: 1. it is still possible to forcibly render the contents of a tag through mutation XSS.

Published Feb 3, 2026 · Updated Feb 27, 2026

Affected packages

HtmlSanitizer

Ecosystem
NuGet
Affected
< 9.0.892
Fixed in
9.0.892
Check
dotnet list package --include-transitive

HtmlSanitizer

Ecosystem
NuGet
Affected
>= 9.1.878-beta, < 9.1.893-beta
Fixed in
9.1.893-beta
Check
dotnet list package --include-transitive

Advisory details

From the GitHub Advisory Database (CC BY 4.0).

Impact

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:

  1. 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: [...]<template><script>alert('xss')</script> where [...] denotes at least another 509 opening `` tags.
  2. If in addition to the template tag, the shadowrootmode attribute is allowed through sanitizer.AllowedAttributes.Add("shadowrootmode");, the simple payload of <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: ``, and its contents will be rendered.

Note that the default configuration is not affected because the template tag is disallowed by default.

Patches

The problem has been patched in versions 9.0.892 and 9.1.893-beta.

Workarounds

Disallow the template tag. It is disallowed by default.

Resources

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template

Credited to nsysean.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology

More NuGet vulnerabilities

All NuGet entries