{"id":"CVE-2026-134915","aliases":["CVE-2026-134915","EEF-CVE-2026-134915"],"related":[],"kind":"vulnerability","state":"published","title":"Quadratic HTML tag tracking in MDEx.stream/2 allows CPU exhaustion via unmatched closing tags","summary":"Inefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who controls Markdown passed to MDEx.stream/2 to exhaust CPU via unmatched HTML closing tags.\n\nMDEx.stream/2 tracks open HTML tags with MDEx.FragmentParser.continue_html_context/2 in lib/mdex/fragment_parser.ex. Every non-void opening tag is pushed onto an unbounded list, and close_html_tag/2 scans the whole list for each closing tag. A closer with no matching opener leaves the list unchanged, so the next closer scans it again. An HTML block of N openers followed by N unmatched closers therefore costs O(N²), and about 270 KB of input keeps a scheduler busy for tens of seconds. The tracking runs on every HTML block and inline HTML literal regardless of the auto_close option and the render unsafe setting. MDEx.to_html/1 and the other non-streaming entry points are not affected.\n\nThis issue affects mdex: from 0.14.0 before 0.15.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Inefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who controls Markdown passed to MDEx.stream/2 to exhaust CPU via unmatched HTML closing tags.\n\nMDEx.stream/2 tracks open HTML tags with MDEx.FragmentParser.continue_html_context/2 in lib/mdex/fragment_parser.ex. Every non-void opening tag is pushed onto an unbounded list, and close_html_tag/2 scans the whole list for each closing tag. A closer with no matching opener leaves the list unchanged, so the next closer scans it again. An HTML block of N openers followed by N unmatched closers therefore costs O(N²), and about 270 KB of input keeps a scheduler busy for tens of seconds. The tracking runs on every HTML block and inline HTML literal regardless of the auto_close option and the render unsafe setting. MDEx.to_html/1 and the other non-streaming entry points are not affected.\n\nThis issue affects mdex: from 0.14.0 before 0.15.0.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nInefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who controls Markdown passed to `MDEx.stream/2` to exhaust CPU via unmatched HTML closing tags.\n\n`MDEx.stream/2` tracks open HTML tags with `MDEx.FragmentParser.continue_html_context/2` in `lib/mdex/fragment_parser.ex`. Every non-void opening tag is pushed onto an unbounded list, and `close_html_tag/2` scans the whole list for each closing tag. A closer with no matching opener leaves the list unchanged, so the next closer scans it again. An HTML block of N openers followed by N unmatched closers therefore costs O(N²), and about 270 KB of input keeps a scheduler busy for tens of seconds. The tracking runs on every HTML block and inline HTML literal regardless of the `auto_close` option and the render `unsafe` setting. `MDEx.to_html/1` and the other non-streaming entry points are not affected.\n\nThis issue affects mdex: from 0.14.0 before 0.15.0.\n\n## Details\n\n**1. Reachability.** `MDEx.stream/2` renders each chunk through `emit_stream_source`, `stream_source_blocks` and `stream_node_groups` in `lib/mdex.ex`. `stream_node_groups` calls `MDEx.FragmentParser.continue_html_context/2` on every parsed node, so every `HtmlBlock` and `HtmlInline` literal is scanned, whatever the `auto_close` and render `unsafe` settings are.\n\n**2. Unbounded stack.** `scan_html` pushes every non-void, non-self-closing opening tag onto the context list with no size limit.\n\n**3. Quadratic scan.** For each closing tag, `close_html_tag/2` runs `Enum.split_while/2` over the whole list. When no matching opener exists, it returns the list unchanged, so every following unmatched closer walks the full list again. N openers followed by N unmatched closers cost O(N²).\n\n## Proof of concept\n\n1. Build a Markdown string of `<div>` repeated 30,000 times followed by `</b>` repeated 30,000 times (270,000 bytes).\n2. Render it as one chunk with `MDEx.stream(auto_close: false)` and run the stream.\n3. Observe about 30 seconds of CPU on mdex 0.14.9, against a few milliseconds for `MDEx.to_html!/1` on the same input. Doubling the input roughly quadruples the time.\n\n## Impact\n\nAn attacker who can submit Markdown that an application renders with `MDEx.stream/2` can tie up a BEAM scheduler for tens of seconds per request, and a few concurrent requests stall the node.","format":"markdown","source":"eef"}],"published":"2026-11-30T18:43:11.147Z","modified":"2026-11-30T19:17:47.130Z","severity":{"scorer":"EEF","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"EEF","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},{"scorer":"Erlang Ecosystem Foundation","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"}],"cwes":["CWE-407"],"affected":[{"ranges":[{"type":"semver","introduced":"0.14.0","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":"a88793cb0fc5caf75bf878b92c64d36817824765","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.0","status":"affected","fixed":"0.15.0"}],"ecosystem":"Hex","package":"mdex","purl":"pkg:hex/mdex","source":"eef"},{"ranges":[{"type":"git","introduced":"a88793cb0fc5caf75bf878b92c64d36817824765","status":"affected","fixed":"2c29b28cd0473c24347aa00b95d16f9ce5f9d9af"}],"repo":"https://github.com/leandrocp/mdex","source":"eef"}],"references":[{"url":"https://cna.erlef.org/cves/CVE-2026-134915.html","tags":["related","third-party-advisory","web"],"sources":["cvelist","eef","nvd"]},{"url":"https://osv.dev/vulnerability/EEF-CVE-2026-134915","tags":["related"],"sources":["cvelist","nvd"]},{"url":"https://github.com/leandrocp/mdex/commit/a88793cb0fc5caf75bf878b92c64d36817824765","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","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-134915","url":"https://www.cve.org/CVERecord?id=CVE-2026-134915","licence":"CVE Terms of Use","modified":"2026-11-30T18:43:11.147Z"},{"source":"eef","name":"Erlang Ecosystem Foundation","id":"EEF-CVE-2026-134915","url":"https://osv.dev/vulnerability/EEF-CVE-2026-134915","licence":"CC-BY-4.0","modified":"2026-11-30T18:45:05.746Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-134915","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-134915","licence":"Public domain","modified":"2026-11-30T19:17:47.130Z"}],"updatedAt":"2026-11-30T19:32:42.472Z","epss":{"score":0.00316,"percentile":0.26515,"date":"2026-12-01T12:00:22.000Z"}}