Skip to main content
Vulnerability Database/CVE-2026-92106

CVE-2026-92106: LazyHTML Mutation XSS Vulnerability

CVE-2026-92106 is a mutation XSS vulnerability in dashbitco lazy_html that allows attackers to inject malicious scripts through SVG and MathML content. This post explains its technical details, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-92106 Overview

CVE-2026-92106 is a mutation cross-site scripting (mXSS) vulnerability in the lazy_html library maintained by dashbitco, an HTML parsing and serialization library used in the Elixir ecosystem. The flaw lives in LazyHTML.to_html/2 and LazyHTML.Tree.to_html/2, which decide whether to escape an element's text based solely on its tag name. A <style> or <script> element nested inside SVG or MathML foreign content is parsed with character references decoded, but is serialized as if it were an HTML raw-text element. The result is that encoded markup becomes live markup after a parse and serialize round-trip. The issue affects lazy_html versions 0.1.0 through 0.1.12 and is fixed in 0.1.13.

Critical Impact

Applications that parse untrusted HTML with lazy_html, apply element or attribute filters, and then serialize the sanitized tree for display can emit attacker-controlled script into the final document, enabling cross-site scripting [CWE-79].

Affected Products

  • dashbitco/lazy_html versions 0.1.0 through 0.1.12
  • Elixir applications that sanitize untrusted HTML with lazy_html
  • Downstream libraries wrapping LazyHTML.to_html/2 or LazyHTML.Tree.to_html/2

Discovery Timeline

  • 2026-09-25 - CVE-2026-92106 published to NVD
  • 2026-09-25 - Last updated in NVD database

Technical Details for CVE-2026-92106

Vulnerability Analysis

The vulnerability is a mutation XSS caused by inconsistent handling of foreign content between the parser and the serializer. In HTML, <style> and <script> are raw-text elements whose contents are not entity-decoded. Inside SVG or MathML foreign content, those same tag names behave as regular foreign elements, so their text content is parsed with character references decoded. lazy_html based its escape decision on the tag name alone, ignoring the namespace of the parent element.

An application that parses attacker-supplied HTML, filters the tree with element or attribute allowlists, and then serializes it will pass through a payload that no filter can observe. The payload is a plain text node, so element and attribute allowlists see nothing malicious. After serialization, the decoded text is emitted inside a <style> tag that is then re-parsed as HTML raw text, where the embedded closing tag terminates the style element and the following markup becomes live DOM.

Root Cause

The helper is_noescape_text_node in c_src/lazy_html.cpp returned true for any <style> or <script> parent, regardless of the parent's namespace. The Elixir-side serializer in lib/lazy_html/tree.ex likewise did not propagate namespace information through its serialization context. Both components treated style and script as raw-text elements globally rather than only in the HTML namespace.

Attack Vector

An attacker supplies HTML containing an SVG or MathML wrapper with a nested <style> element whose text node contains HTML-encoded markup, for example <svg><style></style><img src=x onerror=...></style></svg>. When lazy_html parses the input, the encoded sequence is decoded into literal </style><img src=x onerror=...> inside the text node. Any downstream filter inspects only elements and attributes, so the text node passes untouched. Serialization emits the text verbatim because the serializer sees a style parent, and the browser re-parses the output as raw HTML, executing the injected handler.

cpp
// Patch to c_src/lazy_html.cpp — restrict raw-text behavior to the HTML namespace
bool is_noescape_text_node(lxb_dom_node_t *node) {
  // Only HTML elements have raw text content.
  if (node->parent != NULL && node->parent->ns == LXB_NS_HTML) {
    switch (node->parent->local_name) {
    case LXB_TAG_STYLE:
    case LXB_TAG_SCRIPT:
      // ...
    }
  }
}

Source: dashbitco/lazy_html commit f32c7fd

Detection Methods for CVE-2026-92106

Indicators of Compromise

  • Rendered pages containing <svg> or <math> wrappers around <style> or <script> nodes that originated from user-submitted content.
  • HTTP request bodies or form fields with encoded sequences such as </style><img or </script> inside SVG or MathML fragments.
  • Browser Content Security Policy (CSP) reports citing inline event handlers (for example onerror, onload) injected into content that was expected to be sanitized.

Detection Strategies

  • Inventory Elixir applications and Hex dependencies for lazy_html versions earlier than 0.1.13 using mix deps.tree or mix hex.outdated.
  • Perform differential testing on the sanitization pipeline by submitting known mXSS payloads wrapped in SVG and MathML foreign content and comparing serialized output to the input.
  • Scan web application logs for user submissions containing <svg><style> or <math><style> patterns alongside HTML-encoded tag delimiters.

Monitoring Recommendations

  • Enable and alert on browser CSP violation reports, which will surface unexpected inline script execution introduced by mutation XSS.
  • Add request-body inspection rules in the web application firewall (WAF) for SVG and MathML fragments containing encoded end tags.
  • Track application logs for sanitization errors or unusually long text nodes emitted from HTML processing pipelines.

How to Mitigate CVE-2026-92106

Immediate Actions Required

  • Upgrade lazy_html to version 0.1.13 or later across all Elixir applications and transitive dependencies.
  • Audit any custom code that calls LazyHTML.to_html/2 or LazyHTML.Tree.to_html/2 on untrusted input and confirm it runs against the patched release.
  • Review historical content stores that were sanitized with vulnerable versions and re-sanitize before re-rendering.

Patch Information

The fix is delivered in lazy_html0.1.13. The native change in commit f32c7fd6223225b68bc8691c78b6d4a77972f1d5 restricts raw-text handling to parents in the HTML namespace by checking node->parent->ns == LXB_NS_HTML. The Elixir-side change propagates a namespace field through the serialization context (ctx = %{..., ns: :html}) so that foreign content is escaped during tree-to-HTML conversion. Full details are in GitHub Security Advisory GHSA-8rqp-v692-v82q and the CNA advisory.

Workarounds

  • Strip <svg> and <math> elements entirely from untrusted HTML before passing it to lazy_html for serialization.
  • Remove <style> and <script> nodes from the parsed tree regardless of namespace prior to calling to_html/2.
  • Apply a strict Content Security Policy that disallows inline scripts and inline event handlers to reduce exploitation impact until patching is complete.
bash
# Update lazy_html to the fixed release in mix.exs
# {:lazy_html, "~> 0.1.13"}
mix deps.update lazy_html
mix deps.get
mix compile

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.