CVE-2026-135699: Quadratic regular expression scans in MDEx auto_close text policy allow CPU denial of service

Published Nov 30, 2026
·
Updated

Summary

Inefficient Regular Expression Complexity vulnerability in leandrocp mdex allows an attacker to exhaust CPU via crafted unterminated link or image labels.

When an application completes partial Markdown with the non-default autoclose: [links: :text] or autoclose: [images: :text] policy, MDEx.FragmentParser.textlabel/1 in lib/mdex/fragmentparser.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 autoclose: true policy is not affected.

This issue affects mdex: from 0.14.3 before 0.15.0.

Details

1. Reaching the label. MDEx.FragmentParser.complete/2 (also reached through MDEx.tohtml/2 and the streaming document when autoclose is set) closes an unterminated link or image. Under the :text policy, pendinglink/3 and completelabel/3 hand the attacker's label to textlabel/1. The destination branch of completelink/4 lets the label span several lines, for example [a, a long middle line, then b](htt.

2. Quadratic matching. textlabel/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.

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.

Proof of concept

1. Use an application that renders untrusted Markdown with autoclose: [links: :text]. 2. Submit a fragment made of [a, a newline, 60 000 x characters, a newline, and b](htt, leaving the link unterminated. 3. Render it with MDEx.tohtml!/2 and those options. The call takes tens of seconds of CPU, while the same input with autoclose: true renders in milliseconds. 4. Alternatively, submit [~~~ followed by 40 000 ~ characters and x](htt to drive the trailing-tilde regex.

Impact

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

Configurations

The application must render or complete attacker-influenced Markdown with the :text completion policy for links or images, autoclose: [links: :text] or autoclose: [images: :text]. The default autoclose: true policy and rendering without autoclose are not affected.

Other sources

Inefficient Regular Expression Complexity vulnerability in leandrocp mdex allows an attacker to exhaust CPU via crafted unterminated link or image labels.

When an application completes partial Markdown with the non-default autoclose: [links: :text] or autoclose: [images: :text] policy, MDEx.FragmentParser.textlabel/1 in lib/mdex/fragmentparser.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 autoclose: true policy is not affected.

This issue affects mdex: from 0.14.3 before 0.15.0.

— MITRE

Affected Software

2 affected componentsFixes available
hex/mdex>=0.14.3<0.15.0
erlang/mdex>=0.14.3<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 to a fixed release to a version that resolves this vulnerability.

    Fixed in 0.15.0
  3. Configuration

    Use auto_close: true instead of the non-default :text policy for links or images.

    MDEx auto_close = true

Event History

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

Frequently Asked Questions

1

Which deployments are exposed?

Deployments using mdex 0.14.3 through versions before 0.15.0 are affected only when they complete partial Markdown with auto_close: [links: :text] or auto_close: [images: :text]. The default auto_close: true policy is not affected.

2

What does an attacker need to trigger the issue?

An attacker needs to supply Markdown that is rendered under one of the affected non-default auto-close policies. Crafted unterminated link or image labels, including long label lines or trailing tilde runs, can cause excessive CPU consumption.

3

What can be done if upgrading is not immediately possible?

Avoid the affected auto_close text policies and use the default auto_close: true policy where possible. Also avoid rendering untrusted or streamed Markdown with those affected policies until mdex is updated.

4

How severe can a single malicious input be?

A single render of approximately 60 KB of crafted Markdown can consume tens of seconds of CPU. The processing cost grows quadratically with the relevant label line length or trailing tilde run.

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