CVE-2025-23207
KaTeX \htmlData does not validate attribute names
Impact
### 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: - Open an issue or security advisory in the [KaTeX repository](https://github.com/KaTeX/KaTeX/) - Email us at [katex-security@mit.edu](mailto:katex-security@mit.edu)
Affected packages
| Ecosystem | Package | Affected | Fixed in |
|---|---|---|---|
| npm | katex | >= 0.12.0, <= 0.16.20 | 0.16.21 |
Affected products
| Vendor | Product | Affected versions |
|---|---|---|
| Katex | Katex | from 0.12.0 before 0.16.21 |