{"id":"CVE-2025-54880","aliases":["CVE-2025-54880","GHSA-8gwm-58g9-j8pw"],"related":[],"kind":"vulnerability","state":"published","title":"Mermaid does not properly sanitize architecture diagram iconText leading to XSS","summary":"Mermaid is a JavaScript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams. In the default configuration of mermaid 11.9.0 and earlier, user supplied input for architecture diagram icons is passed to the d3 html() method, creating a sink for cross site scripting. This vulnerability is fixed in 11.10.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Mermaid is a JavaScript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams. In the default configuration of mermaid 11.9.0 and earlier, user supplied input for architecture diagram icons is passed to the d3 html() method, creating a sink for cross site scripting. This vulnerability is fixed in 11.10.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nIn the default configuration of mermaid 11.9.0, user supplied input for architecture diagram icons is passed to the d3 `html()` method, creating a sink for cross site scripting.\n\n### Details\nArchitecture diagram service `iconText` values are passed to the d3 `html()` method, allowing malicious users to inject arbitrary HTML and cause XSS when mermaid-js is used in it's default configuration. \n\nThe vulnerability lies here:\n\n```ts\nexport const drawServices = async function (\n  db: ArchitectureDB,\n  elem: D3Element,\n  services: ArchitectureService[]\n): Promise<number> {\n  for (const service of services) {\n    /** ... **/\n    } else if (service.iconText) {\n      bkgElem.html(\n        `<g>${await getIconSVG('blank', { height: iconSize, width: iconSize, fallbackPrefix: architectureIcons.prefix })}</g>`\n      );\n      const textElemContainer = bkgElem.append('g');\n      const fo = textElemContainer\n        .append('foreignObject')\n        .attr('width', iconSize)\n        .attr('height', iconSize);\n      const divElem = fo\n        .append('div')\n        .attr('class', 'node-icon-text')\n        .attr('style', `height: ${iconSize}px;`)\n        .append('div')\n        .html(service.iconText); // <- iconText passed into innerHTML\n       /** ... **/\n};\n};\n```\n\nThis issue was introduced with 734bde38777c9190a5a72e96421c83424442d4e4, around 15 months ago, which was released in [v11.1.0](https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.1.0).\n\n### PoC\nRender the following diagram and observe the modified DOM.\n\n```\narchitecture-beta\n    group api(cloud)[API]\n    service db \"<img src=x onerror=\\\"document.write(`xss on ${document.domain}`)\\\">\" [Database] in api\n```\n\nHere is a PoC on mermaid.live: https://mermaid.live/edit#pako:eNo9T8FOwzAM_ZXI4rBJpWrpRtuIISF24caZZdKyxOsiLUnlJjCo-u9kQ8wX-_n5-dkjKK8ROEhSRxNQhUh4v8cghWMpOvKxZ7I3M3XyUc83L-9v2z9qQPo0CpneMwFPxnZsILU6M--QyNNKCAHaq2jRhfyL0vLZ7jwMiWd3443Q3krjpt38Mv4sgG3WMsi9HHDLjLs4CwcZdGQ08EARM7BISZMgjJdLBIQjWhTAU6nxIOMpCBBuSrJeug_v7b8yPdMdgR_kaUgo9loGXBvZkbS3LqHTSK8-ugC8LMrrEuAjnIEvlnlVL9q6rZu6Lh-rRQbfwKuyyZuybcvqIaWiqKcMfq6uRd7Uy-kXhYFzcA\n\n### Impact\nXSS on all sites that use mermaid and render user supplied diagrams without further sanitization.\n\n### Remediation\nSanitize the value of `iconText` before passing it to `html()`.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Mermaid es una herramienta de diagramación y gráficos basada en JavaScript que utiliza definiciones de texto inspiradas en Markdown y un renderizador para crear y modificar diagramas complejos. En la configuración predeterminada de Mermaid 11.9.0 y versiones anteriores, la información proporcionada por el usuario para los iconos de los diagramas de arquitectura se pasa al método html() de d3, lo que crea un receptor para cross site scripting. Esta vulnerabilidad se corrigió en la versión 11.10.0.","source":"nvd"}],"published":"2025-08-19T16:58:41.120Z","modified":"2026-08-07T08:12:20.025Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":5.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":5.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":">= 11.1.0, < 11.10.0","status":"affected"}],"vendor":"mermaid-js","product":"mermaid","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"11.1.0","status":"affected","fixed":"11.10.0"}],"ecosystem":"npm","package":"mermaid","purl":"pkg:npm/mermaid","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"11.1.0","fixed":"11.10.0"}],"vendor":"mermaid_project","product":"mermaid","cpe":"cpe:2.3:a:mermaid_project:mermaid:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/mermaid-js/mermaid/security/advisories/GHSA-8gwm-58g9-j8pw","tags":["exploit","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/commit/2aa83302795183ea5c65caec3da1edd6cb4791fc","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/mermaid-js/mermaid/commit/734bde38777c9190a5a72e96421c83424442d4e4","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54880","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/mermaid-js/mermaid","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-08-19T17:09:29.632Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-54880","url":"https://www.cve.org/CVERecord?id=CVE-2025-54880","licence":"CVE Terms of Use","modified":"2025-08-19T17:09:32.759Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-8gwm-58g9-j8pw","url":"https://github.com/advisories/GHSA-8gwm-58g9-j8pw","licence":"CC-BY-4.0","modified":"2026-08-07T08:12:20.025Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-54880","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54880","licence":"Public domain","modified":"2026-06-17T09:40:51.440Z"}],"updatedAt":"2026-11-25T22:59:02.788Z","epss":{"score":0.00467,"percentile":0.42098,"date":"2026-12-02T12:00:21.000Z"}}