Skip to content
Putting technology to work.
Insights to guide decisions and action.

Search articles

Mistune 3.3.3 takes 32 seconds on 72 KB: two Markdown conversion issues

Table of contents · 5 items

Some web apps convert Markdown written by users, such as inquiry messages, internal bulletin boards or ticket comments, into HTML on the server for display. Mistune is one of the Python libraries that can be used for this, and nbconvert, which converts Jupyter notebooks into HTML and other formats, also depends on it. Two issues have been found in Mistune where a single input of a few dozen KB stalls conversion for tens of seconds.

On November 19, 2026, two Mistune issues (GHSA-ww7q-mxrj-5ffg / CVE-2026-97699 and GHSA-phmp-hrw4-r36r / CVE-2026-97698, both HIGH) were added to GitHub's advisory database. They had been published in the Mistune repository on October 19, the same day as 3.4.0. Versions below 3.3.4 are affected, and 3.3.4 was released on PyPI on July 22. Based on the advisories and the results of passing the same input to 3.3.3, 3.3.4 and 3.4.0 in our working environment, this article sorts out the steps for upgrading and checking.

What input causes the stall

Both issues are in the processing that parses links and images in Markdown, where time grows in proportion to the square of the input length. No special settings or plugins are needed; they occur with the default conversion (mistune.html()).

  • Image syntax (GHSA-ww7q-mxrj-5ffg): input with N repetitions of ![, then x, then N repetitions of ]. For each image opening marker, the rest of the text was searched again from scratch. According to the advisory, a safeguard in the link handling did not apply under the conditions for images.
  • Empty links (GHSA-phmp-hrw4-r36r): input that simply repeats [](. For each ( after the empty label [], the closing bracket was searched for all the way to the end of the document.

In both cases, if such input is accepted in a field that users who are not logged in can submit, a single request can use up a worker. The advisory says, 'A single unauthenticated request pins a worker at 100% CPU.' If several are sent at the same time, other users' requests may also be kept waiting.

On the same day, October 19, another HIGH issue (GHSA-qp42-r9j6-83g9) was also published in the repository. With input that repeats *a_b, the handling of emphasis markers grows quadratically; versions 3.3.0 to 3.3.3 are affected, and the fix is the same 3.3.4. As of November 24, this issue had not been added to GitHub's advisory database. It may not appear in notifications based on the database, so judge by the version you have installed. We did not measure the processing time for this issue in this article.

Results of passing the same input to 3.3.3 and 3.3.4

On November 23, 2026, in our working container (Linux, 4 vCPU, Python 3.11.18), we installed 3.3.3, 3.3.4 and 3.4.0 from PyPI into separate virtual environments and passed the two input patterns above, at varying sizes, to mistune.html(). We ran each condition three times and show the shortest time.

Input (size)3.3.33.3.43.4.0
Image syntax (about 9 KB)0.49 s0.02 s0.01 s
Image syntax (about 36 KB)7.7 s0.08 s0.04 s
Image syntax (about 72 KB)31.8 s0.15 s0.09 s
Empty links (about 6 KB)0.64 s0.01 s0.06 s
Empty links (about 24 KB)10.1 s0.03 s0.12 s
Empty links (about 48 KB)41.9 s0.07 s0.27 s

In 3.3.3, doubling the input roughly quadrupled the time. This is almost the same growth as the advisories' '2x input -> ~3.8x time' (for the image syntax issue; '~3.9x' for the empty link issue). In 3.3.4 and 3.4.0, even 48 to 72 KB finished within 0.3 seconds at the shortest time (the longest of the three runs was 0.39 seconds, for empty links of about 48 KB on 3.4.0).

Comparison of Mistune processing times for the same input. Input with about 72 KB of image syntax took 31.8 seconds on 3.3.3 and 0.15 seconds on 3.3.4. Input with about 48 KB of empty links took 41.9 seconds on 3.3.3 and 0.07 seconds on 3.3.4. Shortest time of three runs each in our working container

The results were the same with the setting that does not pass HTML through as is (mistune.create_markdown(); escape=True by default) (one run per condition; another build was running in the same environment during measurement). On 3.3.3, image syntax of about 36 KB took 7.9 seconds, and empty links of about 24 KB took 10.6 seconds. The HTML handling setting is not a workaround for this issue. On the other hand, ordinary text containing emphasis, links and images (about 43 KB) took around 0.04 seconds on every version.

These measurements come from a single working environment and do not indicate the performance of production servers. The editorial team has kept the scripts used for measurement and the full results.

What to check before and after upgrading (editorial suggestion)

  1. Check the installed version. Even if your app does not use it directly, it may be installed as a dependency of another package. Check the version with pip show mistune or uv pip list. For example, nbconvert 7.17.2 requires mistune<4,>=2.0.3, so older environments may still have 3.3.3 or earlier.
  2. Upgrade to 3.3.4 or later. As of November 24, the latest is 3.4.0 (October 19). According to the changelog, 3.4.0 requires Python 3.10 or later and reworks how links are parsed. The unreleased section of the changelog also mentions a plan to drop support for Python 3.10 in the next version. Because the output may change, use 3.3.4 if you stay on the 3.3 series, and if you move to 3.4.0, compare the conversion results in your own tests before deploying.
  3. Put a limit on input size. Mistune's documentation (Security model) states that escape=True is not a general-purpose HTML sanitizer and is not a substitute for measures such as application-level request size limits or process isolation. Limiting the length of Markdown accepted through forms and APIs, and setting a time limit on conversion, also helps against other similar problems.
  4. Check whether you use mistune.html. The same document says that mistune.html is a compatibility parser built on escape=False, and that it must not be used for untrusted input unless the output is passed through a separate HTML sanitizer. If the code that converts user input uses mistune.html(), consider switching to create_markdown() along with this update.

Scope of verification

On November 22–23, 2026, we reviewed the JSON for GHSA-ww7q-mxrj-5ffg and GHSA-phmp-hrw4-r36r in github/advisory-database (both published on November 19, 2026), commit b4dd328 and the v3.3.4 tag in lepture/mistune, docs/changes.rst (3.3.4 and 3.4.0) and docs/security.rst, the versions and release dates on PyPI, and the dependency declaration of nbconvert 7.17.2 (document research). On November 24, we rechecked the advisory in the lepture/mistune repository (its publication date and GHSA-qp42-r9j6-83g9) and the latest version on PyPI. We also measured the processing time of 3.3.3, 3.3.4 and 3.4.0 in a working container (hands-on testing). We have not tested it embedded in a web application, nor tried to reproduce the issue in nbconvert or Jupyter.

We covered how to keep checking Python dependencies for vulnerabilities in our article on uv audit, and a case where regular expression processing time became a problem in our article on Ruby regular expressions.

GleamHub's development, AI and automation consulting covers maintaining web applications that handle user input and planning dependency updates. Please reach out through our contact form.

References

Share this articleXFacebook
Kakeru Suzuki

Fascinated by the possibilities of technology, has had a deep interest in programming and digital art since student days

Turn this article's theme into your company's next step

Concrete steps forward for your organization.

We organize your desired architecture, legacy systems, and operational requirements to formulate your next steps toward execution.

  • Desired architecture
  • Integration with existing environments
  • Operational requirements
Consult on development & operations initiatives

You can consult with us from the initial conceptual stage. Details from this article will be carried over to the inquiry form.

Receive the latest articles by email