llamaCVEVulnerability Intelligence
/
Advisory · GitHub · NuGet · HtmlSanitizer

GHSA-X83R-FR5C-QQVJ

SanitizeDom(string) fails to sanitize attributes merged onto <html>/<head>/<body> wrapper elements

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS
—
low
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche a -67 d de la divulgación
Exposición18 dDesde la divulgación, 2 nov 2026, 5:47 a. m.
Detección16 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 10.0.1037-beta
Monitoreo
Detectada +1
27 ago 26
2 nov 26
19 nov 26
21 nov 26
27 ago 26
17 sept 26
9 oct 26
30 oct 26
21 nov 26
FechaFaseEventoDetalle
Remediación Parche 10.0.1037-beta HtmlSanitizer · -67 d desde divulgación
Divulgación Publicada GHSA-X83R-FR5C-QQVJ divulgada
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Impact

`HtmlSanitizer.SanitizeDom(string, string)` builds its working document by prepending a fixed wrapper to the caller's input (`"<!doctype html><html><body>" + html`) and then sanitizes starting from `dom.Body`. Per HTML5 tree-construction rules, an `<html>` or `<body>` start tag appearing in the caller's input does not create a new element — it merges its attributes onto the wrapper element that is already open. Because `DoSanitize` walks `context.QuerySelectorAll("*")`, which returns only descendants of the context element, it never inspects the context element itself (`<body>`) or anything above it (`<html>`, `<head>`). Attributes merged onto those three elements are therefore never passed to `IsAllowedAttribute` and are never stripped.

An attacker-controlled input such as:

var s = new HtmlSanitizer();
var dom = s.SanitizeDom("<body onload=alert(1)><p>hi</p>");

survives sanitization with a live `onload` handler on the returned document's `<body>` element:

<!DOCTYPE html><html><head></head><body onload="alert(1)"><p>hi</p></body></html>

Any application that calls `SanitizeDom(string)` and later serializes or renders more of the returned `IHtmlDocument` than just `dom.Body.InnerHtml`/`ChildNodes` (for example via `dom.ToHtml()`, `dom.DocumentElement.OuterHtml`, or by returning the whole document to a browser) is exposed to stored/reflected cross-site scripting (XSS): script-capable attributes (`onload`, `onerror`, etc.) and other normally-disallowed attributes can be smuggled onto the `<html>`, `<head>`, or `<body>` elements and reach the browser unsanitized.

Callers who only use `SanitizeDom(string)` output through `dom.Body.InnerHtml`, or who use the string-returning `Sanitize(string, ...)` API, are not affected.

Patches

Fixed in commit ab626e7 https://github.com/mganss/HtmlSanitizer/commit/ab626e7a4f2893f7e9ec0a72779ae19c5ec439a7: before sanitizing, `SanitizeDom(string, string)` now strips every attribute from the wrapper elements (`<html>`, `<head>`, `<body>`) that were not present in the original document, since none of those attributes can legitimately come from anywhere but the caller's input.

Users should upgrade to:

  • HtmlSanitizer 9.2.1039 https://www.nuget.org/packages/HtmlSanitizer/9.2.1039 or
  • HtmlSanitizer 10.0.1037-beta https://www.nuget.org/packages/HtmlSanitizer/10.0.1037-beta or later
Workarounds
  • Prefer `Sanitize(string html, ...)` over `SanitizeDom(string html, ...)` where possible.
  • If you must use `SanitizeDom(string, string)`, only read `dom.Body.InnerHtml` (or iterate `dom.Body.ChildNodes`) from the returned document, and never serialize or use `dom.ToHtml()`, `dom.DocumentElement`, or `dom.Head`/`dom.Body.OuterHtml`.
  • As a defense-in-depth measure, explicitly strip all attributes from `dom.DocumentElement`, `dom.Head`, and `dom.Body` immediately after calling `SanitizeDom` and before further use.
References
  • Fix commit: ab626e7a4f2893f7e9ec0a72779ae19c5ec439a7 https://github.com/mganss/HtmlSanitizer/commit/ab626e7a4f2893f7e9ec0a72779ae19c5ec439a7
  • Patched package: HtmlSanitizer 9.2.1039 on NuGet https://www.nuget.org/packages/HtmlSanitizer/9.2.1039
  • Patched package: HtmlSanitizer 10.0.1037-beta on NuGet https://www.nuget.org/packages/HtmlSanitizer/10.0.1037-beta
Versiones

Rangos afectados

Afectada Corregida Última
HtmlSanitizer< 10.0.1037-beta
10.0.1037-beta
11.0.26
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
nugetHtmlSanitizer
Corregida 10.0.1037-beta -67 d 11.0.26 no afectada
Versiones corregidas10.0.1037-beta
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/mganss/HtmlSanitizer/security/advisories/GHSA-x83r-fr5c-qqvj

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.