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

Source: https://junglewise.ai/threats/cve-2026-44897-mistune-xss-via-unsanitized-heading-id-attribute  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-26. Updated: 2026-05-26  
License: CC BY 4.0 with a link back

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

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.

Technologies: [mistune (PyPI)](https://junglewise.ai/threats/technologies/mistune). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2026-44897 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-44897 being exploited in the wild.

**How severe is CVE-2026-44897?** Medium severity, with a CVSS score of 6.1, published 26 May 2026.

**Which products and versions are affected?** mistune (PyPI) <= 3.2.0, ECOSYSTEM:introduced=0,fixed=3.2.1.

**Is there a fix for CVE-2026-44897?** Yes. mistune (PyPI): upgrade to 3.2.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-44897 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-44897?** Check whether you run mistune (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- mistune (PyPI): upgrade to 3.2.1 or later

  ```sh
  pip install "mistune>=3.2.1"
  ```


## 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

## Identifiers

- CVE-2026-44897
- GHSA-v87v-83h2-53w7
- PYSEC-2026-2207

## 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

- [https://github.com/lepture/mistune/releases/tag/v3.2.1](https://github.com/lepture/mistune/releases/tag/v3.2.1)
- [https://github.com/lepture/mistune/security/advisories/GHSA-v87v-83h2-53w7](https://github.com/lepture/mistune/security/advisories/GHSA-v87v-83h2-53w7)

## Related threats

- [Mistune path traversal and XSS in Include directive](https://junglewise.ai/threats/duplicate-advisory-mistune-path-traversal-and-xss-in-include-directive-bf25c187)
- [Mistune path traversal and XSS in Include directive](https://junglewise.ai/threats/cve-2026-115355-mistune-before-3-3-0-contains-a-path-traversal-vulnerability-in)
- [Mistune uncontrolled recursion in HTML rendering](https://junglewise.ai/threats/cve-2026-76098-mistune-uncontrolled-recursion-in-html-rendering)
- [lepture Mistune predictable ID generation in TOC plugin](https://junglewise.ai/threats/cve-2026-59930-lepture-mistune-predictable-id-generation-in-toc-plugin)
- [lepture mistune XSS via incomplete URL scheme filtering in HTML renderer](https://junglewise.ai/threats/cve-2026-59929-lepture-mistune-xss-via-incomplete-url-scheme-filtering-in-html)
