CVE-2025-23207 \htmlData does not validate attribute names in KaTeX

Medium 6.3 Published Updated

Attackers can execute arbitrary JavaScript via malicious TeX input in KaTeX when the trust option is enabled, requiring an upgrade or configuration change.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2025-23207?

CVE-2025-23207 is a medium-severity cross-site scripting vulnerability in KaTeX, published on 17 Jan 2025. Any signed-in user can exploit it over the network, with no action from the victim.

Official 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.

Weakness: CWE-79, CWE-116

Which versions are affected by CVE-2025-23207?

2 open source packages ship an affected version, including katex. It affects 1 product.

PackageAffectedFixed in
katex npmFrom 0.12.00.16.21
katex npmFrom 0.12.00.16.21

Products include Katex Katex.

How do I fix CVE-2025-23207?

Upgrade katex to 0.16.21 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2025-23207 being exploited?

There is no known exploitation of CVE-2025-23207 in the wild and no public exploit code.

Sources

Also known as DEBIAN-CVE-2025-23207, GHSA-cg87-wmx4-v546, UBUNTU-CVE-2025-23207.

Is CVE-2025-23207 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free