GitHub Advisoryadvisory · PyPI

GHSA-3rcm-vjrc-p45j JustHTML has a Sanitizer Bypass (in Markdown)

MEDIUM Published 2026-03-18 Modified 2026-03-18 Official page ↗
Ecosystem
PyPI
Packages
justhtml
Severity
Moderate
CVSS vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
Weaknesses
CWE-79
Reviewed
2026-03-18

Affected packages

• PyPI justhtml: < 1.12.0 → fixed in 1.12.0

Description

Summary `to_markdown()` does not sufficiently escape text content that looks like HTML. As a result, untrusted input that is safe in `to_html()` can become raw HTML in Markdown output. This is not specific to tokenizer raw-text states like ``, ``, or ``, although those states can trigger the behavior. The root cause is broader: Markdown text serialization leaves angle brackets unescaped in text nodes. Details When converting a parsed document to Markdown, text nodes are escaped for a small set of Markdown metacharacters, but HTML-significant characters such as `` are preserved. That means content parsed as text, including entity-decoded text or text produced by RCDATA/RAWTEXT-style parsing, can be emitted into Markdown as raw HTML. Examples of affected input include: • Text produced from entity-decoded input such as `&lt;script&gt;...&lt;/script&gt;` • Text inside elements like ``, ``, `` (when parsed as raw text), and `` This is distinct from actual `` or `` elements in the DOM. Those are already dropped by default in `to_markdown()` unless `html_passthrough=True`. Proof of Concept General case ```python from justhtml import JustHTML doc = JustHTML("&lt;img src=x onerror=alert(1)&gt;", fragment=True) print(doc.to_html()) print() print(doc.to_markdown())

Related

Weakness · CWE (1)

  • CWE-79 Improper Neutralization of Input During Web Page Generation weakness

References