CVE-2026-59930: Mistune Table-of-Contents ID Collision Vulnerability
Mistune, a popular Python Markdown parser, contains a predictability flaw in how it generates anchor IDs for table-of-contents elements. Before version 3.3.0, the toc plugin and TableOfContents directive create heading IDs using a simple sequential pattern (toc_1, toc_2, etc.) without considering the actual heading text. An attacker who controls Markdown content can craft headings with matching IDs that collide with these predictable anchors, potentially redirecting users to unintended locations or interfering with page navigation and styling rules that depend on those IDs.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 4.3 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N
- Weaknesses (CWE)
- CWE-1284, CWE-345
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-07-08 / 2026-07-09
NVD description (verbatim)
Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, the toc plugin and TableOfContents directive generate heading IDs as predictable toc_N values without slugifying the heading text, allowing attacker-controlled id="toc_N" content to collide with generated anchors and redirect same-page navigation, CSS selectors, or JavaScript handlers. This issue is fixed in version 3.3.0.
4 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from insufficient heading-ID generation logic in Mistune's table-of-contents functionality. Rather than slugifying heading text into unique, content-derived identifiers, the parser assigns generic, sequentially numbered IDs (toc_N). An attacker submitting crafted Markdown can insert elements with id attributes matching these predictable values, creating an ID collision. This allows the attacker to hijack anchor navigation targets, override CSS selectors targeting those IDs, or interfere with JavaScript event handlers bound to those elements. The attack surface is largest in systems that render user-supplied or untrusted Markdown, such as comment platforms, wiki engines, or documentation portals. The flaw is remedied in version 3.3.0 by implementing proper heading-text slugification.
Business impact
Organizations using Mistune to process user-generated Markdown content face a risk of defacement and user-experience disruption. An attacker could manipulate same-page navigation, causing users to land on incorrect sections or triggering unintended JavaScript. In comment systems or documentation platforms, this enables subtle content manipulation—for example, linking to a heading that now points elsewhere—which could mislead readers or damage credibility. The impact is typically non-critical but can erode trust and create maintenance overhead. Risk is highest in multi-user or community-driven platforms where content moderation is difficult.
Affected systems
The Mistune project's mistune package for Python is affected in all versions prior to 3.3.0. Any application using Mistune to render Markdown with the toc plugin or TableOfContents directive enabled is vulnerable if it processes Markdown from untrusted sources. This includes wiki software, blogging platforms, comment systems, and static site generators that rely on Mistune for parsing.
Exploitability
Exploitability requires user interaction—specifically, a user must visit a page containing attacker-controlled Markdown and be affected by the ID collision (e.g., clicking a link or having JavaScript execute). Exploitation is straightforward for an attacker with the ability to supply Markdown content: no special tools or credentials are needed. However, the attack vector is network-based and unauthenticated, meaning any Internet-facing application that accepts user Markdown is at risk. The CVSS score of 4.3 reflects the requirement for user interaction and limited integrity impact.
Remediation
Upgrade Mistune to version 3.3.0 or later. This version implements proper heading-text slugification, eliminating the predictable ID collision vulnerability. For organizations unable to upgrade immediately, consider disabling the toc plugin or TableOfContents directive if not essential, or restrict Markdown input to trusted sources only. Implement Content Security Policy (CSP) headers to limit the scope of ID-based CSS or JavaScript tampering.
Patch guidance
Verify against the vendor advisory that version 3.3.0 (or later) is available for your Python environment and dependency manager. Update Mistune using your package manager (e.g., pip install --upgrade mistune>=3.3.0). Test the update in a staging environment to confirm compatibility with any custom Markdown renderers or plugins. If you maintain a vendored copy of Mistune, apply the fix from the official repository and rebuild your application.
Detection guidance
Monitor your Mistune version in inventory and dependency scanning tools. In logs, look for Markdown submissions that contain inline id attributes matching the pattern id="toc_[0-9]+"; such submissions may indicate attempted ID collision attacks. Review page-rendering logic to identify where the toc plugin is active. If you have analytics or error-tracking in place, watch for unexpected navigation jumps or JavaScript errors that might indicate users encountering manipulated anchors.
Why prioritize this
This vulnerability is moderate-severity and should be prioritized for patching within a standard maintenance window, especially for applications handling user-generated content. The ease of exploitation is offset by the need for user interaction and the limited scope of impact. Organizations with high-traffic community platforms or wikis should prioritize higher; internal-only applications may patch on a standard schedule.
Risk score, explained
The CVSS 3.1 score of 4.3 (Medium) reflects a network-accessible, unauthenticated attack vector, low attack complexity, and no requirement for special privileges. However, the score is capped by the requirement for user interaction and limited integrity impact (no confidentiality or availability loss). The attack does not compromise system security or data confidentiality, making it a user-experience and content-integrity issue rather than a critical security breach.
Frequently asked questions
Is this vulnerability exploitable without user interaction?
No. An attacker can craft Markdown with colliding IDs, but the impact only manifests when a user visits the rendered page and interacts with it (e.g., clicking a link or triggering JavaScript). This requirement for user interaction is reflected in the CVSS score.
Does this affect all uses of Mistune, or only specific configurations?
Only applications using the toc plugin or TableOfContents directive are vulnerable. If your application uses Mistune for general Markdown parsing without these components enabled, you are not affected. Review your Mistune configuration to confirm.
Can I work around this without upgrading immediately?
Yes, consider disabling the toc plugin or TableOfContents directive if it is not essential to your application. Alternatively, restrict Markdown input to trusted sources only. However, upgrading to version 3.3.0 is the recommended long-term solution.
What are the differences between CWE-1284 and CWE-345 in this context?
CWE-1284 (Improper Validation of Specified Quantity in Input) describes the failure to properly validate and uniquify heading IDs. CWE-345 (Insufficient Verification of Data Authenticity) reflects the fact that user-supplied Markdown can inject content that collides with system-generated identifiers without proper verification. Together, they highlight the design flaw in ID generation.
This analysis is provided for informational purposes and based on the CVE record and vendor advisory as of the publication date. Security assessments should be tailored to your organization's specific environment and threat model. Always verify patch availability and compatibility with your deployment before applying updates. SEC.co does not provide legal, compliance, or guaranteed patch guidance; consult your vendor and internal security team for definitive remediation timelines. Source: NVD (public-domain), retrieved 2026-08-17. Analysis generated by SEC.co (claude-haiku-4-5).
Affected vendors
Related vulnerabilities
- CVE-2026-11596MEDIUMScreenConnect Host Pass Token Expiration Bypass (MEDIUM, 4.7)
- CVE-2026-11906MEDIUMIBM Db2 Authenticated Denial of Service via XMLTable Query Injection
- CVE-2026-13507MEDIUMvolcengine OpenViking Data Authenticity Vulnerability
- CVE-2026-13513MEDIUMMyScaleDB Cache Validation Vulnerability
- CVE-2026-45792MEDIUMRTK Configuration Injection Allows Silent Output Suppression in LLM Workflows
- CVE-2026-46538MEDIUMMicrosoft UFO Cross-Device Task Result Injection (CVSS 5.9)
- CVE-2026-46539MEDIUMNimiq BlockInclusionProof Logic Flaw Enables Forged Block Headers
- CVE-2026-47155MEDIUMvLLM Revision Pinning Supply-Chain Integrity Bypass (CVSS 6.5)