CVE-2026-59930

Mistune toc / TableOfContents directive: heading IDs use predictable `toc_N` numbering with no slugification, allowing collision with attacker-controlled `id="toc_N"` content

Published Jul 8, 2026 CVSS 3.1 · 4.3 Medium EPSS < 1% KEV · Not listed
Description
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.

Analysis

AI-generated

Technical impact

Older Mistune releases generate predictable heading identifiers using the form toc_N when rendering a TableOfContents. These identifiers are not derived from the heading text, so an attacker can embed an element with an id attribute such as id="toc_N" in the markdown. The generated anchor will then conflict with the attacker‑controlled element, causing links, CSS selectors, or JavaScript targeting #toc_N to resolve to the wrong destination. This client‑side manipulation can redirect users within the page, change the layout, or compromise JavaScript behavior, but it does not provide direct code execution or data exfiltration.

Affected Systems

Python applications that include Mistune version 3.2.x or earlier are affected. The issue is fixed in release 3.3.0. All deployments that render untrusted markdown with these older versions are at risk. The vendor is Lepture, the Mistune project.

Risk and Exploitability

The CVSS score of 4.3 indicates low severity. EPSS is below 1% and the vulnerability is not listed in CISA KEV, suggesting limited exploitation. The likely attack vector is the injection of malicious markdown into a service that renders it with Mistune—such as content‑management systems, forums, or chat applications. Because the attack requires control over the input, the risk is confined to contexts where untrusted data is parsed. Mitigating by upgrading to 3.3.0 eliminates the flaw immediately.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade Mistune to version 3.3.0 or newer.
  • Disable the TableOfContents directive or remove the toc plugin from any rendering pipeline that processes untrusted Markdown until the upgrade is applied.
  • Enforce a Content Security Policy that limits JavaScript and CSS from targeting elements with IDs beginning with "toc_" and monitor for anomalous navigation changes.

Generated by OpenCVE AI on August 1, 2026 at 15:56 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-2hm2-hc3v-44h9 Mistune toc / TableOfContents directive: heading IDs use predictable `toc_N` numbering with no slugification, allowing collision with attacker-controlled `id="toc_N"` content
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Lepture
Lepture mistune
Vendors & Products Lepture
Lepture mistune
Type Values Removed Values Added
Description 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.
Title Mistune toc / TableOfContents directive: heading IDs use predictable `toc_N` numbering with no slugification, allowing collision with attacker-controlled `id="toc_N"` content
Weaknesses CWE-1284
CWE-345
References
Metrics cvssV3_1

{'score': 4.3, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N'}

Weaknesses
  • CWE-1284

    Improper Validation of Specified Quantity in Input

  • CWE-345

    Insufficient Verification of Data Authenticity

  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 9, 2026, 1:54 PM
Reserved
Jul 7, 2026, 6:20 PM
Status
Analyzed
Published
Jul 8, 2026, 5:17 PM
Modified
Oct 25, 2026, 5:10 PM
Severity
Moderate
Public date
Jul 8, 2026, 4:13 PM