CVE-2026-129522: Quadratic rescanning in MDEx auto-close link scanner allows CPU denial of service

Published Nov 30, 2026
·
Updated

Summary

Inefficient Algorithmic Complexity vulnerability in MDEx.FragmentParser in leandrocp mdex allows an attacker who controls streamed or auto-closed Markdown to cause a denial of service through CPU exhaustion. Any application that renders untrusted Markdown with MDEx.stream/2 or the autoclose option is affected, for example live previews or streamed LLM output.

While auto-closing the last paragraph, closebracket/5 in lib/mdex/fragmentparser.ex runs an unbounded forward scan of the link tail for every ](. When that scan finds no valid link, scanning resumes just after the ], so the next ]( rescans the same tail. Each closed link also re-filters every pending image opener. Repeated [](x (, [](x(, or ![ openers in one paragraph therefore cost quadratic time, and about 100 KB of input occupies a scheduler for over ten seconds.

This issue affects mdex: from 0.14.2 before 0.15.0.

Details

1. Entry. MDEx.stream/2 (auto-close on by default) and documents with autoclose call MDEx.FragmentParser.complete/2, which reaches incompleteparagraphlink/5 and openlink/5 for the last paragraph. Scanning stops at a blank line, so an attacker who never sends one keeps the whole input in scope.

2. Rescan. For every ](, closebracket/5 calls linktail/2, which scans forward without bound through baredestination/3, linktitleend/4 and linkclose/2. When the tail is :invalid, continueafterlink/2 resumes just after the ], so the next ]( rescans the same tail. An unterminated title ( or nested parentheses ( makes every scan run to the end of the paragraph.

3. Opener filtering. Each closed link runs Enum.filter/2 over every pending opener to keep only images. With ![ repeated N times followed by N closed links, that is N filters over N openers.

All three shapes cost O(N^2). The reporter measured 120 KB of [](x ( at 12.0 s in a one-chunk MDEx.stream/2, against about 10 ms for MDEx.tohtml!/1 without auto-close.

Proof of concept

1. Build a single paragraph of 20,000 repetitions of z (about 120 KB, no blank line). 2. Pass it as one chunk to MDEx.stream/2 and consume the stream. 3. Observe the call take over ten seconds, while MDEx.tohtml!/1 on the same input returns in about 10 ms. Doubling the input roughly quadruples the time.

Impact

An attacker who can submit Markdown to a streaming or auto-closing renderer can occupy a CPU scheduler for seconds per request with about 100 KB of input, slowing or denying rendering for other users.

Configurations

The application must render untrusted Markdown with auto-closing enabled: through MDEx.stream/2, where it is on unless autoclose: false is passed, or with the autoclose option set on a document. Rendering with the default options of MDEx.tohtml/2 and MDEx.parsedocument/2 does not run the affected scanner.

Other sources

Inefficient Algorithmic Complexity vulnerability in MDEx.FragmentParser in leandrocp mdex allows an attacker who controls streamed or auto-closed Markdown to cause a denial of service through CPU exhaustion. Any application that renders untrusted Markdown with MDEx.stream/2 or the autoclose option is affected, for example live previews or streamed LLM output.

While auto-closing the last paragraph, closebracket/5 in lib/mdex/fragmentparser.ex runs an unbounded forward scan of the link tail for every ](. When that scan finds no valid link, scanning resumes just after the ], so the next ]( rescans the same tail. Each closed link also re-filters every pending image opener. Repeated [](x (, [](x(, or ![ openers in one paragraph therefore cost quadratic time, and about 100 KB of input occupies a scheduler for over ten seconds.

This issue affects mdex: from 0.14.2 before 0.15.0.

— MITRE

Affected Software

2 affected componentsFixes available
hex/mdex>=0.14.2<0.15.0
erlang/mdex>=0.14.2<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
  2. Upgrade

    Upgrade mdex to a version that resolves this vulnerability.

    Fixed in 0.15.0
  3. Configuration

    Disable auto-closing by passing auto_close: false to MDEx.stream/2 or setting auto_close: false on the document.

    MDEx.stream/2 and MDEx documents auto_close = false

Event History

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

Frequently Asked Questions

1

Which applications are realistically exposed to this denial of service?

Applications that render attacker-controlled Markdown using MDEx.stream/2 or MDEx with the auto_close option are affected. Examples include live Markdown previews and applications rendering streamed LLM output.

2

What input does an attacker need to supply?

An attacker needs control over streamed or auto-closed Markdown in a single paragraph. Repeated malformed link-like sequences such as [](x (, [](x(, or repeated ![ openers can trigger quadratic CPU consumption.

3

Are ordinary MDEx rendering configurations affected?

The issue is specifically described for MDEx.stream/2 and use of the auto_close option. The provided information does not establish that rendering paths without streamed or auto-closed Markdown are affected.

4

What versions should be remediated?

The affected range is mdex 0.14.2 through versions before 0.15.0. Upgrade to 0.15.0 or later.

5

What can be done before upgrading?

Avoid rendering untrusted Markdown through MDEx.stream/2 or with auto_close enabled where possible. Apply input-size and processing-time limits to untrusted streamed or auto-closed Markdown to reduce CPU-exhaustion risk.

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