{"id":"CVE-2026-53531","aliases":["GHSA-4w5h-hx6r-28q7"],"url":"https://o3.security/vulnerability/CVE-2026-53531","summary":"ratex-parser has unbounded parser recursion that leads to stack overflow (process abort)","details":"### 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.","published":"2026-08-21T21:34:16.017Z","modified":"2026-10-21T02:58:29.301464305Z","cvss":null,"epss":{"score":0.00309,"percentile":0.2381,"asOf":"2026-09-17"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"crates.io","name":"ratex-parser","fixedVersion":"0.1.11"}],"fix":null,"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/53xxx/CVE-2026-53531.json"},{"type":"ADVISORY","url":"https://github.com/erweixin/RaTeX/security/advisories/GHSA-4w5h-hx6r-28q7"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53531"},{"type":"PACKAGE","url":"https://github.com/erweixin/RaTeX"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-10-21T02:58:29.301464305Z"}}