CVE-2025-23207
JSON

6.3medium

\htmlData does not validate attribute names in KaTeX

Severity
6.3medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.41% (higher than 36% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-cg87-wmx4-v546

Description

KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. KaTeX users who render untrusted mathematical expressions with `renderToString` could encounter malicious input using `\htmlData` that runs arbitrary JavaScript, or generate invalid HTML. Users are advised to upgrade to KaTeX v0.16.21 to remove this vulnerability. Users unable to upgrade should avoid use of or turn off the `trust` option, or set it to forbid `\htmlData` commands, forbid inputs containing the substring `"\\htmlData"` and sanitize HTML output from KaTeX.

Affected

Product or packageVersionsReported by
KaTeX KaTeX>= 0.12.0, < 0.16.21, from 0.12.0 before 0.16.21CVE List, NVD
katex (npm)from 0.12.0 before 0.16.21GitHub Advisory Database

All scores

GitHub_M6.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L
GitHub6.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L
NVD7.2high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N

Classification

CWE-79CWE-116

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. KaTeX users who render untrusted mathematical expressions with `renderToString` could encounter malicious input using `\htmlData` that runs arbitrary JavaScript, or generate invalid HTML. Users are advised to upgrade to KaTeX v0.16.21 to remove this vulnerability. Users unable to upgrade should avoid use of or turn off the `trust` option, or set it to forbid `\htmlData` commands, forbid inputs containing the substring `"\\htmlData"` and sanitize HTML output from KaTeX.

GitHub Advisory Database
Impact

KaTeX users who render untrusted mathematical expressions with renderToString could encounter malicious input using \htmlData that runs arbitrary JavaScript, or generate invalid HTML.

Patches

Upgrade to KaTeX v0.16.21 to remove this vulnerability.

Workarounds
  • Avoid use of or turn off the trust option, or set it to forbid \htmlData commands.
  • Forbid inputs containing the substring "\\htmlData".
  • Sanitize HTML output from KaTeX.
Details

\htmlData did not validate its attribute name argument, allowing it to generate invalid or malicious HTML that runs scripts.

For more information

If you have any questions or comments about this advisory:

NVD (es)

KaTeX es una Librería de JavaScript rápida y fácil de usar para la representación matemática de TeX en la web. Los usuarios de KaTeX que representen expresiones matemáticas no confiables con `renderToString` podrían encontrarse con entradas maliciosas utilizando `\htmlData` que ejecutan JavaScript arbitrario o generan HTML no válido. Se recomienda a los usuarios que actualicen a KaTeX v0.16.21 para eliminar esta vulnerabilidad. Los usuarios que no puedan actualizar deben evitar el uso de la opción `trust` o desactivarla, o configurarla para prohibir los comandos `\htmlData`, prohibir las entradas que contengan la subcadena `"\\htmlData"` y la salida HTML Desinfectar de KaTeX.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-23207 changed 2025-01-17CVE Terms of Use
GitHub Advisory DatabaseGHSA-cg87-wmx4-v546 changed 2025-01-21CC-BY-4.0
NVDCVE-2025-23207 changed 2026-06-17Public domain