CVE-2021-43861: Mermaid Cross-Site Scripting Vulnerability
HIGHCVE-2021-43861 is a HIGH (CVSS 7.2) cross-site scripting vulnerability (CWE-20: Improper Input Validation) affecting Mermaid libraries in the npm ecosystem. The issue involves incorrect sanitisation function leads to `xss` in mermaid. Remediation is available by upgrading affected packages to version 8.13.8.
CVE-2021-43861 at a Glance
Security Impact
CVSS: 7.2
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2021-43861
To remediate this vulnerability, upgrade all affected Mermaid dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install mermaid@8.13.8
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls mermaid
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-43861, inspect your project dependencies using npm:
npm ls mermaid
Analyze the terminal output to locate any version of Mermaid in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.13.8), your application is affected.
Note: The npm ls mermaid command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Mermaid, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-43861 Affected Mermaid Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mermaid
|
npm |
< 8.13.8
|
8.13.8
|
References
Frequently Asked Questions
What is CVE-2021-43861?
Which Mermaid versions are affected?
What version fixes CVE-2021-43861?
Is mermaid affected?
What is the CVSS score of CVE-2021-43861?
What CWE is associated with CVE-2021-43861?
How can I check npm dependencies for CVE-2021-43861?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-p3rp-vmj9-gv6v",
"modified" : "2022-01-06T19:02:22Z",
"published" : "2022-01-06T19:45:59Z",
"aliases" : [ "CVE-2021-43861" ],
"summary" : "Incorrect sanitisation function leads to `XSS` in mermaid",
"details" : "### Impact\nMalicious diagrams can contain javascript code that can be run at diagram readers machines.\n\n### Patches\nThe users should upgrade to version 8.13.8\n\n### Workarounds\nYou need to upgrade in order to avoid this issue.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "mermaid"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "8.13.8"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/mermaid-js/mermaid/security/advisories/GHSA-p3rp-vmj9-gv6v"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43861"
}, {
"type" : "WEB",
"url" : "https://github.com/mermaid-js/mermaid/commit/066b7a0d0bda274d94a2f2d21e4323dab5776d83"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/mermaid-js/mermaid"
}, {
"type" : "WEB",
"url" : "https://github.com/mermaid-js/mermaid/releases/tag/8.13.8"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-20", "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-01-06T19:02:22Z",
"nvd_published_at" : "2021-12-30T14:15:00Z"
}
}