CVE-2024-28244: KaTeX's maxExpand bypassed by Unicode sub/superscripts

Published Mar 25, 2024
·
Updated

Impact KaTeX users who render untrusted mathematical expressions could encounter malicious input using \def or \newcommand that causes a near-infinite loop, despite setting maxExpand to avoid such loops. This can be used as an availability attack, where e.g. a client rendering another user's KaTeX input will be unable to use the site due to memory overflow, tying up the main thread, or stack overflow.

Patches Upgrade to KaTeX v0.16.10 to remove this vulnerability.

Workarounds Forbid inputs containing any of the characters ₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ⁺⁻⁼⁽⁾⁰¹²³⁴⁵⁶⁷⁸⁹ᵃᵇᶜᵈᵉᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘʷˣʸᶻᵛᵝᵞᵟᵠᵡ before passing them to KaTeX. (There is no easy workaround for the auto-render extension.)

Details KaTeX supports an option named maxExpand which aims to prevent infinitely recursive macros from consuming all available memory and/or triggering a stack overflow error. Unfortunately, support for "Unicode (sub|super)script characters" allows an attacker to bypass this limit. Each sub/superscript group instantiated a separate Parser with its own limit on macro executions, without inheriting the current count of macro executions from its parent. This has been corrected in KaTeX v0.16.10.

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

Other sources

KaTeX is a JavaScript library for TeX math rendering on the web. KaTeX users who render untrusted mathematical expressions could encounter malicious input using \def or \newcommand that causes a near-infinite loop, despite setting maxExpand to avoid such loops. KaTeX supports an option named maxExpand which aims to prevent infinitely recursive macros from consuming all available memory and/or triggering a stack overflow error. Unfortunately, support for "Unicode (sub|super)script characters" allows an attacker to bypass this limit. Each sub/superscript group instantiated a separate Parser with its own limit on macro executions, without inheriting the current count of macro executions from its parent. This has been corrected in KaTeX v0.16.10.

— MITRE

Affected Software

2 affected componentsFixes available
npm/katex>=0.15.4<0.16.10
0.16.10
KaTeX KaTeX>=0.15.4<0.16.10

Event History

Mar 25, 2024
Advisory Published
via GitHub·07:38 PM
CVE Published
via MITRE·07:45 PM
Data Sourced
via MITRE·07:45 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08:15 PM
RemedyAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-28244?

CVE-2024-28244 is classified with high severity due to its potential for causing denial of service through infinite loops.

2

How do I fix CVE-2024-28244?

To fix CVE-2024-28244, upgrade KaTeX to version 0.16.10 or later.

3

Who is affected by CVE-2024-28244?

Users of KaTeX versions between 0.15.4 and 0.16.10 are affected by CVE-2024-28244.

4

What kind of attack does CVE-2024-28244 enable?

CVE-2024-28244 enables an availability attack by allowing attackers to render malicious mathematical expressions that could lead to a denial of service.

5

When was CVE-2024-28244 first reported?

CVE-2024-28244 was first reported in early 2024, affecting users of the KaTeX library.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203