Am I affected?

type your mdex version to check

Description

Improper Neutralization of Escape, Meta, or Control Sequences vulnerability in leandrocp mdex allows Content Spoofing via code block content passed to MDEx.to_slack/2. An attacker who controls Markdown that an application converts to Slack mrkdwn can inject <!channel>, <!here> and <@user> mentions and links whose visible label differs from their target, with default options.

In lib/mdex/slack_converter.ex, the MDEx.CodeBlock clause of render_node/2 wraps the block's literal in a fixed three-backtick fence and emits it without the escaping applied to every other text node. A block opened with four backticks or tildes whose body contains a line of three backticks therefore closes the Slack code block early, and the rest of the body is parsed as live mrkdwn. Links injected this way also skip the dangerous URL filter in render_url/2.

This issue affects mdex: from 0.13.1 before 0.15.0.

Technical analysis

1. Input handling. MDEx.to_slack/2 parses the Markdown and passes the document to MDEx.SlackConverter.convert/2, which renders each node. Text, inline code and link labels go through escape_text/1, which encodes &, < and >.

2. Unsafe processing. The MDEx.CodeBlock clause of render_node/2 emits the block literal unchanged between a fixed opening and closing three-backtick fence. CommonMark lets a block opened with four backticks or ~~~ contain a line of three backticks, so that line reaches the output intact.

3. Effect in Slack. Slack ends a code block at the next three backticks, so the inner line closes the fence and the remaining body is parsed as mrkdwn. Mention tokens such as <!channel> and links such as <https://evil.example|https://trusted.example> become live, while the same text outside a code block is escaped. Injected links never pass through render_url/2, so its dangerous URL check does not apply.

Proof of concept

  1. Supply Markdown that opens a code block with four backticks, has a line of three backticks as its first body line, then the line <!channel> <https://evil.example|https://trusted.example>, and closes with four backticks.
  2. Convert it with MDEx.to_slack/2 using default options.
  3. Observe that the output's code block ends at the inner three-backtick line and the following line keeps <!channel> and the label-spoofed link unescaped outside any code block, while a plain-text <!channel> elsewhere in the same input is escaped to &lt;!channel&gt;.

Weaknesses & attack patterns

Weakness

CWE-150 · Improper Neutralization of Escape, Meta, or Control Sequences in catalog → MITRE ↗

Attack patterns

CAPEC-148 · Content Spoofing MITRE ↗

An attacker who can submit Markdown that an application forwards to Slack can trigger channel-wide or per-user notifications and post links whose visible label shows a trusted URL while pointing elsewhere, in messages that appear to come from the application.

Affected — Hex / mdex Hex.pm ↗ Repository ↗

≥ 0.13.1 < 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.SlackConverter' · 'Elixir.MDEx'
source files lib/mdex/slack_converter.ex · lib/mdex.ex
routines 'Elixir.MDEx.SlackConverter':convert/2 · 'Elixir.MDEx':to_slack/2 · 'Elixir.MDEx':to_slack!/2

Affected — GitHub / leandrocp/mdex Repository ↗

≥ 0be090a < 22a0c7b affected
every other version: unaffected
cpe cpe:2.3:a:leandrocp:mdex:*:*:*:*:*:*:*:*
version type git
modules · source files · routines
modules 'Elixir.MDEx.SlackConverter' · 'Elixir.MDEx'
source files lib/mdex/slack_converter.ex · lib/mdex.ex
routines 'Elixir.MDEx.SlackConverter':convert/2 · 'Elixir.MDEx':to_slack/2 · 'Elixir.MDEx':to_slack!/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:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:L/SA:N

Exploitability

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

Vulnerable System

Confidentiality
None
Integrity
Low
Availability
None

Subsequent Systems

Confidentiality
None
Integrity
Low
Availability
None
« All CVEs