Disclosed vulnerabilities
Fixed: Sep 26, 2019
No CVE assigned Published: Sep 26, 2019

OS command execution vulnerability in Commander.js

4.5 Medium Severity Command Injection javascript js PROTOTYPE-POLLUTION
Dor Tumarkin Reported by Checkmarx Zero

Summary

A local code/OS command execution vulnerability was discovered in Commander.js, in the “parse()” method. Given a permission to write and set permissions on a file in the same working directory as the application, and given the ability to pass the value __proto__ to the “parse()” method, an attacker can bypass checks against values set in _execs[] to execute an external file which was not intended.

Product

Commander.js before version 2.20.1 and 3.x before 3.0.2.

Impact

With the right conditions an attacker could run ability commands on the server.

Steps to reproduce

  1. Create a file named poc-__proto__ with the shell command in it with a given execution permissions (+x)
  2. Create poc.js with the code:
    var program = require('commander');
    console.log(program.parse(process.argv));
  3. Run Node poc.js __proto__

Expected result:

The shell command in the file poc-__proto__ will run.

Remediation

Update Commander.js plugin to 2.20.1 or 3.0.2 or above.

Credit

This issue was discovered and reported by Checkmarx Security Researcher Dor Tumarkin.

Resources

  1. Pull request
  2. 2544df8

Stay connected and never miss a research update!