Am I affected?

type your mdex version to check

Description

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 auto_close: 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 expand_quote_prefix/2 in lib/mdex/fragment_parser.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.

Proof of concept

  1. Build a Markdown input consisting of a single line of 400,000 > characters.
  2. Render it with MDEx.to_html!(input, auto_close: true), or pass it as one chunk to MDEx.stream/2.
  3. Observe the call takes over ten seconds, compared with under 150 ms for MDEx.to_html!(input) without auto-close.

Weaknesses & attack patterns

Weakness

CWE-407 · Inefficient Algorithmic Complexity in catalog → MITRE ↗

Attack patterns

CAPEC-130 · Excessive Allocation MITRE ↗

An attacker who can submit Markdown to an application that auto-closes or streams it can occupy a CPU core for seconds with a single request of a few hundred kilobytes, degrading rendering for other users.

Affected — Hex / mdex Hex.pm ↗ Repository ↗

≥ 0.14.2 < 0.15.0 affected
every other version: unaffected
cpe cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*
version type semver
modules · source files · routines
modules 'Elixir.MDEx.FragmentParser'
source files lib/mdex/fragment_parser.ex
routines 'Elixir.MDEx.FragmentParser':expand_quote_prefix/2 · 'Elixir.MDEx.FragmentParser':complete/2

Affected — GitHub / leandrocp/mdex Repository ↗

≥ 9a4b768 < 2c29b28 affected
every other version: unaffected
cpe cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*
version type git
modules · source files · routines
modules 'Elixir.MDEx.FragmentParser'
source files lib/mdex/fragment_parser.ex
routines 'Elixir.MDEx.FragmentParser':expand_quote_prefix/2 · 'Elixir.MDEx.FragmentParser':complete/2

References

Credits

Peter Ullrich Finder Reporter
Jonatan Männchen / EEF Analyst
Leandro Pereira Remediation developer

CVSS breakdown

CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N

Exploitability

Attack Vector
Local
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None

Vulnerable System

Confidentiality
None
Integrity
None
Availability
Low

Subsequent Systems

Confidentiality
None
Integrity
None
Availability
None
« All CVEs