Inefficient Algorithmic Complexity vulnerability in MDEx.FragmentParser in leandrocp mdex allows an attacker who controls streamed or auto-closed Markdown to cause a denial of service through CPU exhaustion. Any application that renders untrusted Markdown with MDEx.stream/2 or the auto_close option is affected, for example live previews or streamed LLM output.
While auto-closing the last paragraph, close_bracket/5 in lib/mdex/fragment_parser.ex runs an unbounded forward scan of the link tail for every ](. When that scan finds no valid link, scanning resumes just after the ], so the next ]( rescans the same tail. Each closed link also re-filters every pending image opener. Repeated [](x (, [](x(, or  or nested parentheses ([](x( repeated) makes every scan run to the end of the paragraph.
3. Opener filtering. Each closed link runs Enum.filter/2 over every pending opener to keep only images. With  z (about 120 KB, no blank line).MDEx.stream/2 and consume the stream.MDEx.to_html!/1 on the same input returns in about 10 ms. Doubling the input roughly quadruples the time.An attacker who can submit Markdown to a streaming or auto-closing renderer can occupy a CPU scheduler for seconds per request with about 100 KB of input, slowing or denying rendering for other users.
The application must render untrusted Markdown with auto-closing enabled: through MDEx.stream/2, where it is on unless auto_close: false is passed, or with the auto_close option set on a document. Rendering with the default options of MDEx.to_html/2 and MDEx.parse_document/2 does not run the affected scanner.
{
"$schema": "https://cna.erlef.org/schemas/osv/record-0.1.0.json",
"capec_ids": [
"CAPEC-130"
],
"cpe_ids": [
"cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*"
],
"cwe_ids": [
"CWE-407"
]
}{
"$schema": "https://cna.erlef.org/schemas/osv/affected-0.1.0.json",
"modules": [
"'Elixir.MDEx.FragmentParser'",
"'Elixir.MDEx'"
],
"program_files": [
"lib/mdex/fragment_parser.ex",
"lib/mdex.ex"
],
"program_routines": [
"'Elixir.MDEx.FragmentParser':close_bracket/5",
"'Elixir.MDEx.FragmentParser':continue_after_link/2",
"'Elixir.MDEx.FragmentParser':complete/2",
"'Elixir.MDEx':stream/2"
]
}
"https://cna.erlef.org/schemas/osv/affected-0.1.0.json"
[
"'Elixir.MDEx.FragmentParser'",
"'Elixir.MDEx'"
]
[
"lib/mdex/fragment_parser.ex",
"lib/mdex.ex"
]
[
"'Elixir.MDEx.FragmentParser':close_bracket/5",
"'Elixir.MDEx.FragmentParser':continue_after_link/2",
"'Elixir.MDEx.FragmentParser':complete/2",
"'Elixir.MDEx':stream/2"
]
"https://cna.erlef.org/osv/EEF-CVE-2026-129522.json"
"https://cna.erlef.org/schemas/osv/affected-0.1.0.json"
[
"'Elixir.MDEx.FragmentParser'",
"'Elixir.MDEx'"
]
[
"lib/mdex/fragment_parser.ex",
"lib/mdex.ex"
]
[
"'Elixir.MDEx.FragmentParser':close_bracket/5",
"'Elixir.MDEx.FragmentParser':continue_after_link/2",
"'Elixir.MDEx.FragmentParser':complete/2",
"'Elixir.MDEx':stream/2"
]
"https://cna.erlef.org/osv/EEF-CVE-2026-129522.json"