CVE-2026-134915: Quadratic HTML tag tracking in MDEx.stream/2 allows CPU exhaustion via unmatched closing tags

Published Nov 30, 2026
·
Updated

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.

MDEx.stream/2 tracks open HTML tags with MDEx.FragmentParser.continuehtmlcontext/2 in lib/mdex/fragmentparser.ex. Every non-void opening tag is pushed onto an unbounded list, and closehtmltag/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 autoclose option and the render unsafe setting. MDEx.tohtml/1 and the other non-streaming entry points are not affected.

This issue affects mdex: from 0.14.0 before 0.15.0.

Details

1. Reachability. MDEx.stream/2 renders each chunk through emitstreamsource, streamsourceblocks and streamnodegroups in lib/mdex.ex. streamnodegroups calls MDEx.FragmentParser.continuehtmlcontext/2 on every parsed node, so every HtmlBlock and HtmlInline literal is scanned, whatever the autoclose and render unsafe settings are.

2. Unbounded stack. scanhtml pushes every non-void, non-self-closing opening tag onto the context list with no size limit.

3. Quadratic scan. For each closing tag, closehtmltag/2 runs Enum.splitwhile/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²).

Proof of concept

1. Build a Markdown string of <div> repeated 30,000 times followed by </b> repeated 30,000 times (270,000 bytes). 2. Render it as one chunk with MDEx.stream(autoclose: false) and run the stream. 3. Observe about 30 seconds of CPU on mdex 0.14.9, against a few milliseconds for MDEx.tohtml!/1 on the same input. Doubling the input roughly quadruples the time.

Impact

An 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.

Other sources

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.

MDEx.stream/2 tracks open HTML tags with MDEx.FragmentParser.continuehtmlcontext/2 in lib/mdex/fragmentparser.ex. Every non-void opening tag is pushed onto an unbounded list, and closehtmltag/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 autoclose option and the render unsafe setting. MDEx.tohtml/1 and the other non-streaming entry points are not affected.

This issue affects mdex: from 0.14.0 before 0.15.0.

— MITRE

Affected Software

2 affected componentsFixes available
hex/mdex>=0.14.0<0.15.0
erlang/mdex>=0.14.0<0.15.0
0.15.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade erlang/mdex to a version that resolves this vulnerability.

    Fixed in 0.15.0

Event History

Nov 30, 2026
CVE Published
via MITRE·06:43 PM
Data Sourced
via MITRE·06:43 PM
DescriptionWeakness
Data Sourced
via OSV·06:43 PM
DescriptionSeverityWeakness
Data Sourced
via OSV·06:45 PM
Affected Software
Data Sourced
via NVD·07:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which applications are exposed to this CPU-exhaustion issue?

Applications are exposed if they use mdex versions 0.14.0 through versions before 0.15.0 and pass attacker-controlled Markdown to MDEx.stream/2. MDEx.to_html/1 and other non-streaming entry points are not affected.

2

Does disabling unsafe rendering or changing auto_close prevent exploitation?

No. HTML tag tracking occurs for every HTML block and inline HTML literal regardless of the auto_close option and the render unsafe setting.

3

What input does an attacker need to provide?

The attacker needs control over Markdown processed by MDEx.stream/2. An HTML block containing many non-void opening tags followed by unmatched closing tags triggers repeated scans of the accumulated open-tag list, causing quadratic CPU consumption.

4

What can be done if upgrading is not immediately possible?

Avoid processing untrusted Markdown through MDEx.stream/2, or impose strict input-size and processing-time limits on that path. The reported behavior can keep a scheduler busy for tens of seconds with roughly 270 KB of crafted input.

5

How can we determine whether our deployment is affected?

Check whether the application uses the mdex package at version 0.14.0 or later but earlier than 0.15.0, and whether it invokes MDEx.stream/2 on untrusted or externally supplied Markdown. The issue applies to both HTML blocks and inline HTML literals.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203