CVE-2026-59926: Mistune Markdown Parser XSS via Attribute Injection
Mistune, a popular Python library for converting Markdown into HTML, has a vulnerability in how it handles formatting directives. When users include special formatting instructions (called admonitions) in Markdown, the library failed to properly clean certain styling options before adding them to the generated HTML. This oversight allows an attacker to inject malicious code that could compromise website visitors' browsers, even if the site owner thought they had protective settings turned on. The issue affects Mistune versions before 3.2.1.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 6.1 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Weaknesses (CWE)
- CWE-79
- 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.2.1, render_admonition() in src/mistune/directives/admonition.py concatenates the Admonition directive :class: option into the HTML class attribute without escaping, allowing attribute injection and cross-site scripting even when HTMLRenderer escape mode is enabled. This issue is fixed in version 3.2.1.
3 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability exists in the render_admonition() function within the admonition directive module. When processing the :class: option of an Admonition directive, the function concatenates user-supplied input directly into the HTML class attribute without HTML entity encoding. This bypasses the HTMLRenderer's escape mode protections, enabling attribute injection that can be chained into stored XSS. An attacker controlling Markdown input can craft a :class: value containing event handlers or data attributes that execute arbitrary JavaScript in the context of the consuming application.
Business impact
Organizations embedding untrusted Markdown content (user-submitted documents, wiki systems, comment sections, or third-party content feeds) face potential account compromise, session hijacking, or malware distribution to end users. The vulnerability is particularly concerning for SaaS platforms, collaborative tools, and publishing systems where end-user-generated Markdown is a core feature. Affected parties must assume that malicious Markdown could already exist in their content corpus.
Affected systems
Python applications using Mistune versions prior to 3.2.1 are affected. This includes any web application, documentation system, CMS, or API that uses Mistune to render Markdown. The scope spans development environments, CI/CD pipelines using Mistune for documentation generation, and production web services. Check your dependency management tools (pip, poetry, pipenv) for Mistune version inventory across your estate.
Exploitability
Exploitability is moderate. The attack requires the ability to control or influence Markdown input that will be processed by the vulnerable Mistune instance. No authentication is required to craft malicious Markdown, though the attacker must have a vector to inject it (e.g., markdown upload, API input, or compromised content source). User interaction is required—a victim must view a page rendering the malicious Markdown. The attack is not network-complex and can be automated at scale if injection vectors are available.
Remediation
Upgrade Mistune to version 3.2.1 or later immediately. For applications unable to upgrade immediately, implement input validation to reject or sanitize Admonition directives containing suspicious :class: values, or disable admonition directive processing if not needed. Consider implementing a Content Security Policy (CSP) with strict script-src directives to limit XSS blast radius.
Patch guidance
Update Mistune via your package manager: `pip install --upgrade mistune>=3.2.1` (verify exact version in the official release notes at the Mistune project repository). Update your requirements.txt, Pipfile, or pyproject.toml, then rebuild and redeploy affected services. Test rendering of previously stored Markdown to ensure no unintended breakage. Consider running a security scan on your content corpus to identify any existing malicious Markdown that may exploit this vulnerability.
Detection guidance
Search code repositories and dependency locks for `mistune` with version < 3.2.1. Monitor application logs for Markdown input containing the string pattern `:class:` followed by unusual HTML characters (quotes, angle brackets, event handlers like `on`). Implement WAF rules to flag HTTP requests containing malicious HTML attribute patterns in parameters expected to carry Markdown. Use runtime application security tools to detect unusual script execution following Markdown rendering.
Why prioritize this
This is a medium-severity issue affecting a widely-used open-source library. While the CVSS score is 6.1, prioritization depends on your use case: if your application accepts untrusted Markdown from users or third parties, treat this as HIGH priority for immediate patching. If Markdown is authored only by trusted internal staff, treat as MEDIUM priority but still patch within your standard cycle. The lack of active exploitation (KEV status: not listed) provides a narrow window to patch proactively.
Risk score, explained
CVSS 3.1 score of 6.1 (MEDIUM) reflects: network-accessible attack vector, low complexity, no privileges required, user interaction needed (viewing malicious content), and scope change (XSS can affect other users/sessions). The score does not account for business context—your risk may be higher if you run a user-generated-content platform, or lower if Markdown is internally authored only.
Frequently asked questions
Do I need to upgrade if I don't use the Admonition directive?
Check your Mistune configuration and rendering pipeline. If your application never calls or imports the admonition module, the attack surface is reduced, but upgrading is still recommended to prevent future misconfigurations and to ensure consistency across your dependency tree.
Can I detect if this vulnerability has been exploited in my stored content?
Search your content database for Markdown containing `:class:` followed by HTML event handler patterns (e.g., `onclick=`, `onmouseover=`, `onerror=`). Correlate any findings with browser logs from the time those documents were rendered. An XSS attack would typically appear as unexpected JavaScript execution or suspicious network requests in user sessions.
What if we have a CSP policy in place—does that protect us?
A restrictive CSP (e.g., `script-src 'self'`) can mitigate the impact of stored XSS by preventing inline scripts or unauthorized script sources from executing. However, CSP is defense-in-depth, not a substitute for patching. An attacker might still bypass CSP via DOM-based XSS or manipulate other HTML attributes to cause harm.
Are there any backward-compatibility concerns with upgrading to 3.2.1?
Verify against the Mistune project's release notes and changelog. Version 3.2.1 is a patch release and should not introduce breaking changes to the public API. However, if your application relies on undocumented behavior or internal APIs, test thoroughly in a staging environment before production deployment.
This analysis is provided for informational purposes by SEC.co and does not constitute security advice tailored to your specific infrastructure or risk profile. Always verify vulnerability details against official vendor advisories and apply patches in a controlled, tested environment. Your organization's risk assessment and prioritization should account for your unique threat model, compliance requirements, and operational constraints. No warranty is provided regarding the completeness or accuracy of this analysis; rely on authoritative sources such as the Mistune project repository and your own security assessments for final remediation decisions. Source: NVD (public-domain), retrieved 2026-08-17. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-59923MEDIUMMistune Percent-Encoded JavaScript URI Bypass in HTML Rendering
- CVE-2026-59929MEDIUMMistune URL Scheme Bypass Vulnerability – XSS Risk in Markdown Parser
- CVE-2016-20070MEDIUMPrivilege Escalation & Stored XSS in WordPress Booking Calendar Contact Form 1.0.23
- CVE-2018-25384MEDIUMStored XSS in Wikidforum 2.20 Allows Authenticated Attackers to Inject Malicious Scripts
- CVE-2019-25731MEDIUMStored XSS in Zuz Music 2.1 Contact Form
- CVE-2019-25737MEDIUMStored XSS in Live Chat Unlimited 2.8.3 – Admin Session Compromise
- CVE-2019-25739MEDIUMGigToDo 1.3 Stored XSS Vulnerability in Proposal Descriptions
- CVE-2019-25742MEDIUMStored XSS in Zoner Real Estate WordPress Theme 4.1.1 – Admin Account Compromise Risk