KaTeX \htmlData does not validate attribute names
Affected releases · katex
- 0.16.x0.16.0 – 0.16.20Fixed in 0.16.21
- 0.15.x and older0.12.0 – 0.15.6No fix, no longer updated
On 0.16.x, the newest line:
npm install katex@0.16.21Every release on a timeline
Not affected
0.1.0 – 0.11.1
21 releases
Affected
0.12.0 – 0.16.20
55 releases
Fixed
0.16.21 – 0.19.1
42 releases, latest
What happens
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
trustoption, or set it to forbid\htmlDatacommands.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
Email us at katex-security@mit.edu
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.