{"id":"CVE-2026-135775","aliases":["CVE-2026-135775","EEF-CVE-2026-135775"],"related":[],"kind":"vulnerability","state":"published","title":"Quadratic CPU consumption in mdex auto-close trimming of trailing parentheses after bare URLs","summary":"Inefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who controls rendered Markdown to cause a denial of service via a bare URL followed by many closing parentheses.\n\nWhen auto-close is active, MDEx.FragmentParser.autolink_size/2 in lib/mdex/fragment_parser.ex trims trailing ) from a bare URL one byte at a time and recounts every ( and ) in the remaining URL at each step, so a URL followed by N parentheses costs O(N²) work. Around 20 KB of input pins a scheduler for tens of seconds, and MDEx.stream/2 repeats the completion over the whole accumulated source for every chunk. No extension needs to be enabled. Rendering with auto-close disabled is not affected.\n\nThis issue affects mdex: from 0.14.2 before 0.15.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Inefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who controls rendered Markdown to cause a denial of service via a bare URL followed by many closing parentheses.\n\nWhen auto-close is active, MDEx.FragmentParser.autolink_size/2 in lib/mdex/fragment_parser.ex trims trailing ) from a bare URL one byte at a time and recounts every ( and ) in the remaining URL at each step, so a URL followed by N parentheses costs O(N²) work. Around 20 KB of input pins a scheduler for tens of seconds, and MDEx.stream/2 repeats the completion over the whole accumulated source for every chunk. No extension needs to be enabled. Rendering with auto-close disabled is not affected.\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 leandrocp mdex allows an attacker who controls rendered Markdown to cause a denial of service via a bare URL followed by many closing parentheses.\n\nWhen auto-close is active, `MDEx.FragmentParser.autolink_size/2` in `lib/mdex/fragment_parser.ex` trims trailing `)` from a bare URL one byte at a time and recounts every `(` and `)` in the remaining URL at each step, so a URL followed by N parentheses costs O(N²) work. Around 20 KB of input pins a scheduler for tens of seconds, and `MDEx.stream/2` repeats the completion over the whole accumulated source for every chunk. No extension needs to be enabled. Rendering with auto-close disabled is not affected.\n\nThis issue affects mdex: from 0.14.2 before 0.15.0.\n\n## Details\n\n**1. Reaching the trimmer.** With auto-close active, `MDEx.FragmentParser.complete/2` runs `complete_inline/3`, which calls `unmatched_suffix/1`. That masks bare URLs through `mask_urls/1` and `mask_url_spans/4`, and each URL span is measured with `autolink_text/1`. No extension needs to be enabled.\n\n**2. Quadratic trim.** `autolink_size/2` walks back from the end of the URL candidate. For every trailing `)` it takes the remaining prefix, counts all `(` and all `)` in it with `count_char/2`, and if closers outnumber openers it drops one byte and recurses. A URL followed by N `)` therefore performs N full scans of a string of length up to N, which is O(N²).\n\n**3. Amplification.** `MDEx.stream/2` re-runs completion over the whole accumulated source for every chunk, so a payload delivered over many chunks multiplies the cost. None of the entry points limits input size.\n\n## Proof of concept\n\n1. Build the input `\"http://x\"` followed by 15,000 `)` characters (about 15 KB).\n2. Render it with `MDEx.to_html!(markdown)`: it completes in a few milliseconds.\n3. Render the same input with `MDEx.to_html!(markdown, auto_close: true)`, or pass it as a single chunk to `MDEx.stream/2`: rendering takes tens of seconds and holds a scheduler for the whole time.\n4. Doubling the number of parentheses roughly quadruples the time.\n\n## Impact\n\nAn attacker who can supply Markdown, or steer LLM output, that an application renders with auto-close can pin BEAM schedulers with a few kilobytes of input per request, delaying or denying service to every other user of the node.\n\n## Workarounds\n\nRender untrusted Markdown with auto-close disabled: pass `auto_close: false` to `MDEx.stream/2`, and do not pass `auto_close: true` to `MDEx.to_html/2` or the other renderers.\n\n## Configurations\n\nThe vulnerable code runs only when auto-close is active: in `MDEx.stream/2`, where `auto_close` defaults to `true`; in `MDEx.to_html/2` and the other renderers when called with `auto_close: true`; and in `MDEx.Document` streaming buffers with `auto_close` set. Rendering with the default options of `MDEx.to_html/2` does not reach it.","format":"markdown","source":"eef"}],"published":"2026-11-30T18:45:07.891Z","modified":"2026-11-30T19:17:50.680Z","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:H/SC:N/SI:N/SA:N","score":5.9,"rating":"MEDIUM"},"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:H/SC:N/SI:N/SA:N","score":5.9,"rating":"MEDIUM"},{"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:H/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-135775.html","tags":["related","third-party-advisory","web"],"sources":["cvelist","eef","nvd"]},{"url":"https://osv.dev/vulnerability/EEF-CVE-2026-135775","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:42.936Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-135775","url":"https://www.cve.org/CVERecord?id=CVE-2026-135775","licence":"CVE Terms of Use","modified":"2026-11-30T18:59:54.741Z"},{"source":"eef","name":"Erlang Ecosystem Foundation","id":"EEF-CVE-2026-135775","url":"https://osv.dev/vulnerability/EEF-CVE-2026-135775","licence":"CC-BY-4.0","modified":"2026-11-30T19:00:03.009Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-135775","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-135775","licence":"Public domain","modified":"2026-11-30T19:17:50.680Z"}],"updatedAt":"2026-11-30T19:32:21.045Z","epss":{"score":0.00316,"percentile":0.26514,"date":"2026-12-01T12:00:22.000Z"}}