#1135942 mistune: CVE-2026-33079

Package:
src:mistune
Source:
src:mistune
Submitter:
Salvatore Bonaccorso
Date:
2026-11-06 17:03:01 UTC
Severity:
normal
Tags:
#1135942#5
Date:
2026-05-07 12:28:52 UTC
From:
To:
Hi,

The following vulnerability was published for mistune.

CVE-2026-33079[0]:
| In versions 3.0.0a1 through 3.2.0 of Mistune, there is a ReDoS
| (Regular Expression Denial of Service) vulnerability in
| `LINK_TITLE_RE` that allows an attacker who can supply Markdown for
| parsing to cause denial of service. The regular expression used for
| parsing link titles contains overlapping alternatives that can
| trigger catastrophic backtracking. In both the double-quoted and
| single-quoted branches, a backslash followed by punctuation can be
| matched either as an escaped punctuation sequence or as two ordinary
| characters, creating an ambiguous pattern inside a repeated group.
| If an attacker supplies Markdown containing repeated ! sequences
| with no closing quote, the regex engine explores an exponential
| number of backtracking paths. This is reachable through normal
| Markdown parsing of inline links and block link reference
| definitions. A small crafted input can therefore cause significant
| CPU consumption and make applications using Mistune unresponsive.

Note there is no upstream fix at time of writing for this, but filling
a bug for tracking.

If you fix the vulnerability please also make sure to include the
CVE (Common Vulnerabilities & Exposures) id in your changelog entry.

For further information see:

[0] https://security-tracker.debian.org/tracker/CVE-2026-33079
https://www.cve.org/CVERecord?id=CVE-2026-33079
[1] https://github.com/lepture/mistune/security/advisories/GHSA-8mp2-v27r-99xp

Regards,
Salvatore

#1135942#12
Date:
2026-11-06 17:02:10 UTC
From:
To:
Hi,

This is about CVE-2026-33079 (bug #1135942), the ReDoS in mistune's quoted
link-title scanner.

Current state and affectedness
------------------------------
The vulnerable code is the LINK_TITLE_RE regular expression in the helpers
module. Its catch-all character class also matches a backslash, so a
backslash
that begins an escape can be consumed either by the escape alternative or
by the
catch-all; an unterminated title built from many backslash-bang pairs then
triggers catastrophic backtracking (CWE-1333).

Upstream removed LINK_TITLE_RE entirely in 3.3.0 (commit 5de41fb8e527, which
rewrote the title parser as a linear character scan with no backtracking).
Versions 3.2.0 and 3.2.1 still contain the regex; 3.3.0 and later do not.

Mapping that to Debian:
bookworm 2.0.4-1 not affected (predates the regex; already marked so)
trixie 3.1.3-1 affected (regex present)
forky 3.1.4-1 affected (regex present)
sid 3.4.0-1 not affected (ships the 3.3.0+ linear parser)

So unstable (3.4.0-1) is no longer affected and the tracker's unstable
entry can
be moved to fixed; the "revisit when fixed upstream" note is resolved,
since it
was fixed upstream in 3.3.0. trixie and forky still carry the regex.

Backport for the still-affected 3.1.x
-------------------------------------
The 3.3.0 rewrite is too large to backport to a stable release, so the
attached
patch makes the existing regex non-backtracking instead: a backslash is
consumed
only by the escape alternative (backslash plus any one character, newline
included), and the catch-all class excludes backslash. The two alternatives
can
then no longer both consume a backslash. The set of accepted titles is
unchanged
-- an escaped character (including an escaped quote) is still one unit, and
a
title may still span lines. The patch applies cleanly to both 3.1.3-1
(trixie)
and 3.1.4-1 (forky); the diff is identical for both.

Verification (installed 3.1.4-1, module used only as a library)
---------------------------------------------------------------
Reproducer: an inline link whose title is many backslash-bang pairs, left
unterminated.
- End to end through create_markdown(): N=18 pairs about 190 ms, N=24
exceeds
8 s (hard-killed).
- The regex alone, 5 s hard timeout per match: shipped regex N=20 about
485 ms, N=25 times out; patched regex stays about 27 ms through N=1000.
- The compiled pattern extracted from the shipped trixie and forky helpers
equals the one benchmarked as vulnerable; the patched pattern equals the
safe one.
- Behaviour check: shipped vs patched regex produce identical matches
across a
battery of valid and edge-case titles (escaped quote, escaped backslash,
backslash-letter, tab, embedded newline, unicode, parentheses, brackets,
empty) for both quote styles -- zero differences.

The DEP-3 header in the patch records the upstream commit and this bug.

Thanks,
Sumit Verma