Loading...
Skip to main content

CVE-2026-25543 — Vulnerability in HtmlSanitizer — CVE Details

MEDIUM

HtmlSanitizer has a bypass via template tag

Published February 3, 2026Updated February 28, 2026Source: osv

Summary

### 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](https://www.nuget.org/packages/HtmlSanitizer/9.0.892) and [9.1.893-beta](https://www.nuget.org/packages/HtmlSanitizer/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

Advisory Timeline

  • First published February 3, 2026 (251 days ago).
  • Last revised February 28, 2026 — 24 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

NuGet
Update HtmlSanitizer to 9.0.892 or later
dotnet add package HtmlSanitizer --version 9.0.892
NuGet
Update HtmlSanitizer to 9.1.893-beta or later
dotnet add package HtmlSanitizer --version 9.1.893-beta

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (2)

Affects 1 ecosystem: nuget (1).

PackageEcosystemAffectedFixed In
HtmlSanitizer
nuget
1.0.4925.29815, 1.0.4927.30873, 1.1.5243.28448, 1.1.5297.28403 (+116 more)9.0.892
HtmlSanitizer
nuget
All versions9.1.893-beta

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

  • CWE-116
    Improper Encoding or EscapingMITRE
  • CWE-79
    Cross-site Scripting (XSS)MITRE

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 6.6 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
—
Confidentiality
—
Integrity
—
Availability
—

CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Frequently Asked Questions

What is CVE-2026-25543?
HtmlSanitizer has a bypass via template tag This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 6.6/10).
How do I check if my project is affected by CVE-2026-25543?
CVE-2026-25543 affects HtmlSanitizer. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-25543 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
6.6

Exploitation requires specific conditions or has limited impact. Remediate within weeks.

Also Known As

GHSA-j92c-7v7g-gj3f

Related CVEs

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies