Severity by source
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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Network vector for typical web-app deployment; scope changed because SIGSEGV inside the NIF terminates the entire BEAM VM, killing all co-hosted processes beyond the direct caller.
Primary rating from Vendor (EEF).
CVSS VectorVendor: EEF
Lifecycle Timeline
1DescriptionCVE.org
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.
AnalysisAI
Stack exhaustion in the mdex and mdex_native Elixir Markdown libraries causes entire-node denial of service when processing attacker-controlled deeply nested Markdown. Two mutually recursive Rust NIF functions, ex_document_to_comrak_ast and comrak_ast_to_ex_document in document.rs, traverse the Comrak AST without enforcing a maximum nesting depth; a document with thousands of nested block quotes drives unbounded recursion that overflows the native C stack. Because the resulting SIGSEGV is raised inside a NIF, the Erlang runtime cannot catch it - the OS process hosting the BEAM terminates, killing every Elixir and Erlang process on the node. No public exploit has been identified at time of analysis, but the attack requires only crafted Markdown input with no authentication.
Technical ContextAI
The vulnerability resides in the Rust NIF (Native Implemented Function) layer shared between mdex and its extracted sub-package mdex_native. NIFs execute native Rust/C code directly inside the BEAM OS process; unlike Erlang exceptions, signals raised inside NIFs - including SIGSEGV from stack overflow - bypass the Erlang supervisor tree entirely and cannot be isolated. CWE-674 (Uncontrolled Recursion) identifies the root cause: the two mutually recursive functions ex_document_to_comrak_ast and comrak_ast_to_ex_document mirror the AST structure of Comrak, a CommonMark-compliant Rust parser, without imposing any recursion depth limit. Deeply nested Markdown constructs such as cascaded block quotes produce an equally deep AST, and recursion depth scales linearly with nesting, quickly exceeding the native C stack. Affected CPEs are cpe:2.3:a:leandrocp:mdex (versions 0.3.0 through 0.12.2) and cpe:2.3:a:leandrocp:mdex_native (versions 0.1.0 through 0.2.2); the mdex_native package was introduced when the conversion code was refactored out of mdex starting at mdex 0.12.3.
RemediationAI
Upgrade mdex to version 0.12.3 or later, or mdex_native to version 0.2.3 or later; the upstream fix is available at commit 947696c47bc22bea5dffc0f78c946fa6b70ce183 (https://github.com/leandrocp/mdex_native/commit/947696c47bc22bea5dffc0f78c946fa6b70ce183), with the full advisory at https://github.com/leandrocp/mdex_native/security/advisories/GHSA-3w4f-53g2-f66p. If immediate patching is not feasible, the most effective compensating control is to enforce a maximum nesting depth or document size limit on Markdown input before it reaches any mdex API call - reject or truncate documents exceeding a safe threshold (such as 50 to 100 nesting levels of block quotes or list items) at the application layer; this adds input-validation overhead but prevents unbounded recursion from reaching the NIF boundary. As an architectural mitigation, isolating mdex rendering in a dedicated OTP application or separate OS subprocess with a supervisor that can restart on crash limits the blast radius from node-wide termination to a sandboxed process, though this requires non-trivial architectural changes and does not eliminate the underlying flaw.
Unauthenticated denial-of-service in MDEx, an Elixir/Erlang CommonMark parsing library, lets an attacker crash the entir
Native Rust heap exhaustion in leandrocp mdex and mdex_native allows any attacker who can supply document content to MDE
Unbounded memory allocation in the MDEx Elixir Markdown rendering library allows a remote unauthenticated attacker to ex
Cross-site scripting in MDEx (Elixir Markdown library by leandrocp), versions 0.8.3 through 0.13.1, allows any attacker
Stored and reflected cross-site scripting in MDEx's Lumis syntax highlighting adapter allows attackers who can submit Ma
Same weakness CWE-674 – Uncontrolled Recursion
View allSame technique Denial Of Service
View allShare
External POC / Exploit Code
Leaving vuln.today
EUVD-2026-40177