# CVE-2024-28243: KaTeX maxExpand bypass via \edef token expansion

Source: https://junglewise.ai/threats/cve-2024-28243-katex-maxexpand-bypass-via-edef-token-expansion  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2024-03-25. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2024-28243 · Severity: low · CVSS 3.1 · Published 2024-03-25

KaTeX is a popular JavaScript library for rendering mathematical expressions. Attackers can craft malicious mathematical expressions using the \edef command that cause the library to enter a near-infinite loop and consume excessive memory, despite the maxExpand safety limit being configured. This can render a web application unresponsive, disrupting service for all users viewing the affected content.

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

## Quick answers

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

**How severe is CVE-2024-28243?** Low severity, with a CVSS score of 3.1, published 25 March 2024.

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

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

**How is CVE-2024-28243 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2024-28243?** 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.10 or later

  ```sh
  npm install katex@0.16.10
  ```


## Technical details

KaTeX implements a maxExpand option to prevent infinite recursion in macro expansion from consuming all memory and causing stack overflow. The vulnerability exists because maxExpand counts "a single macro expanding to any number of tokens" as one expansion unit. The \edef (expand-and-define) TeX command can exponentially multiply tokens using only a linear number of expansions—for example, by repeatedly doubling a definition. An attacker providing untrusted mathematical expressions can exploit this to bypass maxExpand protection, causing denial of service via memory overflow, main thread blocking, or stack overflow. The vulnerability requires the attacker to be able to supply rendering input to a KaTeX instance. The fix, released in KaTeX v0.16.10, counts every expanded token within \edef as a separate expansion against the maxExpand limit.

## Affected products

- KaTeX KaTeX >= v0.10.0-beta, < 0.16.10

## Identifiers

- CVE-2024-28243
- GHSA-64fm-8hw2-v72w

## Timeline

- 2024-03-25: disclosed: GHSA-64fm-8hw2-v72w published
- 2024-03-25: patched: KaTeX v0.16.10 released with fix

## References

- [https://github.com/KaTeX/KaTeX/security/advisories/GHSA-64fm-8hw2-v72w](https://github.com/KaTeX/KaTeX/security/advisories/GHSA-64fm-8hw2-v72w)

## 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 htmlData attribute name validation bypass](https://junglewise.ai/threats/cve-2025-23207-katex-htmldata-attribute-name-validation-bypass)
- [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)
