CVE-2021-23352: Madge Madge Vulnerable To Command Injection Vulnerability
HIGHCVE-2021-23352 is a HIGH madge vulnerable to command injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Madge libraries in the npm ecosystem. The issue involves madge vulnerable to command injection. Remediation is available by upgrading affected packages to version 4.0.1.
CVE-2021-23352 at a Glance
How to Fix CVE-2021-23352
To remediate this vulnerability, upgrade all affected Madge 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 madge@4.0.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls madge
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-23352, inspect your project dependencies using npm:
npm ls madge
Analyze the terminal output to locate any version of Madge in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.0.1), your application is affected.
Note: The npm ls madge 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-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Madge, 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-23352 Affected Madge Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
madge
|
npm |
< 4.0.1
|
4.0.1
|
References
Frequently Asked Questions
What is CVE-2021-23352?
Which Madge versions are affected?
What version fixes CVE-2021-23352?
Is madge affected?
What CWE is associated with CVE-2021-23352?
How can I check npm dependencies for CVE-2021-23352?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-753c-phhg-cj29",
"modified" : "2023-09-06T23:33:10Z",
"published" : "2021-03-12T23:01:49Z",
"aliases" : [ "CVE-2021-23352" ],
"summary" : "Madge vulnerable to command injection",
"details" : "This affects the package madge before 4.0.1. It is possible to specify a custom Graphviz path via the graphVizPath option parameter which, when the .image(), .svg() or .dot() functions are called, is executed by the childprocess.exec function.\n\n### PoC\n```js\nconst madge = require('madge'); \nmadge('..', {graphVizPath: \"touch HELLO;\"}) .then((res) => res.svg()) .then((writtenImagePath) => { console.log('Image written to ' + writtenImagePath); });\n```",
"severity" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "madge"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.0.1"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-23352"
}, {
"type" : "WEB",
"url" : "https://github.com/pahen/madge/commit/da5cbc9ab30372d687fa7c324b22af7ffa5c6332"
}, {
"type" : "WEB",
"url" : "https://github.com/pahen/madge/blob/master/lib/graph.js#L27"
}, {
"type" : "WEB",
"url" : "https://snyk.io/vuln/SNYK-JS-MADGE-1082875"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-77", "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-03-12T21:10:53Z",
"nvd_published_at" : "2021-03-09T19:15:00Z"
}
}