GHSA-fm7p-gw32-828p

Suggest an improvement
Source
https://github.com/advisories/GHSA-fm7p-gw32-828p
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-fm7p-gw32-828p/GHSA-fm7p-gw32-828p.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-fm7p-gw32-828p
Aliases
Published
2026-07-29T17:21:26Z
Modified
2026-07-29T17:41:44Z
Severity
  • 6.3 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L CVSS Calculator
Summary
mathlive's Lack of Escaping of HTML allows for XSS
Details

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

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.

Database specific
{
    "cwe_ids":  [
        "CWE-116"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-07-29T17:21:26Z",
    "nvd_published_at":  null,
    "severity":  "MODERATE"
}
References

Affected packages

npm / mathlive

Package

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
0.110.0

Database specific

last_known_affected_version_range
"<= 0.109.2"
source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-fm7p-gw32-828p/GHSA-fm7p-gw32-828p.json"