Command Injection Affecting madge package, versions <4.0.1


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Mature
EPSS
0.59% (79th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-MADGE-1082875
  • published9 Mar 2021
  • disclosed5 Mar 2021
  • creditAlessio Della Libera (d3lla)

Introduced: 5 Mar 2021

CVE-2021-23352  (opens in a new tab)
CWE-89  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade madge to version 4.0.1 or higher.

Overview

madge is a Madge is a developer tool for generating a visual graph of your module dependencies, finding circular dependencies, and give you other useful info.

Affected versions of this package are vulnerable to Command Injection. 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.

PoC

1. install `madge` module: `npm i madge`
2. run the following poc.js:

// Example taken from: https://github.com/pahen/madge#svg

const madge = require('madge'); madge('..', {graphVizPath: "touch HELLO;"}) .then((res) => res.svg()) .then((writtenImagePath) => { console.log('Image written to ' + writtenImagePath); });

CVSS Scores

version 3.1