Summary
Jodit Editor's built-in clean-html sanitizer can be bypassed using a MathML and <style> based carrier that hides dangerous elements during the sanitizer's DOM walk.
If an application feeds attacker-controlled HTML into the editor and later renders the sanitized value via innerHTML, a scriptable event handler (for example, an <img onload=...>) may execute without any user interaction.
Affected context
This vulnerability appears in web applications that embed Jodit Editor (pre-4.12.28) and rely on its clean-html sanitizer as the primary defense against malicious HTML.
It becomes relevant when untrusted or attacker-influenced HTML is passed into Jodit's value-setting or content insertion APIs, and consumers later inject the resulting editor value directly into the DOM via mechanisms like element.innerHTML = editor.value or template bindings that behave similarly.
The issue is not tied to a specific backend and can surface anywhere the editor's sanitized output is treated as safe HTML and rendered in a browser context.
Exploit preconditions
- Attack surface: Web front-end where Jodit Editor is integrated and its sanitized output is rendered into the DOM.
- Required access: Ability for an attacker to influence HTML supplied to the editor's value-set or insertion paths (e.g., posting content, editing rich text, or providing HTML via an API).
- Trigger point: Application takes the editor's sanitized value and injects it into the page using HTML sinks like
innerHTML,dangerouslySetInnerHTML, or equivalent templating constructs. - Why exploitation is possible: The MathML/<style>-based structure hides dangerous elements from the sanitizer's traversal, letting event-handler attributes such as
onloadoronfocussurvive. When the sanitized HTML is reinserted into the DOM, the browser activates these handlers, enabling script execution without user interaction.
Why this happens
The root cause is an incomplete HTML sanitization strategy that assumes a straightforward DOM tree walk will encounter all actionable elements and attributes.
By leveraging specific markup combinations (e.g., MathML with embedded <style>), attackers can create nodes that either are not visited or are misclassified during the sanitizer's element walk. As a result, event handler attributes like onload on <img> elements remain intact and executable in the final output.
This maps to CWE-79 (Improper Neutralization of Input During Web Page Generation) and CWE-83 (Improper Neutralization of Script in Attributes in a Web Page), where user-controlled HTML and attributes are not fully neutralized before being merged into the rendered page.
Potential impact
- Attackers could execute arbitrary JavaScript in the victim's browser without any clicks or user interaction.
- Session-related data, CSRF tokens, or other in-page secrets could be accessed and exfiltrated by injected scripts.
- Application state could be modified, including performing actions on behalf of the victim using their authenticated session.
- Integrity of displayed content may be compromised, enabling defacement or injection of misleading UI elements and phishing overlays.
- In multi-tenant or shared environments, one tenant's malicious content could impact other users viewing that content.
General mitigation guidance
Effective mitigation focuses on assuming the editor's sanitizer is not a complete security boundary and adding independent layers of defense:
- Treat all HTML coming from the editor as untrusted; apply a robust, security-focused sanitizer on the server or at a separate trust boundary, using a strict allowlist of elements and attributes.
- Strip or neutralize dangerous attributes (event handlers,
javascript:URLs, inline styles) and disallow risky namespaces or complex markup features (e.g., MathML, SVG) unless there is a strong, explicit need for them. - Prefer rendering models that avoid direct use of
innerHTML, or at least limit it to content that has passed through hardened sanitization and encoding routines. - Apply content-security-oriented patterns such as disallowing inline event handlers and inline scripts via Content Security Policy (CSP), thereby reducing the impact of any sanitizer bypass.
- Follow a least-privilege model in UI design: only enable the minimal subset of formatting features required by the product, disabling unnecessary advanced HTML capabilities in the editor configuration.
How teams detect issues like this
Detection typically combines code inspection and behavioral testing:
- Static analysis / review: Search for places where
editor.valueor similar editor output is passed directly into sinks likeinnerHTML, templating expressions that render raw HTML, or framework APIs that bypass automatic escaping. - Sanitizer configuration audit: Review which elements, attributes, and namespaces the application allows; flag configurations that permit broad or unconstrained HTML, MathML, SVG, or inline event handlers.
- Security testing: Craft HTML payloads including MathML, SVG, and <style> constructs designed to carry event handlers, and verify whether they appear and execute after passing through the editor's sanitization and rendering pipeline.
- Automated tooling: Use generic XSS-focused scanners, linters, or security review tools that understand DOM-based sinks and can highlight unsafe use of sanitizers or direct HTML insertion patterns in the codebase.

