Severity:

CRITICAL RISK

(9.8)

Cross-Site Scripting (CWE-79) in justhtml Markdown

CVE-2026-8445

Deferred

Vulnerability type

Category:

Cross-Site Scripting

CWE:

CWE-79

Impact:

Client-Side Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

justhtml can preserve HTML-significant angle brackets when converting parsed text nodes to Markdown with to_markdown(). If untrusted content is rendered as HTML after conversion, this may bypass sanitization and enable cross-site scripting, particularly when text was entity-decoded or parsed from special HTML elements.

Affected context

The vulnerability occurs in applications that use justhtml to convert untrusted HTML or parsed document content into Markdown and subsequently render that Markdown in a browser or HTML-capable interface. It is most relevant when the conversion output is treated as sanitized content, while angle brackets from text nodes remain available for interpretation as raw HTML.

Exploit preconditions

  • Attack surface: The to_markdown() document-to-Markdown conversion path
  • Required access: Ability to supply or influence HTML, text-node, or document content processed by the application
  • Trigger point: Rendering the generated Markdown in a context that permits embedded HTML
  • Why exploitation is possible: HTML-significant characters such as < and > may remain unescaped, allowing content that appeared safe before conversion to be interpreted as markup after rendering

Why this happens

The underlying bug is incomplete output encoding during Markdown serialization. Although some Markdown metacharacters are escaped, angle brackets in text nodes are not consistently encoded as data, so entity-decoded text or content parsed from RCDATA and RAWTEXT-related elements can become raw HTML in the output. This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, because attacker-controlled content can cross a trust boundary without adequate context-appropriate escaping.

Potential impact

  • An attacker could execute script in the security context of a vulnerable application
  • Users may be exposed to session theft, phishing content, or unauthorized actions
  • Sanitization controls could be bypassed when they trust Markdown conversion as a safety boundary
  • Rendered content could be altered to distribute malicious links or misleading interface elements

General mitigation guidance

Mitigation generally focuses on treating Markdown conversion as a formatting operation rather than a complete sanitization boundary.

Common defensive patterns include:

  • Escape or encode HTML-significant characters when serializing text nodes
  • Apply a context-appropriate, allowlist-based sanitizer to the final rendered HTML
  • Disable or tightly restrict raw HTML support in Markdown renderers where it is not required
  • Keep untrusted content in a data-only rendering context instead of injecting it as markup
  • Separate trusted and untrusted content pipelines and apply least-privilege browser policies such as restrictive Content Security Policy controls

How teams detect issues like this

Organizations can detect this class of issue through:

  • Static analysis rules that identify Markdown-to-HTML flows lacking final output sanitization
  • Code review checks for serializers that escape selected Markdown characters but preserve < and >
  • Security tests covering entity-decoded text and content from special HTML parsing contexts
  • Dynamic tests that verify generated Markdown cannot introduce active HTML when rendered
  • Policy enforcement requiring approved, context-aware sanitizers before untrusted Markdown is displayed

Automated code review and dependency analysis tools may help identify unsafe rendering paths, but should be complemented by end-to-end output-encoding tests.

Sources

SourceLink
github.comgithub.com/EmilStenstrom/justhtml/security/advisories/GHSA-3rcm-vjrc-p45j
vulncheck.comvulncheck.com/advisories/justhtml-before-sanitizer-bypass-via-markdown

Frequently asked

questions

It can be, when a remotely supplied or otherwise untrusted document is converted to Markdown and the resulting content is rendered in a browser or another HTML-capable client.

Not necessarily. The required access depends on the application's content submission and rendering workflow; any ability to influence processed input may be sufficient.

Treat converted Markdown as untrusted, escape HTML-significant characters during serialization, and sanitize the final rendered HTML with a strict allowlist.

Use context-aware output encoding, avoid treating format conversion as sanitization, restrict raw HTML features, and test complete input-to-rendering flows with adversarial markup.

Find out what's already
exploitable in your codebase.