CVE-2026-57531 in Milkdown
Summary
by MITRE • 07/24/2026
Milkdown before 7.21.3 contains a DOM cross-site scripting vulnerability in the @milkdown/plugin-emoji package that allows unauthenticated attackers to execute arbitrary JavaScript in the host application's origin by causing a victim to paste attacker-controlled content. The parseDOM.getAttrs handler stores raw innerHTML of pasted span elements with data-type="emoji" without sanitization, and the toMarkdown runner subsequently assigns this unsanitized value directly to a live DOM element's innerHTML, bypassing the DOMPurify sanitization used in the toDOM path, causing payload execution on every markdown serialization cycle.
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 07/24/2026
The vulnerability under discussion affects milkdown versions prior to 7.21.3, specifically within the @milkdown/plugin-emoji package where a cross-site scripting flaw exists that enables unauthenticated attackers to inject and execute arbitrary JavaScript code within the context of the host application. This security gap arises from improper handling of user-provided content during the markdown processing cycle, creating an exploitable path that can be leveraged by malicious actors to compromise applications using this library.
The technical implementation of this vulnerability stems from the parseDOM.getAttrs handler functionality which processes pasted content containing span elements with data-type="emoji" attributes. The flaw occurs when this handler stores the raw innerHTML content of these span elements without any sanitization measures, effectively preserving potentially malicious scripts that were embedded within the emoji data structure during paste operations. This unsanitized data then flows through the processing pipeline where it is subsequently consumed by the toMarkdown runner component.
The operational impact of this vulnerability is significant as it allows attackers to execute code on every markdown serialization cycle, meaning that any content containing malicious payloads will be executed each time the application processes or renders markdown content. The vulnerability specifically bypasses DOMPurify sanitization that normally protects the toDOM path, creating a direct execution channel through the toMarkdown runner which directly assigns the unsanitized emoji values to live DOM elements' innerHTML properties. This creates an persistent threat where malicious code can be triggered repeatedly without requiring additional user interaction beyond the initial paste action.
This vulnerability maps directly to CWE-79 Cross-Site Scripting and aligns with ATT&CK technique T1203 Exploitation for Client Execution, where attackers leverage client-side vulnerabilities to execute arbitrary code within the victim's browser context. The flaw represents a classic case of insecure data handling in rich text processing libraries where input validation occurs only at certain points in the pipeline while leaving other paths unsecured.
The recommended mitigations include updating to milkdown version 7.21.3 or later where the vulnerability has been addressed through proper sanitization of emoji attributes during both parse and serialization cycles. Additionally, developers should implement comprehensive input validation and sanitization practices for all user-provided content in rich text editors, ensuring that any data flowing through the application maintains security boundaries. Organizations using this library should also consider implementing Content Security Policy headers to provide additional protection layers against potential exploitation attempts.