CVE-2026-54705: Mathlive Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-fm7p-gw32-828p
CVSS 6.3
CWE-116
Published
Advisory Summary

CVE-2026-54705 is a MODERATE (CVSS 6.3) cross-site scripting vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Mathlive libraries in the npm ecosystem. The issue involves mathlive's lack of escaping of html allows for xss. Remediation is available by upgrading affected packages to version 0.110.0.

CVE-2026-54705 at a Glance

CVE Identifier CVE-2026-54705
GHSA Identifier GHSA-fm7p-gw32-828p
Severity MODERATE
CVSS v3.1 Base Score 6.3
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Mathlive
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2026-54705

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

mathlive fixed: 0.110.0
npm install mathlive@0.110.0
Verify Direct and Transitive Dependencies

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

npm ls mathlive

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-54705, inspect your project dependencies using npm:

npm ls mathlive

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

Note: The npm ls mathlive command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

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 Mathlive, 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

### Summary Despite the 0.104.0 patch escaping attribute-bearing constructs (`\htmlData`, `\href`), text-content reflection was missed. The `\text{}`, `\mbox{}` commands accept arbitrary characters in their body and emit them raw and unescaped into both the HTML markup and the MathML output, leading to XSS. ### Details `Box.toMarkup` at `src/core/box.ts:356` concatenates `this.value` into the rendered span without HTML-escaping. In text mode any literal character (`<`, `>`, `&`, `"`) is wrapped into a `TextAtom` whose `value` is the raw codepoint and lands in the markup unchanged. The MathML serializer at `src/formats/atom-to-math-ml.ts` is independently broken: `xmlEscape` deliberately omits the `&` rule, and `scanText`, `case 'text'`, and the `mode === 'text'` early return all emit `atom.value` raw. Both outputs flow into `innerHTML` sinks via the public API. `<math-span>` / `<math-div>` (`src/public/math-static-elements.ts:331,407`) bypass `MathfieldElement.createHTML` entirely. The editor and SSR paths route through `createHTML`, but its default value is the identity function (`src/public/mathfield-element.ts:789`). ### PoC 1. Go to https://mathlive.io/mathfield/demo/ 2. open DevTools console and paste: ```js const s = document.createElement('math-span'); s.style.display = 'block'; s.textContent = '\\text{<img src=x onerror=alert(1)>}'; document.body.appendChild(s); s.scrollIntoView(); ``` Equivalent payloads: `\mbox{<img src=x onerror=alert(1)>}` or ```js import { convertLatexToMarkup } from 'mathlive'; document.body.innerHTML = convertLatexToMarkup('\\text{<img src=x onerror=alert(1)>}'); ``` ### Impact MathLive users who render untrusted mathematical expressions can encounter malicious input that runs arbitrary JavaScript.

CVE-2026-54705 Affected Mathlive Versions

1 component(s)
Fixed Versions:
0.110.0
Product / Package Ecosystem Affected Versions Fixed Version
mathlive
npm
< 0.110.0
0.110.0

References

Frequently Asked Questions

What is CVE-2026-54705?
CVE-2026-54705 is a security vulnerability in Mathlive involving mathlive's Lack of Escaping of HTML allows for XSS under CWE-116: Improper Encoding or Escaping of Output.
Which Mathlive versions are affected?
Affected versions include releases prior to 0.110.0 across affected packages: mathlive.
What version fixes CVE-2026-54705?
Upgrading to 0.110.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mathlive affected?
Yes, mathlive is affected in releases prior to 0.110.0. Upgrade your dependency to 0.110.0 or later.
What is the CVSS score of CVE-2026-54705?
CVE-2026-54705 has a CVSS v3.1 base score of 6.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2026-54705?
CVE-2026-54705 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 npm dependencies for CVE-2026-54705?
Run the dependency tree command: 'npm ls mathlive'. 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-fm7p-gw32-828p",
  "modified" : "2026-07-29T17:21:26Z",
  "published" : "2026-07-29T17:21:26Z",
  "aliases" : [ "CVE-2026-54705" ],
  "summary" : "mathlive's Lack of Escaping of HTML allows for XSS",
  "details" : "### Summary\n\nDespite the 0.104.0 patch escaping attribute-bearing constructs (`\\htmlData`, `\\href`), text-content reflection was missed. The `\\text{}`, `\\mbox{}` commands accept arbitrary characters in their body and emit them raw and unescaped into both the HTML markup and the MathML output, leading to XSS.\n\n### Details\n\n`Box.toMarkup` at `src/core/box.ts:356` concatenates `this.value` into the rendered span without HTML-escaping. In text mode any literal character (`<`, `>`, `&`, `\"`) is wrapped into a `TextAtom` whose `value` is the raw codepoint and lands in the markup unchanged. The MathML serializer at `src/formats/atom-to-math-ml.ts` is independently broken: `xmlEscape` deliberately omits the `&` rule, and `scanText`, `case 'text'`, and the `mode === 'text'` early return all emit `atom.value` raw.\n\nBoth outputs flow into `innerHTML` sinks via the public API. `<math-span>` / `<math-div>` (`src/public/math-static-elements.ts:331,407`) bypass `MathfieldElement.createHTML` entirely. The editor and SSR paths route through `createHTML`, but its default value is the identity function (`src/public/mathfield-element.ts:789`).\n\n### PoC\n\n1. Go to https://mathlive.io/mathfield/demo/\n2. open DevTools console and paste:\n\n```js\nconst s = document.createElement('math-span');\ns.style.display = 'block';\ns.textContent = '\\\\text{<img src=x onerror=alert(1)>}';\ndocument.body.appendChild(s);\ns.scrollIntoView();\n```\n\nEquivalent payloads: `\\mbox{<img src=x onerror=alert(1)>}`\n\nor\n\n```js\nimport { convertLatexToMarkup } from 'mathlive';\ndocument.body.innerHTML = convertLatexToMarkup('\\\\text{<img src=x onerror=alert(1)>}');\n```\n\n### Impact\n\nMathLive users who render untrusted mathematical expressions can encounter malicious input that runs arbitrary JavaScript.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mathlive"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.110.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.109.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/arnog/mathlive/security/advisories/GHSA-fm7p-gw32-828p"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/arnog/mathlive/issues/3028"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/arnog/mathlive/commit/5fe1c46153883f9ec0249a5c8c34e64aaae9cfb8"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/arnog/mathlive"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-29T17:21:26Z",
    "nvd_published_at" : null
  }
}