Junglewise Threat Intelligence

CVE-2026-44897: Mistune XSS via unsanitized heading ID attribute

CVE-2026-44897 · Severity: medium · CVSS 6.1 · Published 2026-05-26

Technologies: Lepture Mistune. Vendors: PyPI.

Executive brief

Mistune is a popular Python library used to convert Markdown text into HTML for websites and applications. A security flaw in how it handles section headings allows an attacker to inject malicious code (Cross-Site Scripting) into a webpage if the application is configured to generate human-readable links for those headings. If a user views a page containing this malicious content, an attacker could potentially steal session cookies, redirect the user, or perform actions on their behalf.

Technical details

A Cross-Site Scripting (XSS) vulnerability exists in Mistune's HTMLRenderer.heading() component. The vulnerability stems from the direct string concatenation of the 'id' attribute value into the HTML heading tag without passing it through sanitization functions like escape() or safe_entity(). While the default Table of Contents (TOC) hook uses safe numeric IDs, many real-world implementations use custom callbacks to generate human-readable slugs from heading text. An attacker can craft a heading containing double-quotes to break out of the 'id' attribute and inject arbitrary HTML attributes, such as 'onmouseover' or other event handlers. This issue is resolved in version 3.2.1 by ensuring heading IDs are properly escaped.

Affected products

  • lepture Mistune < 3.2.1

Timeline

  • 2026-05-03: patched: Fixes included in version 3.2.1 release
  • 2026-05-06: advisory: GitHub Security Advisory published
  • 2026-05-26: disclosed: CVE published to NVD

References

Related threats