CVE-2026-25543
JSON

6.3medium

HtmlSanitizer has a bypass via template tag

Severity
6.3medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.27% (higher than 21% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-j92c-7v7g-gj3f

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.

Affected

Product or packageVersionsReported by
mganss HtmlSanitizer< 9.0.892, < 9.1.893-betaCVE List
HtmlSanitizer (NuGet)before 9.0.892, from 9.1.878-beta before 9.1.893-betaGitHub Advisory Database
htmlsanitizer_project htmlsanitizerbefore 9.0.892, from 9.1.878 before 9.1.893NVD

All scores

GitHub_M6.3medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
NVD6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Classification

CWE-79CWE-116

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database
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: <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.

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

NVD (es)

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.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-25543 changed 2026-02-05CVE Terms of Use
GitHub Advisory DatabaseGHSA-j92c-7v7g-gj3f changed 2026-02-28CC-BY-4.0
NVDCVE-2026-25543 changed 2026-06-17Public domain