Skip to content

← Public intelligence

PyPI package

mistune

Open actionable advisories and recorded vendor fixes. This public package view has no inventory attached and cannot establish whether your deployment is affected. A vendor fix never resolves your finding; verify your installed version and the source guidance.

Open advisories

20 actionable advisories, newest first. Withdrawn advisories and news are excluded. Coverage is partial.

  1. UnratedPyPIAmendedPublished

    Mistune: Path Traversal and XSS in Include directive

    CVE-2026-115355 · GHSA-h7ww-273w-6cm8

    Affected
    • PyPI mistune <= 3.2.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    The Include directive in src/mistune/directives/include.py does not validate that the resolved file path stays within the source directory, allowing path traversal via ../ sequences to read arbitrary files. Additionally, error messages and included file contents are rendered without HTML escaping, leading to XSS even when escape=True. Affected functions: - Path resolution (lines 27-31) - blockerror() in html.py (line 140) - renderhtmlinclude() (line 72) The Include plugin must be explicitly enabled via the plugins parameter.

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.com (1)osv.dev (2)Source checked Evidence →
  2. High, CVSS 7.5PyPIPublished

    Mistune: Denial of Service — RecursionError via Excessive Emphasis Markers in Markdown

    CVE-2026-76098 · GHSA-6m44-fpc8-c3rq

    Affected
    • PyPI mistune >= 3.3.0, < 3.3.3
    Fixed in
    3.3.3· Vendor fix available
    Issue
    Mistune v3.3.2 is vulnerable to a Denial of Service (DoS) attack via uncontrolled recursion in the HTML rendering of deeply-nested emphasis tokens. By submitting Markdown containing approximately 1,000 consecutive asterisk characters, an attacker causes the Python process to crash with RecursionError. Details The InlineParser's processemphasisdelimiters() creates deeply nested <strong tokens from consecutive emphasis markers (every 2 asterisks add one nesting level). With 1,000 consecutive asterisks, approximately 500 levels of nesting are produced. The HTMLRenderer.rendertoken() method (src/mistune/renderers/html.py:40-57) renders these tokens recursively: when a token has children, line 48 calls self.rendertokens(token['children'], state), entering child rendering. Each nesting level produces ~2 stack frames, so 500 levels ≈ 1,000 frames, exceeding Python's default recursion limit (sys.getrecursionlimit() = 1000). The emphasis() and strong() methods (lines 80-84) wrap…

    Recommended action: Upgrade to 3.3.3 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.comSource checked Evidence →
  3. Medium, CVSS 6.1PyPIAmendedPublished

    Mistune renderers/html.safe_url: HARMFUL_PROTOCOLS list misses legacy and chained schemes that historically chain to javascript: execution

    CVE-2026-59929 · GHSA-qfrw-5rxm-mhh2

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    Type: URL-scheme allowlist gap. The safeurl filter only blocks the four schemes javascript:, vbscript:, file:, data:. Several other schemes are accepted into rendered <a href="..." and <img src="..." tags despite being known XSS vectors in legacy or chain-handling browsers. The same gap applies to direct links, reference links, and autolinks. File: src/mistune/renderers/html.py, line 11-23 (HARMFULPROTOCOLS list). Root cause: the HARMFULPROTOCOLS tuple is a hardcoded, opt-out denylist of four entries. Browsers historically supported (and some still partially support) several other schemes that either execute JavaScript directly (livescript:, mocha:) or wrap a javascript: payload (feed:javascript:, view-source:javascript:, jar:javascript:, ms-its:javascript:, mk:@MSITStore:javascript:). On user-agents that still recognise these schemes (older Firefox builds for feed:/jar:, all Internet Explorer / Edge Legacy for ms-its:/mk:/res:, niche chrome-style browsers, browser extensions…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  4. Medium, CVSS 4.3PyPIAmendedPublished

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

    CVE-2026-59930 · GHSA-2hm2-hc3v-44h9

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    Type: Predictable identifier generation. The toc plugin and TableOfContents directive both default to generating heading IDs of the form toc1, toc2, toc3, ... with no input-derived component. An attacker who can place a heading anywhere in the document can predict which tocN ID it will receive, and can inject HTML elsewhere (in a non-heading context) that uses the same id="tocN" to either (a) shadow the legitimate heading anchor, breaking same-page navigation, or (b) collide with CSS or JavaScript that targets #tocN selectors, redirecting click handlers and styling to attacker-chosen content. File: src/mistune/toc.py line 36-37 (headingid = lambda token, index: "toc" + str(index + 1)); src/mistune/directives/toc.py line 33 (same default). Root cause: the default headingid callback ignores the heading's text content and uses only the headings's order in the document. Two documents rendered together (or one document with attacker-influenced headings spliced into trusted…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  5. Medium, CVSS 5.9PyPIAmendedPublished

    Mistune: Arbitrary File Read via Include directive path traversal

    CVE-2026-59924 · GHSA-r4rv-85jg-w4mf

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    A path traversal issue exists in mistune's Include directive when markdown files are processed using md.read(). A crafted include path can cause files outside the intended markdown directory to be accessed. Details The issue occurs in the Include.parse() method where user-supplied paths are joined and normalized without verifying that the resulting path remains within an expected directory. Because the final path is not restricted to a trusted base directory, path traversal sequences such as ../ may reference files outside the intended location. Proof of Concept Create a markdown file: Process it using: Impact Applications that process untrusted markdown files with the Include directive enabled may allow unintended file access. The impact depends on how the feature is used and what files are accessible to the running process. Recommended Fix Validate the resolved path and ensure it remains within an allowed directory before opening the file.

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  6. High, CVSS 7.5PyPIAmendedPublished

    Mistune plugins/formatting: quadratic-time parsing on long runs of ~~x~~, ==x==, and ^^x^^ markers (strikethrough / mark / insert)

    CVE-2026-59922 · GHSA-c8j7-8cv4-2xmq

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    Type: Algorithmic-complexity denial of service. A run of N closed pairs ~~x~~~~x~~... (or the analogous ==x== for mark, ^^x^^ for insert) causes O(N²) work in the formatting parser. With the strikethrough, mark, or insert plugin enabled, an 8 KB input pegs the CPU for ~4 seconds; 16 KB → ~17 seconds. File: src/mistune/plugins/formatting.py, lines 13-15 (the STRIKEEND / MARKEND / INSERTEND patterns and their per-position scan). Root cause: for each opening ~~/==/^^ the parser scans forward for the matching close pattern. The scan itself uses a bounded regex, but the parser tries the close-scan at every potential start position. For input shaped like ~~x~~ repeated N times, every ~~ is examined as a possible start, each scan covers up to the end of input. Total work is O(N²). Default config without these plugins handles the same input in linear time (4 ms for 4000 reps), confirming the cost is in the formatting plugin's per-marker scan, not in core parsing. Affected Code File:…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  7. Medium, CVSS 5.3PyPIAmendedPublished

    Mistune: XSS via unescaped class option in Admonition directive

    CVE-2026-59926 · GHSA-g97x-gvcm-x72h

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    In src/mistune/directives/admonition.py, the renderadmonition() function concatenates the :class: option directly into the HTML class attribute without escaping (lines 63-68). This allows attribute injection and XSS even when HTMLRenderer(escape=True) is used. The directive name parameter is safe (validated against whitelist), but the class option comes from raw user input.

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  8. Medium, CVSS 6.1PyPIAmendedPublished

    Mistune: XSS via percent-encoded javascript URI bypass in safe_url()

    CVE-2026-59923 · GHSA-8c25-4j27-2rv3

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    An XSS vulnerability in Mistune allows bypassing of safeurl() protections via percent-encoded javascript URIs. Details The vulnerability exists in HTMLRenderer.safeurl() in Mistune. The function is intended to block harmful URL schemes such as "javascript:" by checking the prefix of the provided URL: url = url.lower() if url.startswith(self.HARMFULPROTOCOLS): return "#harmful-link" However, the input URL is not URL-decoded before this check. Because of this, an attacker can use percent-encoding to bypass the filter. For example: javascript%3Aalert(1) Since "%3A" is not decoded to ":", the check does not detect the "javascript:" scheme. When rendered in a browser, the URL is decoded, resulting in execution of arbitrary JavaScript upon user interaction. This effectively bypasses Mistune's built-in safeurl() protection mechanism. PoC 1. Install vulnerable version: pip install mistune==3.2.0 2. Run the following code: import mistune markdown = mistune.createmarkdown() html =…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  9. High, CVSS 7.5PyPIAmendedPublished

    Mistune inline_parser: quadratic-time parsing on long runs of **x** and ***x*** emphasis pairs

    CVE-2026-59925 · GHSA-4j32-57v6-6g45

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    Type: Algorithmic-complexity DoS in core emphasis parsing. A long sequence of well-formed x (strong) or x (strong-emphasis combined) pairs causes O(N²) parser work. Distinct from the bracket-bomb DoS ([ repetition) and from the formatting-plugin DoS (~~/==/^^); this one fires on default-config mistune with no plugins required. File: src/mistune/inlineparser.py lines 41-48 (the EMPHASISENDRE family) and the surrounding emphasis dispatch. Root cause: for every opening run of s the parser scans forward using one of EMPHASISENDRE[''] / [''] / [''] to find the matching close. Each scan is bounded per call, but the parser invokes the scan from every potential start position. For input shaped x repeated N times, every is treated as a potential start, each scan can cover up to the end of input. Total work is O(N²). The triple-emphasis variant x is slightly worse due to the extra alternation between , , and close patterns. Reproducible against default mistune with no plugins. Affected…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  10. Medium, CVSS 5.3PyPIAmendedPublished

    Mistune directives/include: mutual .. include:: recursion crashes the renderer with RecursionError, denial of service via two attacker-controlled markdown files

    CVE-2026-59927 · GHSA-8mpj-m6qm-5qr8

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    Type: Uncontrolled recursion via mutual include. The Include directive checks for direct self-reference (a.md cannot include a.md), but does not detect indirect cycles. Two markdown files that include each other (a.md → includes b.md → includes a.md) cause unbounded recursion until Python's stack limit fires RecursionError. The exception propagates out of the renderer and crashes the calling code. File: src/mistune/directives/include.py, lines 33-37 (the self-include check is the only cycle-detection logic). Root cause: the include logic only compares os.path.abspath(dest) == os.path.abspath(sourcefile). There is no per-render set of "files already included" that would catch transitive cycles. When a.md includes b.md, the recursive block.parse(newstate) call uses dest (b.md) as the new file, which then includes a.md (passing the self-check, because the immediate parent file is b.md, not a.md), which then includes b.md, and so on. Each recursion level adds Python frames; the…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  11. High, CVSS 7.5PyPIAmendedPublished

    Mistune block_parser: quadratic-time parsing on long lists of repeated reference-link definitions

    CVE-2026-59928 · GHSA-ffq3-xpv3-j92q

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    Type: Algorithmic-complexity DoS in reference-link definition handling. A markdown document with N reference-link definitions of the same key (or many distinct keys) takes O(N²) parser time. 5000 repeated [a]: u\n definitions take ~1.1 second; 10000 → ~4.5 seconds. File: src/mistune/blockparser.py (reference-link def parsing) and the surrounding reflinks env-dictionary handling. Root cause: every reference definition is parsed by scanning forward from each candidate position. The unikey normalisation runs per-def, the dictionary insert is per-def, and the lookup-by-label-then-iterate-defs path is linear in the number of stored defs. For input with N defs, the total work is O(N²). Affected Code src/mistune/blockparser.py — reference-definition rule fires on every line that matches [label]: url. For each one: - unikey(label) is called (linear scan of the label). - The def is appended to state.env['reflinks']. - Later inline-link resolution looks up by unikey(label) in the dict…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  12. High, CVSS 8.7PyPIAmendedPublished

    Mistune: Potential DoS via quadratic-time parsing in parse_link_text

    CVE-2026-49851 · GHSA-qcq2-496w-v96p

    Affected
    • PyPI mistune < 3.3.0
    Fixed in
    3.3.0· Vendor fix available
    Issue
    Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parselinktext. A relatively small input consisting of repeated [ characters causes significant parsing slowdown. Affected component mistune/inlineparser.py → parselinktext Description When parsing Markdown containing many consecutive [ characters, parselinktext repeatedly scans the input using a regex search inside a loop. Each iteration re-scans a large portion of the remaining string, resulting in quadratic-time behavior. An attacker-controlled Markdown input can therefore trigger excessive CPU usage with a very small payload. Root cause The vulnerability stems from a two-loop interaction: - The outer loop in InlineParser.parse() (inlineparser.py) advances only 1 character at a time when parselink() returns None - Each failed attempt calls parselinktext() which performs an O(n) scan to the end of the string looking for a closing ] - With n consecutive characters, this…

    Recommended action: Upgrade to 3.3.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  13. Medium, CVSS 4.7PyPIAmendedPublished

    Mistune Image Directive CSS Injection Vulnerability

    CVE-2026-44899 · GHSA-ccfx-mfmx-2fx9

    Affected
    • PyPI mistune >= 3.2.0, <= 3.2.0
    Fixed in
    3.2.1· Vendor fix available
    Issue
    The Image directive plugin validates the :width: and :height: options with a regex compiled as numre = re.compile(r"^\d+(?:\.\d)?"). This pattern is applied via re.match() (which anchors only at the start of the string, not the end). Any value that begins with one or more digits passes validation, regardless of what follows. When the validated value is not a plain integer, renderblockimage() inserts it directly into a style="width:...;" or style="height:...;" attribute. Because the value was accepted by the prefix-only regex, any CSS after the leading digits reaches the style= attribute verbatim and without escaping. An attacker can therefore inject an arbitrary chain of CSS properties — including position:fixed, background-color, z-index, outline, and opacity — using nothing more than a single :width: option in a fenced image directive. The resulting element can visually cover the entire browser viewport, enabling full-page phishing overlays and UI redressing attacks.…

    Recommended action: Upgrade to 3.2.1 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  14. Medium, CVSS 6.1PyPIAmendedPublished

    Mistune TOC Anchor Injection XSS

    CVE-2026-44898 · GHSA-6269-cqxg-mhhv

    Affected
    • PyPI mistune >= 3.2.0, <= 3.2.0
    Fixed in
    3.2.1· Vendor fix available
    Issue
    rendertocul() builds a <ul table-of-contents tree from a list of (level, id, text) tuples. Both the id value (used as href="#<id") and the text value (used as the visible link label) are inserted into <a tags via a plain Python format string — with no HTML escaping applied to either value. When heading IDs are derived from user-supplied heading text (the standard use-case for readable slug anchors), an attacker can craft a heading whose text breaks out of the href="#..." attribute context, injecting arbitrary HTML tags including <script blocks directly into the rendered TOC. This vulnerability is closely related to H2 (unescaped id= in heading()): the same headingid callback pattern that triggers H2 also populates the tocitems list that rendertocul() consumes, meaning both vulnerabilities fire simultaneously in a typical documentation setup. Details File: src/mistune/toc.py The k and text values come directly from the tocitems list accumulated during parsing. If k contains "…

    Recommended action: Upgrade to 3.2.1 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  15. Medium, CVSS 6.1PyPIAmendedPublished

    Mistune Heading ID Attribute has Injection XSS

    CVE-2026-44897 · GHSA-v87v-83h2-53w7

    Affected
    • PyPI mistune <= 3.2.0
    Fixed in
    3.2.1· Vendor fix available
    Issue
    HTMLRenderer.heading() builds the opening <hN tag by string-concatenating the id attribute value directly into the HTML — with no call to escape(), safeentity(), or any other sanitisation function. A double-quote character " in the id value terminates the attribute, allowing an attacker to inject arbitrary additional attributes (event handlers, src=, href=, etc.) into the heading element. The default TOC hook assigns safe auto-incremented IDs (toc1, toc2, …) that never contain user text. However, the addtochook() API accepts a caller-supplied headingid callback. Deriving heading IDs from the heading text itself — to produce human-readable slug anchors like #installation or #getting-started — is by far the most common real-world usage of this callback (every major documentation generator does this). When the callback returns raw heading text, an attacker who controls heading content can break out of the id= attribute. Details File: src/mistune/renderers/html.py The text body…

    Recommended action: Upgrade to 3.2.1 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  16. Medium, CVSS 5.3PyPIAmendedPublished

    Mistune has XSS via unescaped figclass/figwidth in Figure directive

    CVE-2026-44896 · GHSA-58cw-g322-p94v

    Affected
    • PyPI mistune <= 3.2.0
    Fixed in
    3.2.1· Vendor fix available
    Issue
    In src/mistune/directives/image.py, the renderfigure() function concatenates figclass and figwidth options directly into HTML attributes without escaping (lines 152-168). This allows attribute injection and XSS even when HTMLRenderer(escape=True) is used, because these values bypass the inline renderer. Other attributes in the same file (src, alt, style) are properly escaped; figclass/figwidth were missed.

    Recommended action: Upgrade to 3.2.1 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  17. High, CVSS 8.7PyPIAmendedPublished

    Mistune has a ReDoS in LINK_TITLE_RE that allows denial of service via crafted Markdown input

    CVE-2026-33079 · GHSA-8mp2-v27r-99xp

    Affected
    • PyPI mistune >= 3.0.0a1, <= 3.2.0
    Fixed in
    3.2.1· Vendor fix available
    Issue
    A ReDoS (Regular Expression Denial of Service) vulnerability in LINKTITLERE allows an attacker who can supply Markdown for parsing to cause denial of service. A crafted 58-byte Markdown document blocks the parser for approximately 6 seconds (measured on Apple M2, Python 3.14.3), with exponential growth per additional byte pair. Details The vulnerable regex is defined in src/mistune/helpers.py#L20-L25: The double-quote branch compiles to "(?:\\[PUNCTUATION]|[^"\x00])". The two alternatives inside (A|B) overlap: a backslash followed by a punctuation character (e.g. \!) can be matched by either branch — as a 2-character escaped-punctuation sequence \\!, or as two individual [^"\x00] characters (\ then !). The same ambiguity exists in the single-quoted title branch. When the input contains repeated \! pairs with no closing ", the regex engine exhaustively backtracks through all 2^N combinations, resulting in exponential O(2^N) time complexity. This is reachable through normal…

    Recommended action: Upgrade to 3.2.1 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  18. High, CVSS 8.8PyPIAmendedPublished

    Mistune vulnerable to catastrophic backtracking

    CVE-2022-34749 · GHSA-fw3v-x4f2-v673

    Affected
    • PyPI mistune >= 2.0.0a1, < 2.0.3
    Fixed in
    2.0.3· Vendor fix available
    Issue
    In Mistune through 2.0.2, support of inline markup is implemented by using regular expressions that can involve a high amount of backtracking on certain edge cases. This behavior is commonly named catastrophic backtracking.

    Recommended action: Upgrade to 2.0.3 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  19. Medium, CVSS 6.1PyPIAmendedPublished

    Cross-site Scripting in Mistune

    CVE-2017-15612 · GHSA-hpv5-v8g5-c864

    Affected
    • PyPI mistune < 0.8
    Fixed in
    0.8· Vendor fix available
    Issue
    mistune.py in Mistune 0.7.4 allows XSS via an unexpected newline (such as in java\nscript:) or a crafted email address, related to the escape and autolink functions.

    Recommended action: Upgrade to 0.8 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →
  20. Medium, CVSS 5.1PyPIAmendedPublished

    mistune Cross-site scripting (XSS) vulnerability

    CVE-2017-16876 · GHSA-98gj-wwxm-cj3h

    Affected
    • PyPI mistune < 0.8.1
    Fixed in
    0.8.1· Vendor fix available
    Issue
    Cross-site scripting (XSS) vulnerability in the keyify function in mistune.py in Mistune before 0.8.1 allows remote attackers to inject arbitrary web script or HTML by leveraging failure to escape the "key" argument.

    Recommended action: Upgrade to 0.8.1 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:osv.dev (1)github.com (2)Source checked Evidence →