CVE-2026-5389: justhtml to_markdown() cross-site scripting via code fence breakout

CVE-2026-5389 · Severity: medium · CVSS 6.1 · Published 2026-08-23

justhtml is a Python library for sanitizing and converting HTML to Markdown. A flaw in the to_markdown() function allows attackers to inject backticks inside code blocks, breaking out of fixed-length fences and exposing raw HTML to downstream Markdown renderers. When the resulting Markdown is rendered, the attacker-controlled HTML can execute, leading to cross-site scripting attacks in applications that treat the output as safe.

Technologies: justhtml (PyPI). Vendors: PyPI.

Quick answers

Is CVE-2026-5389 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-5389 being exploited in the wild.
How severe is CVE-2026-5389?
Medium severity, with a CVSS score of 6.1, published 23 August 2026.
Which products and versions are affected?
justhtml (PyPI) ECOSYSTEM:introduced=0,fixed=1.13.0.
Is there a fix for CVE-2026-5389?
Yes. justhtml (PyPI): upgrade to 1.13.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-5389 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-5389?
Check whether you run justhtml (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

  • justhtml (PyPI): upgrade to 1.13.0 or later
    pip install "justhtml>=1.13.0"

Technical details

The vulnerability is a cross-site scripting (XSS) bypass in the to_markdown() function's handling of HTML <pre> elements (CWE-80). When converting <pre> content to Markdown, the serializer wraps decoded text in fixed triple-backtick code fences (```) without checking if the content contains backtick sequences that could break the fence. An attacker can inject backtick runs (``` or longer) within sanitized <pre> elements to prematurely close the code block, allowing subsequent HTML-like text to appear outside the fence where it is treated as raw HTML by CommonMark/GFM renderers. No authentication is required; the attack is network-reachable and requires only user interaction (rendering the Markdown output). The vulnerability affects justhtml versions before 1.13.0, which patches the issue by dynamically selecting a fence length longer than the longest backtick run in the content.

Affected products

  • EmilStenstrom justhtml before 1.13.0

Identifiers

  • CVE-2026-5389
  • GHSA-5vp3-3cg6-2rq3

Timeline

  • 2026-03-21: disclosed
  • 2026-03-21: patched: Version 1.13.0 released
  • 2026-08-23: advisory: CVE-2026-5389 published

References

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