CVE-2026-44898: lepture Mistune XSS in Table of Contents generation

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

Mistune, a popular Python library used to convert Markdown text into HTML, contains a security flaw in how it generates Tables of Contents (TOC). If an application uses Mistune to process user-provided content, an attacker can craft a malicious heading that injects unauthorized scripts into the page. This could allow an attacker to steal user session data or perform actions on behalf of other users viewing the generated document.

Technologies: mistune (PyPI). Vendors: PyPI.

Quick answers

Is CVE-2026-44898 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-44898 being exploited in the wild.
How severe is CVE-2026-44898?
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, ECOSYSTEM:introduced=3.2.0,fixed=3.2.1.
Is there a fix for CVE-2026-44898?
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-44898 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-44898?
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
    pip install "mistune>=3.2.1"

Technical details

A Cross-Site Scripting (XSS) vulnerability exists in Mistune's `render_toc_ul()` function within `src/mistune/toc.py`. The function builds a Table of Contents tree using a Python format string that fails to apply HTML escaping to the 'id' and 'text' values used in anchor tags. When heading IDs are derived from user-supplied text (a common pattern for slug-based anchors), an attacker can provide a heading that breaks out of the `href` attribute context. This allows for the injection of arbitrary HTML and `<script>` blocks. The issue is resolved in version 3.2.1 by ensuring proper escaping of heading IDs and text.

Affected products

  • lepture Mistune < 3.2.1

Identifiers

  • CVE-2026-44898
  • GHSA-6269-cqxg-mhhv
  • PYSEC-2026-2208

Timeline

  • 2026-05-03: patched: Version 3.2.1 released with HTML escaping fixes.
  • 2026-05-12: advisory: GitHub Security Advisory GHSA-6269-cqxg-mhhv published.
  • 2026-05-26: disclosed: CVE-2026-44898 published to the NVD.

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.