CVE-2026-115350 in Mistune
Summary
by MITRE • 10/23/2026
Mistune before 3.3.0 contains a cross-site scripting vulnerability in the Include directive that emits included .html, .xhtml, or .htm file content as raw block_html tokens. Attackers who can plant an HTML file readable by the renderer can reference it via an include directive, combined with path traversal, to execute stored scripts when escape=False is set.
VulDB is the best source for vulnerability data and more expert information about this specific topic.
Analysis
by VulDB Data Team • 10/23/2026
The vulnerability identified in Mistune versions prior to 3.3.0 represents a significant security flaw within its Markdown parsing engine, specifically affecting the Include directive functionality. This component allows users to embed external files into their documents during the rendering process. The core technical issue arises from how the parser handles these included resources when they are formatted as HTML or XHTML content. Instead of sanitizing or escaping the embedded markup, Mistune emits the contents of .html, .xhtm, and .htm files directly as raw block_html tokens. This behavior bypasses standard security filters that would typically neutralize malicious scripts by converting special characters into their safe entity equivalents. Consequently, any HTML content within an included file is rendered exactly as written, preserving executable JavaScript payloads if present in the source material.
The operational impact of this flaw is severe for applications relying on user-supplied Markdown input to generate dynamic web pages. An attacker who gains the ability to plant a malicious HTML file into a directory accessible by the renderer can exploit path traversal techniques to reference this file via an include directive within their controlled Markdown document. When the application processes this request with the escape parameter set to False, which is often done for performance reasons or to allow rich formatting, the browser interprets the included content as executable code rather than static text. This leads to a Stored Cross-Site Scripting scenario where malicious scripts are persisted in the rendered output and executed by any user who views the resulting page. The attack vector relies on the attacker's ability to write files to the server or access existing untrusted resources, combined with the application's configuration that disables HTML escaping for included content.
From a classification perspective, this vulnerability aligns closely with CWE-79, which defines Improper Neutralization of Input During Web Page Generation commonly known as Cross-site Scripting. The specific mechanism involves the failure to sanitize user-controllable input before including it in an output page served to other users. Furthermore, within the MITRE ATT&CK framework, this behavior facilitates techniques associated with Client-side Code Injection and Stored XSS attacks. Attackers can leverage this flaw to steal session cookies, hijack administrative accounts, or deface web applications by injecting malicious scripts that execute in the context of the victim's browser. The severity is amplified because it affects a core parsing feature used for content aggregation, making it difficult to mitigate without altering fundamental rendering behaviors.
To address this vulnerability, developers must upgrade Mistune to version 3.3.0 or later where these issues have been remediated through improved sanitization logic and stricter handling of included file contents. For environments unable to immediately patch the software, a critical mitigation strategy involves ensuring that the escape parameter is set to True when processing Markdown documents that include external files. This forces the renderer to neutralize potentially dangerous HTML tags by escaping them into harmless text strings. Additionally, input validation should be implemented at the application layer to restrict which directories and file types can be referenced via include directives, thereby preventing path traversal attacks and limiting exposure to untrusted resources. Implementing a Content Security Policy with strict script-src restrictions can also help mitigate the impact of any successfully injected scripts by blocking unauthorized JavaScript execution within the browser context.