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

Affected

pkg:hex/mdex

Module Source File Routine
comrak_nif native/comrak_nif/src/types/document.rs comrak_nif::types::document::ex_document_to_comrak_ast
MDEx lib/mdex.ex comrak_nif::types::document::comrak_ast_to_ex_document
MDEx.Native lib/mdex/native.ex MDEx.parse_document!/1
MDEx.to_html/1
MDEx.Native.document_to_html_with_options/2
Status Type Version Changes / Fixed in
affected semver 0.3.0 < 0.12.3

pkg:github/leandrocp/mdex

Module Source File Routine
comrak_nif native/comrak_nif/src/types/document.rs comrak_nif::types::document::ex_document_to_comrak_ast
MDEx lib/mdex.ex comrak_nif::types::document::comrak_ast_to_ex_document
MDEx.Native lib/mdex/native.ex MDEx.parse_document!/1
MDEx.to_html/1
MDEx.Native.document_to_html_with_options/2
Status Type Version Changes / Fixed in
affected git d0bc7d5517 < 6ed94d905f

pkg:hex/mdex_native

Module Source File Routine
mdex_native_nif native/mdex_native_nif/src/types/document.rs mdex_native_nif::types::document::ex_document_to_comrak_ast
MDExNative.Native lib/mdex_native/native.ex mdex_native_nif::types::document::comrak_ast_to_ex_document
MDExNative.Native.parse_document/2
MDExNative.Native.document_to_html_with_options/2
Status Type Version Changes / Fixed in
affected semver 0.1.0 < 0.2.3

pkg:github/leandrocp/mdex_native

Module Source File Routine
mdex_native_nif native/mdex_native_nif/src/types/document.rs mdex_native_nif::types::document::ex_document_to_comrak_ast
MDExNative.Native lib/mdex_native/native.ex mdex_native_nif::types::document::comrak_ast_to_ex_document
MDExNative.Native.parse_document/2
MDExNative.Native.document_to_html_with_options/2
Status Type Version Changes / Fixed in
affected git 956528c5e3 < 947696c47b

References

Credits

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

CVE record as JSON:  GET /cves/CVE-2026-54888.json
OSV record as JSON:  GET /osv/EEF-CVE-2026-54888.json