Summary
HtmlSanitizer has a bypass via template tag
Workarounds
Disallow the template tag. It is disallowed by default.
Resources
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template
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:
- 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. - If in addition to the template tag, the
shadowrootmodeattribute is allowed throughsanitizer.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.
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
The problem has been patched in versions 9.0.892 and 9.1.893-beta.
Frequently Asked Questions
- What is CVE-2026-25543? CVE-2026-25543 is a medium-severity cross-site scripting (XSS) vulnerability in HtmlSanitizer (nuget), affecting versions < 9.0.892. It is fixed in 9.0.892, 9.1.893-beta. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- Which versions of HtmlSanitizer are affected by CVE-2026-25543? HtmlSanitizer (nuget) versions < 9.0.892 is affected.
- Is there a fix for CVE-2026-25543? Yes. CVE-2026-25543 is fixed in 9.0.892, 9.1.893-beta. Upgrade to this version or later.
- Is CVE-2026-25543 exploitable, and should I be worried? Whether CVE-2026-25543 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-25543 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-25543?
- Upgrade
HtmlSanitizerto 9.0.892 or later - Upgrade
HtmlSanitizerto 9.1.893-beta or later
- Upgrade