Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running suggested command doesn't fix NPM Vulnerability

After each installation of a new NPM module in my project I get the following error :

[!] 40 vulnerabilities found - Packages audited: 5840 (0 dev, 299 optional)
    Severity: 8 Low | 24 Moderate | 8 High

So then I run npm audit and I get the details for each of the 40 vulnerabilities such as :

# Run  npm install [email protected]  to resolve 22 vulnerabilities
SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate      │ Prototype pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ npm                                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ npm > libcipm > npm-lifecycle > node-gyp > request > hawk >  │
│               │ boom > hoek                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

or this :

# Run  npm update fsevents --depth 2  to resolve 3 vulnerabilities
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ debug                                                        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ chokidar                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ chokidar > fsevents > node-pre-gyp > tar-pack > debug        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/534                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

So I run npm install [email protected] (even though I already had 6.0.1) then npm update fsevents --depth 2 But after that I re-run npm audit and nothing has changed, I still have the same 40 vulnerabilities and some of them are really scary. What should I do ?

like image 404
Ki Jéy Avatar asked May 13 '18 10:05

Ki Jéy


People also ask

How to fix NPM dependencies vulnerabilities?

NPM Audit Fix Fixing NPM Dependencies Vulnerabilities 1 TLDR; Manually run the command given in the text to upgrade one package at a time, e.g. npm i --save-dev [email protected] 2 The Fix. Manually upgrade the packages one at a time with the command suggested by NPM instead of running the npm audit fix --force command. 3 Summary. ...

Is there a fix for npm that won't update?

This isn't a fix for npm, but it worked for me for now: 1 Do the npm audit suggestions that aren't npm update s 2 Delete package-lock.json 3 Delete the node_modules folder 4 (I didn't have to clear my npm cache, but if you continue to run into issues, you may want to look into that) 5 Run npm install again More ...

What to do when package manager can't fix vulnerabilities?

If our package manager isn't able to fix these vulnerabilities then surely we're out of luck and must find a way to survive with these vulnerabilities hoping nobody decides to exploit them against our project. Manually upgrade the packages one at a time with the command suggested by NPM instead of running the npm audit fix --force command.

How to fix “NPM install not working” error in Node JS?

But if you can’t update your Node.js version yet, then installing the build tools manually should help you fix this error. The npm install command may fail to work because of many reasons. When the command doesn’t work, you need to check the output first and see what specific error you have.


3 Answers

This worked for me on MacOS:

  • Update NPM to the new 6.1.0. It introduces a 'npm audit fix' command, more info here.
  • Run 'npm audit fix'.

When you run 'npm audit' again, the only vulnerabilities left should be "Manual Review" issues.

like image 114
Flo Avatar answered Oct 03 '22 13:10

Flo


This seems to be a bug in npm 6.0.1 related to handling of optional dependencies: https://github.com/npm/npm/issues/20577

like image 39
Josh Rickert Avatar answered Oct 02 '22 13:10

Josh Rickert


This worked for me:

Do the npm audit suggestions that aren't npm updates
Delete package-lock.json
Delete the node_modules folder
Run npm install again

https://github.com/npm/npm/issues/20684

like image 35
Choylton B. Higginbottom Avatar answered Sep 30 '22 13:09

Choylton B. Higginbottom