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

Source: https://junglewise.ai/threats/cve-2026-5389-justhtml-to-markdown-cross-site-scripting-via-code-fence-breakout  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-23. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

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)](https://junglewise.ai/threats/technologies/justhtml). Vendors: [PyPI](https://junglewise.ai/threats/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

  ```sh
  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 &lt;pre&gt; elements (CWE-80). When converting &lt;pre&gt; 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 &lt;pre&gt; 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

- [https://github.com/EmilStenstrom/justhtml/security/advisories/GHSA-5vp3-3cg6-2rq3](https://github.com/EmilStenstrom/justhtml/security/advisories/GHSA-5vp3-3cg6-2rq3)
- [https://www.vulncheck.com/advisories/justhtml-before-xss-via-code-fence-breakout](https://www.vulncheck.com/advisories/justhtml-before-xss-via-code-fence-breakout)

## Related threats

- [justhtml uncontrolled recursion DoS via deeply nested HTML](https://junglewise.ai/threats/justhtml-uncontrolled-recursion-dos-via-deeply-nested-html-26591bb6)
- [JustHTML uncontrolled recursion DoS via deeply nested HTML](https://junglewise.ai/threats/cve-2026-9769-justhtml-uncontrolled-recursion-dos-via-deeply-nested-html)
- [justhtml mutation XSS in raw-text element serialization](https://junglewise.ai/threats/cve-2026-8630-justhtml-mutation-xss-in-raw-text-element-serialization)
- [justhtml HTML escaping bypass in Markdown conversion](https://junglewise.ai/threats/cve-2026-8445-justhtml-html-escaping-bypass-in-markdown-conversion)
- [justhtml HTML sanitization bypass leading to XSS](https://junglewise.ai/threats/cve-2026-7808-justhtml-html-sanitization-bypass-leading-to-xss)
