GHSA-5vp3-3cg6-2rq3: Justhtml Cross-Site Scripting Vulnerability
HIGHGHSA-5vp3-3cg6-2rq3 is a HIGH cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Justhtml libraries in the PyPI ecosystem. The issue involves justhtml is vulnerable to xss via code fence breakout in <pre> content. Remediation is available by upgrading affected packages to version 1.13.0.
GHSA-5vp3-3cg6-2rq3 at a Glance
How to Fix GHSA-5vp3-3cg6-2rq3
To remediate this vulnerability, upgrade all affected Justhtml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install justhtml>=1.13.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show justhtml
How to Check if You Are Affected
To determine whether your Python environment is affected by GHSA-5vp3-3cg6-2rq3, inspect your installed packages using pip:
pip show justhtml
Analyze the terminal output to locate any version of Justhtml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.13.0), your application is affected.
Note: The pip show justhtml command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Justhtml, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-5vp3-3cg6-2rq3 Affected Justhtml Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
justhtml
|
PyPI |
< 1.13.0
|
1.13.0
|
References
Frequently Asked Questions
What is GHSA-5vp3-3cg6-2rq3?
Which Justhtml versions are affected?
What version fixes GHSA-5vp3-3cg6-2rq3?
Is justhtml affected?
What CWE is associated with GHSA-5vp3-3cg6-2rq3?
How can I check PyPI dependencies for GHSA-5vp3-3cg6-2rq3?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-5vp3-3cg6-2rq3",
"modified" : "2026-03-24T19:22:21Z",
"published" : "2026-03-24T19:22:21Z",
"aliases" : [ ],
"summary" : "JustHTML is vulnerable to XSS via code fence breakout in <pre> content",
"details" : "## Summary\n\n`to_markdown()` is vulnerable when serializing attacker-controlled `<pre>` content. The `<pre>` handler emits a fixed three-backtick fenced code block, but writes decoded text content into that fence without choosing a delimiter longer than any backtick run inside the content.\n\nAn attacker can place backticks and HTML-like text inside a sanitized `<pre>` element so that the generated Markdown closes the fence early and leaves raw HTML outside the code block. When that Markdown is rendered by a CommonMark/GFM-style renderer that allows raw HTML, the HTML executes.\n\nThis is a bypass of the v1.12.0 Markdown hardening. That fix escaped HTML-significant characters for regular text nodes, but `<pre>` uses a separate serialization path and does not apply the same protection.\n\n## Details\n\nThe vulnerable `<pre>` Markdown path:\n\n- extracts decoded text from the `<pre>` subtree\n- opens a fenced block with a fixed delimiter of ``````\n- writes the decoded text directly into the output\n- closes with another fixed ``````\n\nBecause the fence length is fixed, attacker-controlled content containing a backtick run of length 3 or more can terminate the code block. If the content also contains decoded HTML-like text such as `<img ...>`, that text appears outside the fence in the resulting Markdown and is treated as raw HTML by downstream Markdown renderers.\n\nThe issue is not that HTML-like text appears inside code blocks. The issue is that the serializer allows attacker-controlled `<pre>` text to break out of the fixed fence.\n\n## Reproduction\n\n```python\nfrom justhtml import JustHTML\n\npayload = \"<pre>```\\n<img src=x onerror=alert(1)></pre>\"\ndoc = JustHTML(payload, fragment=True) # default sanitize=True\n\nprint(doc.to_html(pretty=False))\n# <pre>```\n# <img src=x onerror=alert(1)></pre>\n\nprint(doc.to_markdown())\n# ```\n# ```\n# <img src=x onerror=alert(1)>\n# ```\n\n```\n\nRendered as CommonMark/GFM-style Markdown, that output is interpreted as:\n\n1. Line 1 opens a fenced code block\n2. Line 2 closes it\n3. Line 3 is raw HTML outside the fence\n4. Line 4 opens a new fence\n\n## Impact\n\nApplications that treat `JustHTML(..., sanitize=True).to_markdown()` output as safe for direct rendering in Markdown contexts may be exposed to XSS, depending on the downstream Markdown renderer's raw-HTML handling.\n\n## Root Cause\n\nThe `<pre>` Markdown serializer uses a fixed fence instead of selecting a delimiter longer than the longest backtick run in the content.\n\n## Fix\n\nWhen serializing `<pre>` content to Markdown, choose a fence length longer than any backtick run present in the code block content, with a minimum length of 3.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "justhtml"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.13.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.12.0"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/EmilStenstrom/justhtml/security/advisories/GHSA-5vp3-3cg6-2rq3"
}, {
"type" : "WEB",
"url" : "https://github.com/EmilStenstrom/justhtml/commit/f35f8f723c713bd8f912d86e9ec6881275ff5af9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/EmilStenstrom/justhtml"
}, {
"type" : "WEB",
"url" : "https://github.com/EmilStenstrom/justhtml/releases/tag/v1.13.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79", "CWE-80" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-24T19:22:21Z",
"nvd_published_at" : null
}
}