CVE-2026-59927 Overview
CVE-2026-59927 affects Mistune, a Python Markdown parser with renderers and plugins. The Include directive in src/mistune/directives/include.py detects only direct self-includes and fails to identify indirect cycles between markdown files. Two files that reference each other trigger unbounded recursion, raise a RecursionError, and crash the rendering request. The flaw is classified as an uncontrolled recursion issue [CWE-674]. Version 3.3.0 resolves the vulnerability by constraining include targets. Applications that expose Mistune rendering to untrusted markdown input face availability impact from this weakness.
Critical Impact
Attackers submitting crafted markdown files with cyclic includes can crash rendering requests, causing denial of service against applications embedding Mistune.
Affected Products
- Mistune Python Markdown parser versions prior to 3.3.0
- Applications and services embedding vulnerable Mistune releases for markdown rendering
- Documentation pipelines and content platforms that invoke the Include directive
Discovery Timeline
- 2026-07-08 - CVE-2026-59927 published to NVD
- 2026-07-08 - Last updated in NVD database
Technical Details for CVE-2026-59927
Vulnerability Analysis
Mistune supports an Include directive that embeds the contents of one markdown file into another during rendering. The pre-3.3.0 implementation guards only against a file including itself. It never tracks the chain of includes across multiple files, so cyclic references remain undetected.
When file a.md includes b.md and b.md includes a.md, the parser recurses between the two documents. Each recursion frame consumes stack space until the Python interpreter raises RecursionError. The exception propagates out of the rendering call and terminates the request handler.
The vulnerability requires no authentication and no user interaction. Any component that accepts attacker-controlled markdown and processes the Include directive is exposed. The impact is limited to availability because the parser aborts before producing output but does not corrupt state or leak data.
Root Cause
The include resolver in src/mistune/directives/include.py performs a shallow self-reference check. It compares the current file path against the immediate include target rather than maintaining a set of ancestor files across the recursion. This omission allows arbitrarily deep cycles among two or more files [CWE-674].
Attack Vector
An attacker supplies two or more markdown files that reference each other through the Include directive. When the application invokes Mistune to render one of these documents, the parser follows the include chain indefinitely and crashes with RecursionError. Delivery paths include multi-file upload interfaces, git-backed documentation renderers, and any workflow that stores related markdown assets attackers can influence.
import os
from typing import TYPE_CHECKING, Any, Dict, List, Match, Union
+from ..util import escape as escape_text
from ._base import BaseDirective, DirectivePlugin
if TYPE_CHECKING:
Source: GitHub Commit 1bef343. The patch constrains include targets and introduces escaping utilities in the directive module.
Detection Methods for CVE-2026-59927
Indicators of Compromise
- Application logs containing Python RecursionError traces originating from mistune/directives/include.py
- Repeated crashes or worker restarts in services that render user-supplied markdown
- Uploaded markdown files that contain mutual .. include:: directives pointing at each other
Detection Strategies
- Inventory Python dependencies and flag any Mistune release earlier than 3.3.0
- Inspect ingested markdown for Include directives and build a reference graph to identify cycles before rendering
- Correlate HTTP 5xx responses from markdown rendering endpoints with stack traces referencing Mistune
Monitoring Recommendations
- Alert on unhandled RecursionError exceptions in application logs
- Track error rates and worker recycle counts on services that expose markdown rendering
- Monitor upload endpoints for bursts of markdown files that include one another
How to Mitigate CVE-2026-59927
Immediate Actions Required
- Upgrade Mistune to version 3.3.0 or later across all environments
- Audit applications for use of the Include directive and disable it where untrusted input is processed
- Enforce request timeouts and worker memory limits on markdown rendering services
Patch Information
The fix ships in Mistune 3.3.0. See the GitHub Release v3.3.0 notes and the GitHub Security Advisory GHSA-8mpj-m6qm-5qr8 for the full remediation details. The corrective commit is available at GitHub Commit 1bef343.
Workarounds
- Remove or block the Include directive in configurations that accept untrusted markdown
- Pre-validate markdown submissions by building an include graph and rejecting cycles
- Isolate the rendering process so a RecursionError does not disrupt the parent service
# Upgrade Mistune to the patched release
pip install --upgrade "mistune>=3.3.0"
# Verify the installed version
python -c "import mistune; print(mistune.__version__)"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

