CVE-2026-134916: Quadratic CPU consumption in MDEx Quill Delta conversion of nested block quotes
Summary
Inefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who controls Markdown input to cause a denial of service through CPU exhaustion via deeply nested block quotes passed to MDEx.todelta/2.
When converting a document to a Quill Delta, MDEx.DeltaConverter.defaultconvertnode/3 in lib/mdex/deltaconverter.ex calls applyblockformat/2 for every MDEx.BlockQuote and MDEx.Alert node, and that function rewrites every op produced by the node's descendants. Conversion therefore costs the nesting depth times the number of ops inside, and the parser places no limit on block quote depth. A document of a few hundred kilobytes keeps a scheduler busy for minutes, while parsing and HTML rendering of the same input finish in milliseconds. The parsetime budget bounds only the native parse, not the conversion.
This issue affects mdex: from 0.8.3 before 0.15.0.
Details
1. Input. Comrak sets no limit on block quote depth, so a line of d > characters followed by n lazy-continuation lines produces d nested MDEx.BlockQuote nodes holding about 2n ops, in only d+2n bytes.
2. Conversion. MDEx.DeltaConverter.defaultconvertnode/3 converts each block quote's children first and then calls applyblockformat/2, which maps over every descendant op to add the blockquote attribute to newline ops. MDEx.Alert does the same with its alert attributes. Each nesting level walks and rebuilds the whole op list again, so total work is O(d·n).
3. Effect. Measured on 0.14.7, depth 2,000 with 20,000 lines (42 KB) takes 1.9 s, depth 5,000 with 50,000 lines (105 KB) takes 15 s, and depth 10,000 with 100,000 lines (210 KB) takes 172 s. Parsing and MDEx.tohtml/2 stay under about 100 ms for the same inputs. budget: [parsetime: ...] limits only the native parse: with parsetime: 1000 the 105 KB input still spent 12 s in conversion.
Proof of concept
1. Build a Markdown document of 4,000 > characters, then a and a newline, then 40,000 lines of b (about 84 KB). 2. Convert it with MDEx.todelta!(markdown, budget: [parsetime: 1000]). 3. Observe that the call takes several seconds (9.4 s on 0.14.9), while MDEx.tohtml!/1 on the same input finishes in about 16 ms. Doubling depth and line count roughly quadruples the conversion time.
Impact
An unauthenticated attacker who can submit Markdown to an application that converts it with MDEx.todelta/2 can occupy BEAM schedulers for minutes per small request, degrading or denying service to every other user of the node while the attack continues.
Other sources
Inefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who controls Markdown input to cause a denial of service through CPU exhaustion via deeply nested block quotes passed to MDEx.todelta/2.
When converting a document to a Quill Delta, MDEx.DeltaConverter.defaultconvertnode/3 in lib/mdex/deltaconverter.ex calls applyblockformat/2 for every MDEx.BlockQuote and MDEx.Alert node, and that function rewrites every op produced by the node's descendants. Conversion therefore costs the nesting depth times the number of ops inside, and the parser places no limit on block quote depth. A document of a few hundred kilobytes keeps a scheduler busy for minutes, while parsing and HTML rendering of the same input finish in milliseconds. The parsetime budget bounds only the native parse, not the conversion.
This issue affects mdex: from 0.8.3 before 0.15.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
erlang/mdexto a version that resolves this vulnerability.Fixed in 0.15.0 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 0.15.0
Event History
Frequently Asked Questions
Who is exposed to this vulnerability?
Applications using mdex versions 0.8.3 through versions before 0.15.0 are exposed if they convert attacker-controlled Markdown to a Quill Delta with MDEx.to_delta/2. Parsing the Markdown or rendering it as HTML alone does not exhibit the described CPU cost.
What does an attacker need to do to trigger the denial of service?
An attacker needs to supply Markdown containing deeply nested block quotes that is passed to MDEx.to_delta/2. The parser does not limit block quote nesting depth, allowing a document of a few hundred kilobytes to keep a scheduler busy for minutes.
Does the parse_time budget mitigate this issue?
No. The parse_time budget limits only native parsing, while the excessive CPU consumption occurs during Quill Delta conversion.
What versions should be remediated?
Upgrade mdex to 0.15.0 or later. The affected range begins at 0.8.3 and includes all versions before 0.15.0.