{"id":"CVE-2026-135699","aliases":["CVE-2026-135699","EEF-CVE-2026-135699"],"related":[],"kind":"vulnerability","state":"published","title":"Quadratic regular expression scans in MDEx auto_close text policy allow CPU denial of service","summary":"Inefficient Regular Expression Complexity vulnerability in leandrocp mdex allows an attacker to exhaust CPU via crafted unterminated link or image labels.\n\nWhen an application completes partial Markdown with the non-default auto_close: [links: :text] or auto_close: [images: :text] policy, MDEx.FragmentParser.text_label/1 in lib/mdex/fragment_parser.ex escapes the pending label with two regular expressions, \\A[^\\n]+|[^\\n]+\\z and ~{3,}\\z, that are anchored at one end only. The engine retries the unanchored alternative from every offset, so the cost grows with the square of a label line or trailing tilde run. An attacker who supplies the Markdown, such as user content or streamed LLM output, can make a single render of about 60 KB take tens of seconds of CPU. The default auto_close: true policy is not affected.\n\nThis issue affects mdex: from 0.14.3 before 0.15.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Inefficient Regular Expression Complexity vulnerability in leandrocp mdex allows an attacker to exhaust CPU via crafted unterminated link or image labels.\n\nWhen an application completes partial Markdown with the non-default auto_close: [links: :text] or auto_close: [images: :text] policy, MDEx.FragmentParser.text_label/1 in lib/mdex/fragment_parser.ex escapes the pending label with two regular expressions, \\A[^\\n]+|[^\\n]+\\z and ~{3,}\\z, that are anchored at one end only. The engine retries the unanchored alternative from every offset, so the cost grows with the square of a label line or trailing tilde run. An attacker who supplies the Markdown, such as user content or streamed LLM output, can make a single render of about 60 KB take tens of seconds of CPU. The default auto_close: true policy is not affected.\n\nThis issue affects mdex: from 0.14.3 before 0.15.0.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nInefficient Regular Expression Complexity vulnerability in leandrocp mdex allows an attacker to exhaust CPU via crafted unterminated link or image labels.\n\nWhen an application completes partial Markdown with the non-default `auto_close: [links: :text]` or `auto_close: [images: :text]` policy, `MDEx.FragmentParser.text_label/1` in `lib/mdex/fragment_parser.ex` escapes the pending label with two regular expressions, `\\A[^\\n]+|[^\\n]+\\z` and `~{3,}\\z`, that are anchored at one end only. The engine retries the unanchored alternative from every offset, so the cost grows with the square of a label line or trailing tilde run. An attacker who supplies the Markdown, such as user content or streamed LLM output, can make a single render of about 60 KB take tens of seconds of CPU. The default `auto_close: true` policy is not affected.\n\nThis issue affects mdex: from 0.14.3 before 0.15.0.\n\n## Details\n\n**1. Reaching the label.** `MDEx.FragmentParser.complete/2` (also reached through `MDEx.to_html/2` and the streaming document when `auto_close` is set) closes an unterminated link or image. Under the `:text` policy, `pending_link/3` and `complete_label/3` hand the attacker's label to `text_label/1`. The destination branch of `complete_link/4` lets the label span several lines, for example `[a`, a long middle line, then `b](htt`.\n\n**2. Quadratic matching.** `text_label/1` runs `Regex.replace` with `\\A[^\\n]+|[^\\n]+\\z`. On a middle line the first alternative cannot match and the second consumes the whole line before failing at `\\z`, and the engine repeats this from every later offset, so a line of N bytes costs about N squared steps. The trailing-tilde pass `~{3,}\\z` behaves the same way on a long run of tildes.\n\n**3. Effect.** One render occupies a scheduler for seconds: a 60 KB label took about 23 s on mdex 0.14.9, against about 11 ms with the default policy, and quadrupling the input raised the time about 18 times.\n\n## Proof of concept\n\n1. Use an application that renders untrusted Markdown with `auto_close: [links: :text]`.\n2. Submit a fragment made of `[a`, a newline, 60 000 `x` characters, a newline, and `b](htt`, leaving the link unterminated.\n3. Render it with `MDEx.to_html!/2` and those options. The call takes tens of seconds of CPU, while the same input with `auto_close: true` renders in milliseconds.\n4. Alternatively, submit `[~~~ ` followed by 40 000 `~` characters and `x](htt` to drive the trailing-tilde regex.\n\n## Impact\n\nAn attacker who controls Markdown rendered with the `:text` auto-close policy can make each render consume seconds of CPU, slowing or stalling the application under repeated requests.\n\n## Configurations\n\nThe application must render or complete attacker-influenced Markdown with the `:text` completion policy for links or images, `auto_close: [links: :text]` or `auto_close: [images: :text]`. The default `auto_close: true` policy and rendering without `auto_close` are not affected.","format":"markdown","source":"eef"}],"published":"2026-11-30T18:44:21.528Z","modified":"2026-11-30T19:17:50.153Z","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-1333"],"affected":[{"ranges":[{"type":"semver","introduced":"0.14.3","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":"359d46b344042a2feda7c768051d39b9d460b210","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.3","status":"affected","fixed":"0.15.0"}],"ecosystem":"Hex","package":"mdex","purl":"pkg:hex/mdex","source":"eef"},{"ranges":[{"type":"git","introduced":"359d46b344042a2feda7c768051d39b9d460b210","status":"affected","fixed":"2c29b28cd0473c24347aa00b95d16f9ce5f9d9af"}],"repo":"https://github.com/leandrocp/mdex","source":"eef"}],"references":[{"url":"https://cna.erlef.org/cves/CVE-2026-135699.html","tags":["related","third-party-advisory","web"],"sources":["cvelist","eef","nvd"]},{"url":"https://osv.dev/vulnerability/EEF-CVE-2026-135699","tags":["related"],"sources":["cvelist","nvd"]},{"url":"https://github.com/leandrocp/mdex/commit/359d46b344042a2feda7c768051d39b9d460b210","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-30T19:01:53.034Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-135699","url":"https://www.cve.org/CVERecord?id=CVE-2026-135699","licence":"CVE Terms of Use","modified":"2026-11-30T19:01:59.731Z"},{"source":"eef","name":"Erlang Ecosystem Foundation","id":"EEF-CVE-2026-135699","url":"https://osv.dev/vulnerability/EEF-CVE-2026-135699","licence":"CC-BY-4.0","modified":"2026-11-30T18:45:05.694Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-135699","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-135699","licence":"Public domain","modified":"2026-11-30T19:17:50.153Z"}],"updatedAt":"2026-11-30T19:32:25.756Z","epss":{"score":0.00316,"percentile":0.26515,"date":"2026-12-01T12:00:22.000Z"}}