The vulnerability, identified as CVE-2025-59940 (GHSA-v39m-5m9j-m9w9), is a CWE-20 (Improper Input Validation) issue in the mkdocs-include-markdown-plugin. The root cause is that the plugin's internal placeholder syntax could collide with user-provided content in markdown files.
The plugin works by replacing {% include-markdown ... %} tags with the content of other files. To do this, it first replaces the tag with a unique placeholder (e.g., \u0002klzzwxh:0\u0003), and after all tags are processed, it substitutes these placeholders with the actual file content. The vulnerability arises because if a user's markdown file already contains a string identical to a placeholder, the plugin would incorrectly replace this string with included content, leading to unexpected output.
The analysis of the patch commit 7466d67aa0de8ffbc427204ad2475fed07678915 reveals the fix. The core changes are in the found_include_markdown_tag function within src/mkdocs_include_markdown_plugin/event.py. Before processing, the entire markdown input is now passed through a new escape_placeholders function, which neutralizes the special characters (\u0002 and \u0003) used to denote placeholders. After all legitimate includes are processed, the unescape_placeholders function is called to restore the original characters.
The vulnerable functions are:
on_page_markdown: The main event handler that receives the untrusted markdown input.
found_include_markdown_tag: The function that performs the unsafe placeholder substitution. During exploitation, a runtime profile would show a call to on_page_markdown, which in turn calls found_include_markdown_tag, where the flawed logic resides.