Am I affected?

type your mdex version to check

Description

Uncontrolled Recursion vulnerability in leandrocp mdex allows denial of service via deeply nested Markdown input.

mdex converts between an Elixir %MDEx.Document{} struct and Comrak's internal AST using two mutually recursive Rust functions, ex_document_to_comrak_ast and comrak_ast_to_ex_document, in the NIF source file document.rs. Neither function enforces a maximum nesting depth, so the recursion depth is bounded only by the structure of the input. An attacker who can get a Markdown document rendered (for example through MDEx.parse_document!/1 or MDEx.to_html/1) can supply a document with thousands of nested block quotes, which drives unbounded recursion across the NIF boundary and exhausts the native C stack.

Because the resulting stack overflow is an uncatchable SIGSEGV raised inside a NIF, it cannot be contained by the Erlang runtime. It terminates the operating system process running the BEAM, killing every Elixir and Erlang process on the node, not just the caller that triggered the render. No authentication or special privileges are required.

The vulnerable conversion code was extracted from mdex into the separate mdex_native package starting in mdex 0.12.3. This issue affects mdex from 0.3.0 before 0.12.3 and mdex_native from 0.1.0 before 0.2.3.

Weaknesses & attack patterns

Weakness

CWE-674 · Uncontrolled Recursion in catalog → MITRE ↗

Attack patterns

CAPEC-130 · Excessive Allocation MITRE ↗

Affected — Hex / mdex Hex.pm ↗ Repository ↗

0.3.0 < 0.12.3 affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*
modules · source files · routines
modules comrak_nif · 'Elixir.MDEx' · 'Elixir.MDEx.Native'
source files native/comrak_nif/src/types/document.rs · lib/mdex.ex · lib/mdex/native.ex
routines comrak_nif::types::document::ex_document_to_comrak_ast · comrak_nif::types::document::comrak_ast_to_ex_document · 'Elixir.MDEx':parse_document!/1 · 'Elixir.MDEx':to_html/1 · 'Elixir.MDEx.Native':document_to_html_with_options/2

Affected — GitHub / leandrocp/mdex Repository ↗

d0bc7d5 < 6ed94d9 affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*
modules · source files · routines
modules comrak_nif · 'Elixir.MDEx' · 'Elixir.MDEx.Native'
source files native/comrak_nif/src/types/document.rs · lib/mdex.ex · lib/mdex/native.ex
routines comrak_nif::types::document::ex_document_to_comrak_ast · comrak_nif::types::document::comrak_ast_to_ex_document · 'Elixir.MDEx':parse_document!/1 · 'Elixir.MDEx':to_html/1 · 'Elixir.MDEx.Native':document_to_html_with_options/2

Affected — Hex / mdex_native Hex.pm ↗ Repository ↗

0.1.0 < 0.2.3 affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:leandrocp:mdex_native:*:*:*:*:*:*:*:*
modules · source files · routines
modules mdex_native_nif · 'Elixir.MDExNative.Native'
source files native/mdex_native_nif/src/types/document.rs · lib/mdex_native/native.ex
routines mdex_native_nif::types::document::ex_document_to_comrak_ast · mdex_native_nif::types::document::comrak_ast_to_ex_document · 'Elixir.MDExNative.Native':parse_document/2 · 'Elixir.MDExNative.Native':document_to_html_with_options/2

Affected — GitHub / leandrocp/mdex_native Repository ↗

956528c < 947696c affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:leandrocp:mdex_native:*:*:*:*:*:*:*:*
modules · source files · routines
modules mdex_native_nif · 'Elixir.MDExNative.Native'
source files native/mdex_native_nif/src/types/document.rs · lib/mdex_native/native.ex
routines mdex_native_nif::types::document::ex_document_to_comrak_ast · mdex_native_nif::types::document::comrak_ast_to_ex_document · 'Elixir.MDExNative.Native':parse_document/2 · 'Elixir.MDExNative.Native':document_to_html_with_options/2

References

Credits

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

CVSS breakdown

CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
« All CVEs