Vulnerabilities in pkg:npm/mdx-mermaid
PACKAGECVE-2022-36036 is a LOW (CVSS 3.6) improper control of generation of vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Mdx mermaid libraries in the npm ecosystem. The issue involves improper control of generation of code ('code injection') in mdx-mermaid. Remediation is available by upgrading affected packages to version 1.3.0, 2.0.0-rc2.
pkg:npm/mdx-mermaid
Vulnerability advisories affecting package pkg:npm/mdx-mermaid. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-rvgm-35jw-q628 | CVE-2022-36036 | LOW | Improper Control of Generation of Code ('Code Injection') in mdx-mermaid |
CVE-2022-36036 at a Glance
Security Impact
CVSS: 3.6
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N).
How to Fix CVE-2022-36036
To remediate this vulnerability, upgrade all affected Mdx 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 mdx-mermaid@1.3.0
npm install mdx-mermaid@2.0.0-rc2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls mdx-mermaid
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-36036, inspect your project dependencies using npm:
npm ls mdx-mermaid
Analyze the terminal output to locate any version of Mdx mermaid in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.0), your application is affected.
Note: The npm ls mdx-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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Mdx 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-2022-36036 Affected Mdx mermaid Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mdx-mermaid
|
npm |
< 1.3.0
|
1.3.0
|
|
mdx-mermaid
|
npm |
≥ 2.0.0-rc1
< 2.0.0-rc2
All 1 versions
2.0.0-rc1
|
2.0.0-rc2
|
References
Frequently Asked Questions
What is CVE-2022-36036?
Which Mdx mermaid versions are affected?
What version fixes CVE-2022-36036?
Is mdx-mermaid affected?
What is the CVSS score of CVE-2022-36036?
What CWE is associated with CVE-2022-36036?
How can I check npm dependencies for CVE-2022-36036?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rvgm-35jw-q628",
"modified" : "2022-09-08T14:12:04Z",
"published" : "2022-08-31T22:26:11Z",
"aliases" : [ "CVE-2022-36036" ],
"summary" : "Improper Control of Generation of Code ('Code Injection') in mdx-mermaid",
"details" : "### Impact\n\nArbitary javascript injection\n\nModify any mermaid code blocks with the following code and the code inside will execute when the component is loaded by MDXjs\n\n```\n` + (function () {\n // Put Javascript code here\n return ''\n}()) + `\n```\n\nThe block below shows a valid mermaid code block\n\n````md\n```mermaid\ngraph TD;\n A-->B;\n A-->C;\n B-->D;\n C-->D;\n```\n````\n\nThe same block but with the exploit added\n\n````md\n```mermaid\n` + (function () {\n alert('vulnerable')\n return ''\n}()) + `\ngraph TD;\n A-->B;\n A-->C;\n B-->D;\n C-->D;\n```\n````\n\n### Patches\n1.3.0 and 2.0.0-rc2\n\n### Workarounds\nNone known",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "mdx-mermaid"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.3.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "mdx-mermaid"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0-rc1"
}, {
"fixed" : "2.0.0-rc2"
} ]
} ],
"versions" : [ "2.0.0-rc1" ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/sjwall/mdx-mermaid/security/advisories/GHSA-rvgm-35jw-q628"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-36036"
}, {
"type" : "WEB",
"url" : "https://github.com/sjwall/mdx-mermaid/commit/f2b99386660fd13316823529c3f1314ebbcdfd2a"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/sjwall/mdx-mermaid"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2022-08-31T22:26:11Z",
"nvd_published_at" : "2022-08-29T18:15:00Z"
}
}