{"id":"CVE-2026-53531","aliases":["CVE-2026-53531","GHSA-4w5h-hx6r-28q7"],"related":[],"kind":"vulnerability","state":"published","title":"ratex-parser has unbounded parser recursion that leads to stack overflow (process abort)","summary":"RaTeX is a KaTeX-compatible math rendering engine written in Rust. Prior to version 0.1.11, RaTeX’s recursive-descent parser recurses one (or more) native stack frame per nesting level at `{`, `\\left`, `\\sqrt{`, `^{`, etc, with no maximum depth limit. A short, ~10 KB input of nested groups overflows the 8 MB main-thread stack and aborts the process. With `panic = \"abort\"` (`Cargo.toml:48`), and because a Rust stack overflow is always a fatal `SIGABRT` regardless of panic strategy this is an unrecoverable, whole-process denial of service reachable from a single untrusted LaTeX string. Version 0.1.11 fixes the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"RaTeX is a KaTeX-compatible math rendering engine written in Rust. Prior to version 0.1.11, RaTeX’s recursive-descent parser recurses one (or more) native stack frame per nesting level at `{`, `\\left`, `\\sqrt{`, `^{`, etc, with no maximum depth limit. A short, ~10 KB input of nested groups overflows the 8 MB main-thread stack and aborts the process. With `panic = \"abort\"` (`Cargo.toml:48`), and because a Rust stack overflow is always a fatal `SIGABRT` regardless of panic strategy this is an unrecoverable, whole-process denial of service reachable from a single untrusted LaTeX string. Version 0.1.11 fixes the issue.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n\nRaTeX’s recursive-descent parser recurses one (or more) native stack frame per nesting level at `{`, `\\left`, `\\sqrt{`, `^{`, etc, with **no maximum depth limit**. A short, ~10 KB input of nested groups overflows the 8 MB main-thread stack and aborts the process. With `panic = \"abort\"` (`Cargo.toml:48`), and because a Rust stack overflow is always a fatal `SIGABRT` regardless of panic strategy this is an unrecoverable, whole-process denial of service reachable from a single untrusted LaTeX string.\n\n### Details\n\nThe mutual recursion has no depth guard (`crates/ratex-parser/src/parser.rs`):\n\n```\nparse_expression (:113)  ->  parse_atom (:281/285)  ->  parse_group (:451)\n                                  ^                          |\n                                  |   on '{' (:459) recurse  |\n                                  +--------------------------+\n```\n\n`\\left` adds another recursive edge: `handle_left` → `parse_expression` (`crates/ratex-parser/src/functions/left_right.rs:47`). The only counters present are unrelated to depth: `leftright_depth` (a `\\right`-matching counter, `parser.rs:24`) and the macro expander’s `max_expand = 1000` (`macro_expander.rs:64`), which does **not** gate brace / `\\left` recursion (those tokens never pass through `expand_once`). There is no `recursion_limit`/depth parameter on `parse_group`, `parse_expression`, or `parse_atom`.\n\n### PoC\n\n<img width=\"1097\" height=\"158\" alt=\"image\" src=\"https://github.com/user-attachments/assets/29b837a2-c455-4cb6-a055-514b31c999c6\" />\n\n\n```\n$ python3 -c 'import sys;sys.stdout.write(\"{\"*200000+\"x\"+\"}\"*200000)' | ./target/release/parse\nthread 'main' has overflowed its stack\nfatal runtime error: stack overflow, aborting\nAborted (core dumped)            # exit 134\n```\n\n(Other nesting forms work equally, e.g. `\\left(`×N, `\\sqrt{`×N, `^{`×N.)\n\n### Impact\n\nA single small request crashes the whole RaTeX process. In a typical server-side math-rendering service this is a reliable, unauthenticated DoS; on smaller worker-thread stacks (e.g. a 512 KB async runtime thread) only a few hundred bytes of nesting are required.","format":"markdown","source":"ghsa"},{"lang":"es","text":"RaTeX es un motor de renderizado de matemáticas compatible con KaTeX escrito en Rust. Antes de la versión 0.1.11, el analizador descendente recursivo de RaTeX recurre a uno (o más) marcos de pila nativos por nivel de anidamiento en '{', '\\left', '\\sqrt{', '^{', etc., sin límite máximo de profundidad. Una entrada corta de ~10 KB de grupos anidados causa un desbordamiento de pila en la pila del hilo principal de 8 MB y aborta el proceso. Con 'panic = “abort”' ('Cargo.toml:48'), y debido a que un desbordamiento de pila de Rust es siempre un 'SIGABRT' fatal independientemente de la estrategia de pánico, esto es una denegación de servicio de proceso completo e irrecuperable alcanzable desde una única cadena LaTeX no confiable. La versión 0.1.11 corrige el problema.","source":"nvd"}],"published":"2026-07-07T23:39:30.000Z","modified":"2026-10-12T16:10:00.220Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","rating":"MEDIUM"}],"cwes":["CWE-400","CWE-674"],"affected":[{"ranges":[{"version":"< 0.1.11","status":"affected"}],"vendor":"erweixin","product":"RaTeX","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.1.11"}],"ecosystem":"crates.io","package":"ratex-parser","purl":"pkg:cargo/ratex-parser","source":"ghsa"}],"references":[{"url":"https://github.com/erweixin/RaTeX/security/advisories/GHSA-4w5h-hx6r-28q7","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/erweixin/RaTeX","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-08-25T16:51:02.684Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-53531","url":"https://www.cve.org/CVERecord?id=CVE-2026-53531","licence":"CVE Terms of Use","modified":"2026-08-25T16:51:41.853Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4w5h-hx6r-28q7","url":"https://github.com/advisories/GHSA-4w5h-hx6r-28q7","licence":"CC-BY-4.0","modified":"2026-07-07T23:56:32.234Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-53531","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53531","licence":"Public domain","modified":"2026-10-12T16:10:00.220Z"}],"updatedAt":"2026-11-25T22:59:34.846Z","epss":{"score":0.00309,"percentile":0.25646,"date":"2026-12-01T12:00:22.000Z"}}