GHSA-FM7P-GW32-828P

Vulnerability from github – Published: 2026-07-29 17:21 – Updated: 2026-07-29 17:21
VLAI
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.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 0.109.2"
      },
      "package": {
        "ecosystem": "npm",
        "name": "mathlive"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.110.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-54705"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-116"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-07-29T17:21:26Z",
    "nvd_published_at": null,
    "severity": "MODERATE"
  },
  "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 (`\u003c`, `\u003e`, `\u0026`, `\"`) 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 `\u0026` rule, and `scanText`, `case \u0027text\u0027`, and the `mode === \u0027text\u0027` early return all emit `atom.value` raw.\n\nBoth outputs flow into `innerHTML` sinks via the public API. `\u003cmath-span\u003e` / `\u003cmath-div\u003e` (`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(\u0027math-span\u0027);\ns.style.display = \u0027block\u0027;\ns.textContent = \u0027\\\\text{\u003cimg src=x onerror=alert(1)\u003e}\u0027;\ndocument.body.appendChild(s);\ns.scrollIntoView();\n```\n\nEquivalent payloads: `\\mbox{\u003cimg src=x onerror=alert(1)\u003e}`\n\nor\n\n```js\nimport { convertLatexToMarkup } from \u0027mathlive\u0027;\ndocument.body.innerHTML = convertLatexToMarkup(\u0027\\\\text{\u003cimg src=x onerror=alert(1)\u003e}\u0027);\n```\n\n### Impact\n\nMathLive users who render untrusted mathematical expressions can encounter malicious input that runs arbitrary JavaScript.",
  "id": "GHSA-fm7p-gw32-828p",
  "modified": "2026-07-29T17:21:26Z",
  "published": "2026-07-29T17:21:26Z",
  "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"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L",
      "type": "CVSS_V3"
    }
  ],
  "summary": "mathlive\u0027s Lack of Escaping of HTML allows for XSS"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…

Loading…