{"id":"CVE-2026-129522","aliases":["CVE-2026-129522","EEF-CVE-2026-129522"],"related":[],"kind":"vulnerability","state":"published","title":"Quadratic rescanning in MDEx auto-close link scanner allows CPU denial of service","summary":"Inefficient Algorithmic Complexity vulnerability in MDEx.FragmentParser in leandrocp mdex allows an attacker who controls streamed or auto-closed Markdown to cause a denial of service through CPU exhaustion. Any application that renders untrusted Markdown with MDEx.stream/2 or the auto_close option is affected, for example live previews or streamed LLM output.\n\nWhile auto-closing the last paragraph, close_bracket/5 in lib/mdex/fragment_parser.ex runs an unbounded forward scan of the link tail for every ](. When that scan finds no valid link, scanning resumes just after the ], so the next ]( rescans the same tail. Each closed link also re-filters every pending image opener. Repeated [](x (, [](x(, or ![ openers in one paragraph therefore cost quadratic time, and about 100 KB of input occupies a scheduler for over ten seconds.\n\nThis issue affects mdex: from 0.14.2 before 0.15.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Inefficient Algorithmic Complexity vulnerability in MDEx.FragmentParser in leandrocp mdex allows an attacker who controls streamed or auto-closed Markdown to cause a denial of service through CPU exhaustion. Any application that renders untrusted Markdown with MDEx.stream/2 or the auto_close option is affected, for example live previews or streamed LLM output.\n\nWhile auto-closing the last paragraph, close_bracket/5 in lib/mdex/fragment_parser.ex runs an unbounded forward scan of the link tail for every ](. When that scan finds no valid link, scanning resumes just after the ], so the next ]( rescans the same tail. Each closed link also re-filters every pending image opener. Repeated [](x (, [](x(, or ![ openers in one paragraph therefore cost quadratic time, and about 100 KB of input occupies a scheduler for over ten seconds.\n\nThis issue affects mdex: from 0.14.2 before 0.15.0.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nInefficient Algorithmic Complexity vulnerability in `MDEx.FragmentParser` in leandrocp mdex allows an attacker who controls streamed or auto-closed Markdown to cause a denial of service through CPU exhaustion. Any application that renders untrusted Markdown with `MDEx.stream/2` or the `auto_close` option is affected, for example live previews or streamed LLM output.\n\nWhile auto-closing the last paragraph, `close_bracket/5` in `lib/mdex/fragment_parser.ex` runs an unbounded forward scan of the link tail for every `](`. When that scan finds no valid link, scanning resumes just after the `]`, so the next `](` rescans the same tail. Each closed link also re-filters every pending image opener. Repeated `[](x (`, `[](x(`, or `![` openers in one paragraph therefore cost quadratic time, and about 100 KB of input occupies a scheduler for over ten seconds.\n\nThis issue affects mdex: from 0.14.2 before 0.15.0.\n\n## Details\n\n**1. Entry.** `MDEx.stream/2` (auto-close on by default) and documents with `auto_close` call `MDEx.FragmentParser.complete/2`, which reaches `incomplete_paragraph_link/5` and `open_link/5` for the last paragraph. Scanning stops at a blank line, so an attacker who never sends one keeps the whole input in scope.\n\n**2. Rescan.** For every `](`, `close_bracket/5` calls `link_tail/2`, which scans forward without bound through `bare_destination/3`, `link_title_end/4` and `link_close/2`. When the tail is `:invalid`, `continue_after_link/2` resumes just after the `]`, so the next `](` rescans the same tail. An unterminated title (`[](x (` repeated) or nested parentheses (`[](x(` repeated) makes every scan run to the end of the paragraph.\n\n**3. Opener filtering.** Each closed link runs `Enum.filter/2` over every pending opener to keep only images. With `![` repeated N times followed by N closed links, that is N filters over N openers.\n\nAll three shapes cost O(N^2). The reporter measured 120 KB of `[](x (` at 12.0 s in a one-chunk `MDEx.stream/2`, against about 10 ms for `MDEx.to_html!/1` without auto-close.\n\n## Proof of concept\n\n1. Build a single paragraph of 20,000 repetitions of `[](x (` followed by `) z` (about 120 KB, no blank line).\n2. Pass it as one chunk to `MDEx.stream/2` and consume the stream.\n3. Observe the call take over ten seconds, while `MDEx.to_html!/1` on the same input returns in about 10 ms. Doubling the input roughly quadruples the time.\n\n## Impact\n\nAn attacker who can submit Markdown to a streaming or auto-closing renderer can occupy a CPU scheduler for seconds per request with about 100 KB of input, slowing or denying rendering for other users.\n\n## Configurations\n\nThe application must render untrusted Markdown with auto-closing enabled: through `MDEx.stream/2`, where it is on unless `auto_close: false` is passed, or with the `auto_close` option set on a document. Rendering with the default options of `MDEx.to_html/2` and `MDEx.parse_document/2` does not run the affected scanner.","format":"markdown","source":"eef"}],"published":"2026-11-30T18:45:21.032Z","modified":"2026-11-30T19:17:43.437Z","severity":{"scorer":"EEF","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":2.1,"rating":"LOW"},"severities":[{"scorer":"EEF","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":2.1,"rating":"LOW"},{"scorer":"Erlang Ecosystem Foundation","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"}],"cwes":["CWE-407"],"affected":[{"ranges":[{"type":"semver","introduced":"0.14.2","fixed":"0.15.0","status":"affected"}],"vendor":"leandrocp","product":"mdex","package":"mdex","cpe":"cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*","repo":"https://github.com/leandrocp/mdex","source":"cvelist"},{"ranges":[{"type":"git","introduced":"bea359152bc1f63f3256ee86ca207151b815940d","fixed":"2c29b28cd0473c24347aa00b95d16f9ce5f9d9af","status":"affected"}],"vendor":"leandrocp","product":"mdex","package":"leandrocp/mdex","cpe":"cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*","repo":"https://github.com/leandrocp/mdex","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.14.2","status":"affected","fixed":"0.15.0"}],"ecosystem":"Hex","package":"mdex","purl":"pkg:hex/mdex","source":"eef"},{"ranges":[{"type":"git","introduced":"bea359152bc1f63f3256ee86ca207151b815940d","status":"affected","fixed":"2c29b28cd0473c24347aa00b95d16f9ce5f9d9af"}],"repo":"https://github.com/leandrocp/mdex","source":"eef"}],"references":[{"url":"https://cna.erlef.org/cves/CVE-2026-129522.html","tags":["related","third-party-advisory","web"],"sources":["cvelist","eef","nvd"]},{"url":"https://osv.dev/vulnerability/EEF-CVE-2026-129522","tags":["related"],"sources":["cvelist","nvd"]},{"url":"https://github.com/leandrocp/mdex/commit/bea359152bc1f63f3256ee86ca207151b815940d","tags":["related","web"],"sources":["cvelist","eef","nvd"]},{"url":"https://github.com/leandrocp/mdex/commit/2c29b28cd0473c24347aa00b95d16f9ce5f9d9af","tags":["fix","patch"],"sources":["cvelist","eef","nvd"]},{"url":"https://hex.pm/packages/mdex","tags":["package"],"sources":["eef"]}],"credits":["Peter Ullrich","Jonatan Männchen / EEF","Leandro Pereira"],"assigner":"EEF","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-11-30T18:59:25.419Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-129522","url":"https://www.cve.org/CVERecord?id=CVE-2026-129522","licence":"CVE Terms of Use","modified":"2026-11-30T18:59:32.097Z"},{"source":"eef","name":"Erlang Ecosystem Foundation","id":"EEF-CVE-2026-129522","url":"https://osv.dev/vulnerability/EEF-CVE-2026-129522","licence":"CC-BY-4.0","modified":"2026-11-30T19:00:03.023Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-129522","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129522","licence":"Public domain","modified":"2026-11-30T19:17:43.437Z"}],"updatedAt":"2026-11-30T19:32:18.257Z","epss":{"score":0.00316,"percentile":0.26515,"date":"2026-12-01T12:00:22.000Z"}}