---
title: "GHSA-cg87-wmx4-v546: KaTeX \\htmlData does not validate attribute names"
description: "Moderate severity. KaTeX \\htmlData does not validate attribute names. Affects katex; fixed in 0.16.21."
url: https://inlinr.com/advisories/GHSA-cg87-wmx4-v546
lang: en
---

[Packages](https://inlinr.com/packages) / [katex](https://inlinr.com/packages/katex) / [Security](https://inlinr.com/packages/katex/security)

Moderate Vulnerability GHSA-cg87-wmx4-v546 CVE-2025-23207 Published 17 Jan 2025

# KaTeX \\htmlData does not validate attribute names

Your version 

Affected releases · [katex](https://inlinr.com/packages/katex)

- 0.16.x 0.16.0 – 0.16.20 Fixed in 0.16.21
- 0.15.x and older 0.12.0 – 0.15.6 No fix, no longer updated

On 0.16.x, the newest line:

```
npm install katex@0.16.21
```

Every release on a timeline

1. Not affected

0.1.0 – 0.11.1  
21 releases
2. Affected

0.12.0 – 0.16.20  
55 releases
3. Fixed

0.16.21 – 0.19.1  
42 releases, latest

118 stable releases of katex, oldest to newest.

## 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 `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/ "https://github.com/KaTeX/KaTeX/")
- Email us at katex-security@mit.edu

## How it is exploited

Exploitable over the network, with a low-privilege account and no action from a user.

- **Confidentiality**: low
- **Integrity**: low
- **Availability**: low

CVSS:3.1/​AV:N/​AC:L/​PR:L/​UI:N/​S:U/​C:L/​I:L/​A:L

## References

- [Reference](https://github.com/KaTeX/KaTeX/security/advisories/GHSA-cg87-wmx4-v546 "https://github.com/KaTeX/KaTeX/security/advisories/GHSA-cg87-wmx4-v546")  
github.com/KaTeX/KaTeX/security/advisories/GHSA…
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2025-23207 "https://nvd.nist.gov/vuln/detail/CVE-2025-23207")  
nvd.nist.gov/vuln/detail/CVE-2025-23207
- [Fix commit](https://github.com/KaTeX/KaTeX/commit/ff289955e81aab89086eef09254cbf88573d415c "https://github.com/KaTeX/KaTeX/commit/ff289955e81aab89086eef09254cbf88573d415c")  
ff28995
- [Package](https://github.com/KaTeX/KaTeX "https://github.com/KaTeX/KaTeX")  
github.com/KaTeX/KaTeX

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
