{"id":"GHSA-fm7p-gw32-828p","revision":"c836f0cc33b4408cadcfac9fe4baa465","records":[{"revision":"c836f0cc33b4408cadcfac9fe4baa465","observedAt":"2026-10-24T13:17:17.793+00:00","statement":{"source":"osv","id":"GHSA-fm7p-gw32-828p","aliases":["CVE-2026-54705"],"title":"mathlive's Lack of Escaping of HTML allows for XSS","description":"### 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.","state":0,"publishedAt":"2026-07-29T17:21:26+00:00","modifiedAt":"2026-07-29T17:41:44.693943+00:00","affected":[{"ecosystem":"npm","name":"mathlive","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0"},{"kind":"fixed","version":"0.110.0"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"MODERATE"}],"references":["https://github.com/arnog/mathlive/security/advisories/GHSA-fm7p-gw32-828p","https://github.com/arnog/mathlive/issues/3028","https://github.com/arnog/mathlive/commit/5fe1c46153883f9ec0249a5c8c34e64aaae9cfb8","https://github.com/arnog/mathlive"],"sourceUrl":"https://github.com/advisories/GHSA-fm7p-gw32-828p","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-fm7p-gw32-828p","identifiers":["GHSA-fm7p-gw32-828p","CVE-2026-54705"]},"retained":false,"historicalAffected":[]}],"coverage":[]}