Executive brief
Milkdown is an open-source WYSIWYG markdown editor used in web applications. A security flaw in how it handles links and emojis allows an attacker to embed malicious scripts into a document. If another user opens the document or clicks a compromised link, the script could execute in their browser, potentially leading to unauthorized actions or data theft.
Technical details
Milkdown before version 7.21.3 contains two independent stored/DOM XSS sinks. First, the '@milkdown/preset-commonmark' and '@milkdown/components' packages failed to validate URL schemes in link href attributes, allowing 'javascript:' payloads to bypass an ineffective DOMPurify.sanitize call that treated bare URLs as text nodes. Second, the emoji plugin's 'toMarkdown' function assigned unsanitized HTML to 'innerHTML' on a live span element, allowing 'img onerror' payloads to execute during serialization. An attacker with document write access can exploit these to execute arbitrary JavaScript in the context of other users. The issue is fixed in version 7.21.3 by implementing a strict URL scheme allowlist and improving HTML sanitization at entry points.
Affected products
- Milkdown milkdown < 7.21.3
Timeline
- 2026-07-12: patched: Fix merged in PR 2410 and released in v7.21.3
- 2026-07-24: disclosed: CVE-2026-57530 published
References
- https://github.com/Milkdown/milkdown/commit/db1ae721854a0ab2f188b83cf8695702966640f1
- https://github.com/Milkdown/milkdown/pull/2410
- https://github.com/Milkdown/milkdown/releases/tag/v7.21.3
- https://www.npmjs.com/package/@milkdown/components
- https://www.npmjs.com/package/@milkdown/preset-commonmark
- https://www.vulncheck.com/advisories/milkdown-stored-xss-via-javascript-url-in-link-href