Skip to content
Heist/ feed
Back to feed
Medium

KaTeX's maxExpand bypassed by Unicode sub/superscripts

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2024-28244
Confirmed fixed CVEs
Not specified
Updated in this feed
3 Nov 2026, 05:42 UTC · Revision 1

Source evidence

KaTeX's maxExpand bypassed by Unicode sub/superscripts

core-osv · Original source

Published 25 Mar 2024, 19:45 UTC

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.

osv:CVE-2024-28244
Complete source record
{
  "id": "c9a5a86503b6638e5e94aa3b72170e290bdf28a4f131bb28ad12db09480b06ca",
  "url": "https://osv.dev/vulnerability/CVE-2024-28244",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "KaTeX's maxExpand bypassed by Unicode sub/superscripts",
    "summary": "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.",
    "evidence": "osv:CVE-2024-28244",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2024-28244",
      "aliases": [
        "CVE-2024-28244",
        "GHSA-cvr6-37gx-v8wc"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/katex/katex",
              "type": "GIT",
              "events": [
                {
                  "introduced": "575dab79f1772ab524fca3ca455f903e6195cb6e"
                },
                {
                  "fixed": "ab323598fbf90a39c2c65bccd88f86b1ddfad931"
                },
                {
                  "fixed": "085e21b5da05414efefa932570e7201a7c70e5b2"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:katex:katex:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0.15.4"
                      },
                      {
                        "fixed": "0.16.10"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "085e21b5da05414efefa932570e7201a7c70e5b2"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v0.16.9",
            "v0.16.8",
            "v0.16.7",
            "v0.16.6",
            "v0.16.5",
            "v0.16.4",
            "v0.16.3",
            "v0.16.2",
            "v0.16.1",
            "v0.16.0",
            "v0.15.6",
            "v0.15.5",
            "v0.15.4"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-28244.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:26.211345284Z",
      "provider": "osv",
      "references": [
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/28xxx/CVE-2024-28244.json",
        "https://github.com/KaTeX/KaTeX/security/advisories/GHSA-cvr6-37gx-v8wc",
        "https://nvd.nist.gov/vuln/detail/CVE-2024-28244",
        "https://github.com/KaTeX/KaTeX/commit/085e21b5da05414efefa932570e7201a7c70e5b2"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-674"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/28xxx/CVE-2024-28244.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-28244",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 492791,
  "published_at": "2024-03-25T19:45:50.907+00:00"
}