CVE-2026-137162: Quadratic CPU consumption in mdex auto-close block quote prefix expansion
Inefficient Algorithmic Complexity vulnerability in leandrocp mdex allows an attacker who supplies Markdown to exhaust CPU via a long run of block quote markers when auto-close is enabled.
When Markdown is rendered with autoclose: true or through MDEx.stream/2, MDEx.FragmentParser checks whether the last paragraph ends in an incomplete link reference definition. If that paragraph contains >, each line's leading quote prefix is expanded by expandquoteprefix/2 in lib/mdex/fragmentparser.ex. That function is body-recursive and prepends each character to the prefix built so far, copying it again for every leading space, tab or >, so a line of N such bytes costs O(N²). The prefix length is not bounded. A single line of a few hundred kilobytes of > ties up a scheduler for seconds, while the same input renders in milliseconds with auto-close off.
This issue affects mdex: from 0.14.2 before 0.15.0.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 0.15.0 - Configuration
Set auto_close to false when rendering Markdown to avoid the affected block-quote prefix expansion.
mdex auto_close = false
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Deployments using mdex versions 0.14.2 through versions before 0.15.0 are affected when rendering attacker-controlled Markdown with auto_close: true. Calls through MDEx.stream/2 also use the affected auto-close path.
What input does an attacker need to provide?
The attacker needs to supply Markdown containing a very long run of leading block quote prefix characters, such as >, spaces, or tabs, in the last paragraph. The costly path is reached when fragment parsing checks for an incomplete link reference definition.
Is the default rendering configuration known to be affected?
The available information only identifies rendering with auto_close: true and MDEx.stream/2 as affected. It does not state whether auto-close is enabled by default.
What can be done before upgrading?
If possible, render untrusted Markdown with auto_close disabled, since the same input renders in milliseconds with auto-close off. Avoid processing untrusted content through MDEx.stream/2 until the affected mdex version is replaced.
How can I determine whether a service is currently at risk?
Check whether the service uses mdex 0.14.2 or a later version below 0.15.0, and whether it accepts untrusted Markdown through auto_close: true or MDEx.stream/2. Inputs with extremely long leading quote-prefix runs can cause CPU exhaustion and tie up a scheduler for seconds.