Vulnerabilities in pkg:nuget/HtmlSanitizer

PACKAGE
Advisory Identifier: GHSA-j92c-7v7g-gj3f
Advisory Summary

CVE-2026-25543 is a MODERATE htmlsanitizer has a bypass vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting HtmlSanitizer libraries in the NuGet ecosystem. The issue involves htmlsanitizer has a bypass via template tag. Remediation is available by upgrading affected packages to version 9.0.892, 9.1.893-beta.

3 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:nuget/HtmlSanitizer

3 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:nuget/HtmlSanitizer. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-j92c-7v7g-gj3f CVE-2026-25543 MODERATE HtmlSanitizer has a bypass via template tag
GHSA-43cp-6p3q-2pc4 CVE-2023-44390 MODERATE HtmlSanitizer vulnerable to Cross-site Scripting in Foreign Content
GHSA-8j9v-h2vp-2hhv CVE-2020-26293 LOW XSS in HtmlSanitizer

CVE-2026-25543 at a Glance

CVE Identifier CVE-2026-25543
GHSA Identifier GHSA-j92c-7v7g-gj3f
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product HtmlSanitizer
Package Ecosystem NuGet
Published Date
Last Updated

How to Fix CVE-2026-25543

To remediate this vulnerability, upgrade all affected HtmlSanitizer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

HtmlSanitizer fixed: 9.0.892
Upgrade HtmlSanitizer to 9.0.892
HtmlSanitizer fixed: 9.1.893-beta
Upgrade HtmlSanitizer to 9.1.893-beta
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for HtmlSanitizer

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-25543, inspect your project dependencies for HtmlSanitizer:

inspect dependencies for HtmlSanitizer

Analyze the terminal output to locate any version of HtmlSanitizer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 9.0.892), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In HtmlSanitizer, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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

CVE-2026-25543 Affected HtmlSanitizer Versions

2 component(s)
Fixed Versions:
9.0.8929.1.893-beta
Product / Package Ecosystem Affected Versions Fixed Version
HtmlSanitizer
NuGet
< 9.0.892
9.0.892
HtmlSanitizer
NuGet
≥ 9.1.878-beta
< 9.1.893-beta
9.1.893-beta

References

Frequently Asked Questions

What is CVE-2026-25543?
CVE-2026-25543 is a security vulnerability in HtmlSanitizer involving HtmlSanitizer has a bypass via template tag under CWE-116: Improper Encoding or Escaping of Output.
Which HtmlSanitizer versions are affected?
Affected versions include releases prior to 9.0.892, 9.1.893-beta across affected packages: HtmlSanitizer.
What version fixes CVE-2026-25543?
Upgrading to 9.0.892, 9.1.893-beta (or the latest patched release for your respective branch) resolves the vulnerability.
Is HtmlSanitizer affected?
Yes, HtmlSanitizer is affected in releases prior to 9.0.892, 9.1.893-beta. Upgrade your dependency to 9.0.892, 9.1.893-beta or later.
What CWE is associated with CVE-2026-25543?
CVE-2026-25543 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check NuGet dependencies for CVE-2026-25543?
Run the dependency tree command: 'inspect dependencies for HtmlSanitizer'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-j92c-7v7g-gj3f",
  "modified" : "2026-02-05T00:36:50Z",
  "published" : "2026-02-03T19:22:06Z",
  "aliases" : [ "CVE-2026-25543" ],
  "summary" : "HtmlSanitizer has a bypass via template tag",
  "details" : "### Impact\n\nIf 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`. \n\nThe lack of sanitization of the template tag brings up two bypasses:\n\n1. 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.\n2. 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. \n\nNote that the default configuration is not affected because the `template` tag is disallowed by default.\n\n### Patches\n\nThe 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).\n\n### Workarounds\n\nDisallow the `template` tag. It is disallowed by default.\n\n### Resources\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "HtmlSanitizer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "9.0.892"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "HtmlSanitizer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "9.1.878-beta"
      }, {
        "fixed" : "9.1.893-beta"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mganss/HtmlSanitizer/security/advisories/GHSA-j92c-7v7g-gj3f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-25543"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mganss/HtmlSanitizer/commit/0ac53dca30ddad963f2b243669a5066933d82b81"
  }, {
    "type" : "WEB",
    "url" : "https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mganss/HtmlSanitizer"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mganss/HtmlSanitizer/releases/tag/v9.0.892"
  }, {
    "type" : "WEB",
    "url" : "https://www.nuget.org/packages/HtmlSanitizer/9.0.892"
  }, {
    "type" : "WEB",
    "url" : "https://www.nuget.org/packages/HtmlSanitizer/9.1.893-beta"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116", "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-03T19:22:06Z",
    "nvd_published_at" : "2026-02-04T22:16:00Z"
  }
}