CVE-2024-28245: KaTeX includegraphics improper output encoding in filename

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

KaTeX is a popular JavaScript mathematics rendering library. An attacker can inject malicious code into LaTeX math expressions using the `\includegraphics` command with unescaped filenames, causing the library to generate invalid or malicious HTML that executes arbitrary JavaScript. This affects any application that renders untrusted mathematical input with KaTeX's trust option enabled.

Technologies: katex (npm). Vendors: npm.

Quick answers

Is CVE-2024-28245 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2024-28245 being exploited in the wild.
How severe is CVE-2024-28245?
Low severity, with a CVSS score of 3.1, published 25 March 2024.
Which products and versions are affected?
katex (npm) SEMVER:introduced=0.11.0,fixed=0.16.10.
Is there a fix for CVE-2024-28245?
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-28245 attacked?
It is attacked over the network.
Am I affected by CVE-2024-28245?
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
    npm install katex@0.16.10

Technical details

The vulnerability is an output encoding flaw (CWE-116) where KaTeX's `\includegraphics` command fails to properly quote or escape the filename argument when generating HTML. An authenticated attacker (or any user in a context where the trust option is enabled) can craft malicious LaTeX input containing specially crafted filenames to break out of the HTML context and inject script tags or events. The attack requires network access and the target application to have KaTeX's trust option enabled or set to allow `\includegraphics` commands. Successful exploitation allows arbitrary JavaScript execution in the context of the victim's browser. The vulnerability was patched in KaTeX v0.16.10; users should upgrade immediately or disable the trust option and sanitize HTML output.

Affected products

  • KaTeX KaTeX >= 0.11.0, < 0.16.10

Identifiers

  • CVE-2024-28245
  • GHSA-f98w-7cxr-ff2h

Timeline

  • 2024-03-25: disclosed
  • 2024-03-25: patched: KaTeX v0.16.10 released

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.