You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An attacker is able to inject arbitrary CSS into the generated graph allowing them to change the styling of elements outside of the generated graph, and potentially exfiltrate sensitive information by using specially crafted CSS selectors.
The following example shows how an attacker can exfiltrate the contents of an input field by bruteforcing the value attribute one character at a time. Whenever there is an actual match, an http request will be made by the browser in order to "load" a background image that will let an attacker know what's the value of the character.
By supplying a carefully crafted textColor theme variable, an attacker can inject arbitrary CSS rules into the document. In the following snippet we can see that getStyles does not sanitize any of the theme variables leaving the door open for CSS injection.
For example, if we set textColor to "green;} #target { background-color: crimson }" the resulting CSS will contain a new selector #target that will apply a crimson background color to an arbitrary element.
<html><body><divid="target"><h1>This element does not belong to the SVG but we can style it</h1></div><svgid="diagram"></svg><scriptsrc="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script><script>mermaid.initialize({startOnLoad: false});constgraph=` %%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }" } } }%% graph TD A[Goose] `constdiagram=document.getElementById("diagram")constsvg=mermaid.render('diagram-svg',graph)diagram.innerHTML=svg</script></body></html>
In the proof of concept above we used the textColor variable to inject CSS, but there are multiple functions that can potentially be abused to change the style of the document. Some of them are in the following list but we encourage mantainers to look for additional injection points:
This issue may lead to Information Disclosure via CSS selectors and functions able to generate HTTP requests. This also allows an attacker to change the document in ways which may lead a user to perform unintended actions, such as clicking on a link, etc.
Remediation
Ensure that user input is adequately escaped before embedding it in CSS blocks.
Moving the gitGraph from experimental alpha status to a fully supported diagram type which handles theming and directives. The grammar has changed slightly from the alpha version, and no longer supports reset operations and some internal fast-forwarding has been removed for simplicity. Some few GitGraphs based on the alpha version might break with the update. This is the reason for the major version number update.
Adding new more secure security level 'sandbox' where all rendering happens in a sandboxed iframe. The returned element in this mode is also an iframe with the svg as a base64 encoded url. (#2654)
Documentation updates
Documention updates in the main mardownfile in the repo adding mermaid diagrams instead of images of mermaid diagrams (#2676) @knsv
renovatebot
changed the title
fix(deps): update dependency mermaid to v9 [security]
fix(deps): update dependency mermaid to v10 [security]
Aug 13, 2025
renovatebot
changed the title
fix(deps): update dependency mermaid to v10 [security]
fix(deps): update dependency mermaid to v9 [security]
Oct 16, 2025
Next steps: Take a moment to review the security alert
above. Review the linked package source code to understand the potential
risk. Ensure the package is not malicious before proceeding. If you're
unsure how to proceed, reach out to your security team or ask the Socket
team for help at support@socket.dev.
Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/dompurify@2.3.8. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
8.5.0→9.1.2GitHub Vulnerability Alerts
CVE-2021-43861
Impact
Malicious diagrams can contain javascript code that can be run at diagram readers machines.
Patches
The users should upgrade to version 8.13.8
Workarounds
You need to upgrade in order to avoid this issue.
CVE-2021-35513
Mermaid before 8.11.0 allows XSS when the antiscript feature is used.
CVE-2022-31108
An attacker is able to inject arbitrary
CSSinto the generated graph allowing them to change the styling of elements outside of the generated graph, and potentially exfiltrate sensitive information by using specially craftedCSSselectors.The following example shows how an attacker can exfiltrate the contents of an input field by bruteforcing the
valueattribute one character at a time. Whenever there is an actual match, anhttprequest will be made by the browser in order to "load" a background image that will let an attacker know what's the value of the character.Patches
Has the problem been patched? What versions should users upgrade to?
Workarounds
Is there a way for users to fix or remediate the vulnerability without upgrading?
References
Are there any links users can visit to find out more?
For more information
If you have any questions or comments about this advisory:
Product
mermaid.js
Tested Version
v9.1.1
Details
Issue 1: Multiple CSS Injection (
GHSL-2022-036)By supplying a carefully crafted
textColortheme variable, an attacker can inject arbitraryCSSrules into the document. In the following snippet we can see thatgetStylesdoes not sanitize any of the theme variables leaving the door open forCSSinjection.Snippet from src/styles.js:
For example, if we set
textColorto"green;} #target { background-color: crimson }"the resultingCSSwill contain a new selector#targetthat will apply acrimsonbackground color to an arbitrary element.In the proof of concept above we used the
textColorvariable to injectCSS, but there are multiple functions that can potentially be abused to change the style of the document. Some of them are in the following list but we encourage mantainers to look for additional injection points:Impact
This issue may lead to
Information Disclosurevia CSS selectors and functions able to generate HTTP requests. This also allows an attacker to change the document in ways which may lead a user to perform unintended actions, such as clicking on a link, etc.Remediation
Ensure that user input is adequately escaped before embedding it in CSS blocks.
Release Notes
mermaid-js/mermaid (mermaid)
v9.1.2Compare Source
Release Notes
🚀 Features
Add support for cyclic themeVariable rotation when more than 8 branches (#3049) @ashishjain0512
#3060 support cherry commit in gitgraph (#3115) @ashishjain0512
#3080 Adding rotated commit label functionality (#3113) @ashishjain0512
feat: adding "Critical Region"/"Option" and "Break" blocks to sequence diagram (#3063) @financelurker
[Experimental] Add C4 Diagram. Compatible with C4-PlantUML syntax. (#3038) @pinghe
Bug Fixes & Cleanup
Documentation
Dependecy updates
🎉 Thanks to all contributors helping with this release! 🎉
v9.1.1Compare Source
Release Notes
🎉 Thanks to all contributors helping with this release! 🎉
v9.1.0Compare Source
Release Notes
🚀 Features
Accessibility added to the charts (#3008) (#2732) @knsv @gwincr11 @therzka @khiga8 @el-mapache @lindseywild
feat: add hideUnusedParticipants and some cleanup (#2943) @Yash-Singh1
Added default new line in the diagram text before parsing for special… (#2983) @ashishjain0512
Added support to change the position of the main branch (#3010) @ashishjain0512
Sequence autonumbering and Git fix options parsing (#2981) @Zumbala
GitGraph: add support for branch ordering (#3002) @husa
fix mermaidAPI.parse() behavior to match documentation, add tests to ensure behavior matches docs (#3004) @timmaffett
protect config.js from attempting to use invalid theme name (which corrupted mermaid use until reset()) (#2987) @timmaffett
Handling flowchart link style for html labels using legacy renderer #2951
Documentation
Dependecy updates
🎉 Thanks to all contributors helping with this release! 🎉
v9.0.1Compare Source
Release Notes
🐛 Bug Fixes
🎉 Thanks to all contributors helping with this release! 🎉
v9.0.0Compare Source
Release Notes
Main feature
Moving the gitGraph from experimental alpha status to a fully supported diagram type which handles theming and directives. The grammar has changed slightly from the alpha version, and no longer supports reset operations and some internal fast-forwarding has been removed for simplicity. Some few GitGraphs based on the alpha version might break with the update. This is the reason for the major version number update.
We now support:
Other changes:
Documentation updates
mkdocs-materialto the integrations (#2780) @chrimahoREADME.mdanddocs/README.mdare in sync (#2755) @kuanyi-nglivebookandexdocsintegrations (#2728) @RudolfManDependency updates
🎉 Thanks to all contributors helping with this release! 🎉
v8.14.0Compare Source
Release Notes
Main feature
Documentation updates
Dependecy updates
🎉 Thanks to all contributors helping with this release! 🎉
v8.13.10Compare Source
Release Notes
🎉 Thanks to all contributors helping with this release! 🎉
v8.13.9Compare Source
Release Notes
Changes to the functionality
Documentation changes
Dependency updates