Milkdown before 7.21.3 contains a DOM cross-site scripting vulnerability in the @milkdown/plugin-emoji package that allows unauthenticated attackers… (CVE-2026-57531)
Source GCVE Database
No CVSS score published yet
- Exploitation
Not in CISA KEV, no exploitation reported
- EPSS
- 0.4% chance of exploitation in 30 days – higher than 33% of CVEsExploit Prediction Scoring System: the likelihood attackers will use this flaw soon.
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:XWhat to do
AI-suggested
The vulnerability is fixed in Milkdown version 7.21.3 and later. Users should upgrade to version 7.21.3 or newer to remediate this issue. Until patched, avoid pasting untrusted content that could exploit this vulnerability.
Description
Milkdown versions before 7.21.3 contain a DOM-based cross-site scripting (XSS) vulnerability in the @milkdown/plugin-emoji package. This vulnerability allows unauthenticated attackers to execute arbitrary JavaScript in the context of the host application by tricking a victim into pasting attacker-controlled content. The issue arises because the plugin's parseDOM.getAttrs handler stores raw innerHTML from pasted span elements with data-type="emoji" without sanitization. Later, the toMarkdown runner assigns this unsanitized content directly to a live DOM element's innerHTML, bypassing the DOMPurify sanitization used elsewhere, resulting in script execution during markdown serialization cycles.
Impact
An attacker can execute arbitrary JavaScript code in the context of the host application by causing a victim to paste specially crafted content. This can lead to theft of sensitive information, session hijacking, or other malicious actions within the victim's browser session. The vulnerability affects the integrity and security of the markdown rendering process in affected Milkdown versions.
Summary
The vulnerability in Milkdown before version 7.21.3 is a DOM-based cross-site scripting flaw in the @milkdown/plugin-emoji package. It stems from improper sanitization of pasted emoji content: the parseDOM.getAttrs handler captures raw innerHTML from pasted span elements marked as emojis without cleaning it. Subsequently, the toMarkdown runner injects this unsanitized HTML directly into the DOM, bypassing the sanitization path used in toDOM. This flaw allows unauthenticated attackers to execute arbitrary JavaScript in the victim's browser when the victim pastes malicious content, leading to potential script execution on every markdown serialization cycle.
Weaknesses
References
- nvd.nist.gov/vuln/detail/CVE-2026-57531 (opens in a new tab)
- github.com/Milkdown/milkdown/pull/2410 (opens in a new tab)
- github.com/Milkdown/milkdown/commit/db1ae721854a0ab2f188b83cf8695702966640f1 (opens in a new tab)
- github.com/Milkdown/milkdown/releases/tag/v7.21.3 (opens in a new tab)
- npmjs.com/package/@milkdown/plugin-emoji (opens in a new tab)
- vulncheck.com/advisories/milkdown-dom-xss-via-innerhtml-assignment (opens in a new tab)