Advisory Database
  • Advisories
  • Dependency Scanning
  1. nuget
  2. ›
  3. HtmlSanitizer
  4. ›
  5. CVE-2026-25543

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

February 3, 2026

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: <div>[...]<template><script>alert('xss')</script> where [...] denotes at least another 509 opening <div> tags.
  2. 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.

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

References

  • developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template
  • github.com/advisories/GHSA-j92c-7v7g-gj3f
  • github.com/mganss/HtmlSanitizer
  • github.com/mganss/HtmlSanitizer/commit/0ac53dca30ddad963f2b243669a5066933d82b81
  • github.com/mganss/HtmlSanitizer/releases/tag/v9.0.892
  • github.com/mganss/HtmlSanitizer/security/advisories/GHSA-j92c-7v7g-gj3f
  • nvd.nist.gov/vuln/detail/CVE-2026-25543

Code Behaviors & Features

Detect and mitigate CVE-2026-25543 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 9.0.892, all versions starting from 9.1.878-beta before 9.1.893-beta

Fixed versions

  • 9.0.892
  • 9.1.893-beta

Solution

Upgrade to versions 9.0.892, 9.1.893-beta or above.

Impact 6.5 MEDIUM

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N

Learn more about CVSS

Weakness

  • CWE-116: Improper Encoding or Escaping of Output

Source file

nuget/HtmlSanitizer/CVE-2026-25543.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 04 Feb 2026 00:35:27 +0000.