Staging Environment: Content and features may be unstable or change without notice.
Search for packages
Package details: pkg:npm/mermaid@10.9.3
purl pkg:npm/mermaid@10.9.3
Next non-vulnerable version 10.9.4
Latest non-vulnerable version 11.10.0
Risk 3.1
Vulnerabilities affecting this package (1)
Vulnerability Summary Fixed by
VCID-q79q-8yzx-p3f6
Aliases:
CVE-2025-54881
GHSA-7rqq-prvp-x9jh
Mermaid improperly sanitizes sequence diagram labels leading to XSS ### Summary In the default configuration of mermaid 11.9.0, user supplied input for sequence diagram labels is passed to `innerHTML` during calculation of element size, causing XSS. ### Details Sequence diagram node labels with KaTeX delimiters are passed through `calculateMathMLDimensions`. This method passes the full label to `innerHTML` which allows allows malicious users to inject arbitrary HTML and cause XSS when mermaid-js is used in it's default configuration (with KaTeX support enabled). The vulnerability lies here: ```ts export const calculateMathMLDimensions = async (text: string, config: MermaidConfig) => { text = await renderKatex(text, config); const divElem = document.createElement('div'); divElem.innerHTML = text; // XSS sink, text has not been sanitized. divElem.id = 'katex-temp'; divElem.style.visibility = 'hidden'; divElem.style.position = 'absolute'; divElem.style.top = '0'; const body = document.querySelector('body'); body?.insertAdjacentElement('beforeend', divElem); const dim = { width: divElem.clientWidth, height: divElem.clientHeight }; divElem.remove(); return dim; }; ``` The `calculateMathMLDimensions` method was introduced in 5c69e5fdb004a6d0a2abe97e23d26e223a059832 two years ago, which was released in [Mermaid 10.9.0](https://github.com/mermaid-js/mermaid/releases/tag/v10.9.0). ### PoC Render the following diagram and observe the modified DOM. ``` sequenceDiagram participant A as Alice<img src="x" onerror="document.write(`xss on ${document.domain}`)">$$\\text{Alice}$$ A->>John: Hello John, how are you? Alice-)John: See you later! ``` Here is a PoC on mermaid.live: https://mermaid.live/edit#pako:eNpVUMtOwzAQ_BWzyoFKaRTyaFILiio4IK7ckA-1km1iKbaLY6spUf4dJ0AF68uOZ2dm7REqXSNQ6PHDoarwWfDGcMkUudaJGysqceLKkj3hPdl3osJ7IRvSm-qBwcCAaIXGaONRrSsnUdnobITF28PQ954lwXglai25UNNhxWAXBMyXxcGOi-3kL_5k79e73atuFSUv2HWazH1IWn0m3CC5aPf4b3p2WK--BW-4DJCOWzQ3TM0HQmiMqIFa4zAEicZv4iGMsw0D26JEBtS3NR656ywDpiYv869_11r-Ko12TQv0yLveI3eqfcjP111HUNVonrRTFuhdsVgAHWEAmuRxlG7SuEzKMi-yJAnhAjTLIk_EcbFJtuk2y9MphM8lM47KIp--AOZghtU ### Impact XSS on all sites that use mermaid and render user supplied diagrams without further sanitization. ### Remediation The value of the `text` argument for the `calculateMathMLDimensions` method needs to be sanitized before getting passed on to `innerHTML`.
10.9.4
Affected by 0 other vulnerabilities.
11.10.0
Affected by 0 other vulnerabilities.
Vulnerabilities fixed by this package (1)
Vulnerability Summary Aliases
VCID-fwuk-z3uk-1ygf Prototype pollution vulnerability found in Mermaid's bundled version of DOMPurify The following bundled files within the Mermaid NPM package contain a bundled version of DOMPurify that is vulnerable to https://github.com/cure53/DOMPurify/security/advisories/GHSA-mmhx-hmjr-r674, potentially resulting in an XSS attack. This affects the built: - `dist/mermaid.min.js` - `dist/mermaid.js` - `dist/mermaid.esm.mjs` - `dist/mermaid.esm.min.mjs` This will also affect users that use the above files via a CDN link, e.g. `https://cdn.jsdelivr.net/npm/mermaid@10.9.2/dist/mermaid.min.js` **Users that use the default NPM export of `mermaid`, e.g. `import mermaid from 'mermaid'`, or the `dist/mermaid.core.mjs` file, do not use this bundled version of DOMPurify, and can easily update using their package manager with something like `npm audit fix`.** ### Patches - `develop` branch: 6c785c93166c151d27d328ddf68a13d9d65adc00 - backport to v10: 92a07ffe40aab2769dd1c3431b4eb5beac282b34 GHSA-m4gq-x24j-jpmf

Date Actor Action Vulnerability Source VulnerableCode Version
2026-04-16T23:35:46.049340+00:00 GitLab Importer Affected by VCID-q79q-8yzx-p3f6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/mermaid/CVE-2025-54881.yml 38.4.0
2026-04-12T00:56:13.043940+00:00 GitLab Importer Affected by VCID-q79q-8yzx-p3f6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/mermaid/CVE-2025-54881.yml 38.3.0
2026-04-03T01:04:25.887570+00:00 GitLab Importer Affected by VCID-q79q-8yzx-p3f6 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/mermaid/CVE-2025-54881.yml 38.1.0
2026-04-02T12:40:16.585561+00:00 GitLab Importer Fixing VCID-fwuk-z3uk-1ygf https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/mermaid/GHSA-m4gq-x24j-jpmf.yml 38.0.0
2026-04-01T16:06:43.333511+00:00 GHSA Importer Fixing VCID-fwuk-z3uk-1ygf https://github.com/advisories/GHSA-m4gq-x24j-jpmf 38.0.0
2026-04-01T12:49:20.385438+00:00 GithubOSV Importer Fixing VCID-fwuk-z3uk-1ygf https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/10/GHSA-m4gq-x24j-jpmf/GHSA-m4gq-x24j-jpmf.json 38.0.0