CVE-2026-5751 in justhtmlinfo

Summary

by MITRE • 08/23/2026

justhtml versions 1.13.0 and earlier contain a parser-differential / mutation cross-site scripting (mXSS) vulnerability when using a custom SanitizationPolicy that preserves foreign namespaces (e.g., drop_foreign_namespaces=False with allowlisted SVG/MathML elements or raw-text containers such as <style>). Specially crafted input can sanitize into markup that appears safe but becomes unsafe when re-parsed by a browser or another HTML parser, allowing markup injection. The default safe configuration (sanitize=True) is not affected. Fixed in 1.14.0.

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Analysis

by VulDB Data Team • 08/23/2026

The vulnerability identified in justhtml versions up to and including 1.13.0 represents a sophisticated cross-site scripting vector known as mutation-based XSS or mXSS. This class of attack exploits the discrepancy between how an HTML sanitizer processes input data and how web browsers subsequently parse that same markup for rendering. Unlike traditional stored or reflected XSS, which relies on injecting raw malicious scripts into unsanitized fields, this vulnerability targets the sanitization logic itself. The core issue arises when the library is configured to preserve foreign namespaces through a custom SanitizationPolicy where drop_foreign_namespaces is set to False while allowing specific elements such as SVG or MathML tags, or raw-text containers like style blocks. In these configurations, the sanitizer may produce output that appears structurally valid and safe according to its own rules, but this output contains subtle structural anomalies that trigger different parsing behaviors in downstream browser engines.

When a user-supplied payload is processed by justhtml under these specific settings, it can be transformed into markup that bypasses initial security checks. However, when this sanitized HTML is injected into the Document Object Model and subsequently re-parsed by the browser's native HTML parser, the structural differences cause the browser to interpret elements differently than intended. For instance, an element that was treated as a safe container during sanitization might be interpreted as executable script context or event handler attribute after DOM mutation. This allows attackers to inject arbitrary JavaScript code into the page execution context without triggering standard XSS filters, effectively bypassing content security policies and other client-side defenses designed to catch obvious injection attempts.

The operational impact of this vulnerability is significant for applications relying on rich text editing features or user-generated content that permits complex HTML structures. An attacker could craft a specially formatted input string that survives the sanitization phase but executes malicious scripts upon rendering in the victim's browser. This can lead to session hijacking, credential theft, defacement, or further propagation of malware within trusted web applications. The risk is particularly acute for platforms where users with elevated privileges create content visible to others, as it allows privilege escalation through script injection despite apparent compliance with security policies.

It is crucial to note that the default configuration of justhtml remains secure against this specific attack vector because sanitize mode defaults to True and does not preserve foreign namespaces by default. The vulnerability only manifests when developers explicitly opt into preserving SVG, MathML, or raw-text containers while disabling namespace dropping. This highlights a common pitfall in web security where flexibility features introduce complexity that can inadvertently weaken the overall defense-in-depth strategy if not carefully configured.

To mitigate this risk, organizations should immediately upgrade to justhtml version 14.0 and later, which includes fixes for these parsing discrepancies. For applications requiring custom sanitization policies involving foreign namespaces, developers must implement additional validation layers beyond what the library provides by default. This may include normalizing HTML output through a secondary pass using a stricter parser or employing Content Security Policy headers to restrict script execution sources. Regular security audits of sanitizer configurations are essential to ensure that permissive settings do not introduce exploitable edge cases in dynamic content rendering pipelines.

Responsible

VulnCheck

Reservation

04/07/2026

Disclosure

08/23/2026

Moderation

accepted

CPE

ready

EPSS

0.00000

KEV

no

Activities

low

Sources

Might our Artificial Intelligence support you?

Check our Alexa App!