# CVE-2025-23207: KaTeX htmlData attribute name validation bypass

Source: https://junglewise.ai/threats/cve-2025-23207-katex-htmldata-attribute-name-validation-bypass  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2025-01-17. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2025-23207 · Severity: low · CVSS 3.1 · Published 2025-01-17

KaTeX is a popular JavaScript math rendering library used to display mathematical equations in web applications. The \htmlData command in KaTeX fails to validate attribute names before generating HTML, allowing attackers who can inject untrusted mathematical expressions to create malicious HTML that executes arbitrary JavaScript or generates invalid markup in rendered output.

Technologies: [katex (npm)](https://junglewise.ai/threats/technologies/katex). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2025-23207 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2025-23207 being exploited in the wild.

**How severe is CVE-2025-23207?** Low severity, with a CVSS score of 3.1, published 17 January 2025.

**Which products and versions are affected?** katex (npm) SEMVER:introduced=0.12.0,fixed=0.16.21.

**Is there a fix for CVE-2025-23207?** Yes. katex (npm): upgrade to 0.16.21 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2025-23207 attacked?** It is attacked over the network.

**Am I affected by CVE-2025-23207?** Check whether you run katex (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- katex (npm): upgrade to 0.16.21 or later

  ```sh
  npm install katex@0.16.21
  ```


## Technical details

KaTeX's \htmlData command does not properly validate attribute name arguments before generating HTML output (CWE-116: Improper Encoding or Escaping of Output). This allows injection of malicious attributes through unvalidated input when rendering untrusted mathematical expressions via renderToString. The vulnerability impacts applications that enable the trust option and process user-controlled math expressions. An attacker can craft expressions that generate invalid or script-executing HTML attributes. The vulnerability affects versions 0.12.0 through 0.16.20 and is resolved in v0.16.21.

## Affected products

- KaTeX KaTeX 0.12.0 to 0.16.20

## Identifiers

- CVE-2025-23207
- GHSA-cg87-wmx4-v546

## Timeline

- 2025-01-17: disclosed: GHSA-cg87-wmx4-v546 published
- 2025-01-17: patched: KaTeX v0.16.21 released with fix

## References

- [https://github.com/KaTeX/KaTeX/security/advisories/GHSA-cg87-wmx4-v546](https://github.com/KaTeX/KaTeX/security/advisories/GHSA-cg87-wmx4-v546)

## Related threats

- [KaTeX prototype pollution in renderer settings](https://junglewise.ai/threats/cve-2026-103923-katex-is-a-fast-easy-to-use-javascript-library-for-tex-math)
- [KaTeX protocol normalization bypass in trust option](https://junglewise.ai/threats/cve-2024-28246-katex-protocol-normalization-bypass-in-trust-option)
- [KaTeX includegraphics improper output encoding in filename](https://junglewise.ai/threats/cve-2024-28245-katex-includegraphics-improper-output-encoding-in-filename)
- [KaTeX maxExpand bypass via Unicode sub/superscripts](https://junglewise.ai/threats/cve-2024-28244-katex-maxexpand-bypass-via-unicode-sub-superscripts)
- [KaTeX maxExpand bypass via \edef token expansion](https://junglewise.ai/threats/cve-2024-28243-katex-maxexpand-bypass-via-edef-token-expansion)
