node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

NPM audit reports the package with high vulnerability (Denial of Service)

Open yarpeytz opened this issue 6 years ago • 51 comments

More info https://www.npmjs.com/advisories/1486

yarpeytz avatar May 14 '20 19:05 yarpeytz

And there goes CI pipelines across the globe...

ecbrodie avatar May 14 '20 19:05 ecbrodie

Seems like a key bit here that limits the scope:

This is only possible when the proxy server sets headers in the proxy request using the proxyReq.setHeader function.

Wouldn't this be a short term work around - proxyReq.headers['arr'] = "I'm a pirate" ?

krautface avatar May 14 '20 19:05 krautface

I get the security warning from NPM about this package too. Using react-scripts (https://github.com/facebook/create-react-app)

tonix-tuft avatar May 14 '20 20:05 tonix-tuft

Yeah, projects using webpack-dev-server will have this warning.

neilbryson avatar May 15 '20 00:05 neilbryson

Is there a fix for this in the works?

jay-finn avatar May 15 '20 02:05 jay-finn

Our pipeline returns this audit failure High Denial of Service Package http-proxy Patched in No patch available Dependency of react-scripts Path react-scripts > webpack-dev-server > http-proxy-middleware > http-proxy More info https://nodesecurity.io/advisories/1486

andrewsteadcc avatar May 15 '20 08:05 andrewsteadcc

npm audit warns in projects with webpack-dev-server webpack-dev-server > http-proxy-middleware > http-proxy

pamit avatar May 15 '20 09:05 pamit

sam withyarn audit

ady642 avatar May 15 '20 10:05 ady642

So you can provisionally fix this by moving webpack-dev-server or react-scripts (whichever package is causing the issue) to devDependencies.

Once the package is in your devDependencies you can run npm audit --prod and it will not audit the package as it only audits the node packages in your dependencies with the --prod arg passed to the CLI.

maxmckenzie avatar May 15 '20 10:05 maxmckenzie

npm audit warns in projects with webpack-dev-server webpack-dev-server > http-proxy-middleware > http-proxy

Same for react-scripts as it depends on webpack-dev-server react-scripts > webpack-dev-server > http-proxy-middleware > http-proxy

schemburkar avatar May 15 '20 10:05 schemburkar

audit-ci npm dependency can also be used instead of npm audit to whitelist this particular dependency.

panuhorsmalahti avatar May 15 '20 12:05 panuhorsmalahti

audit-ci npm dependency can also be used instead of npm audit to whitelist this particular dependency.

Yes, if you use https://github.com/IBM/audit-ci, you can whitelist http-proxy like that:

$ npx audit-ci --high --whitelist=http-proxy

Caution

It's not recommended to use packages with vulnerabilities. In my case I've had to whitelist this in order for Travis CI to continue working.

nacholibre avatar May 15 '20 12:05 nacholibre

audit-ci npm dependency can also be used instead of npm audit to whitelist this particular dependency.

Yes, if you use https://github.com/IBM/audit-ci, you can whitelist http-proxy like that:

$ npx audit-ci --high --whitelist=http-proxy

Sorry for noob question, but does this mean it isn't risky to use locally?

MacKoslowski avatar May 15 '20 13:05 MacKoslowski

audit-ci npm dependency can also be used instead of npm audit to whitelist this particular dependency.

Yes, if you use https://github.com/IBM/audit-ci, you can whitelist http-proxy like that:

$ npx audit-ci --high --whitelist=http-proxy

Sorry for noob question, but does this mean it isn't risky to use locally?

In theory it still is but by whitelisting you're intentionally ignoring the vulnerability. However i think this particulair vulnerability is more of a threat when published on a server.

Jackques avatar May 15 '20 14:05 Jackques

@Jackques, I tried running the whitelist command and it had no luck for me. Would it work if you were to CRA and then run --> npm uninstall http-proxy ?

jamesAppello avatar May 15 '20 15:05 jamesAppello

@Jackques, I tried running the whitelist command and it had no luck for me. Would it work if you were to CRA and then run --> npm uninstall http-proxy ?

If you use https://github.com/IBM/audit-ci then you should be able to set the error id (which relates to the security vul. issue id) in a .json. Check the audit-cli package for details. No need to reinstall the package in order to whitelist it. Once you have got the security id in your witelist the package should no longer appear in the security report.

Jackques avatar May 15 '20 15:05 Jackques

@Jackques, Thank you! What I meant to say was that what if you dont whitelist it? In my specfic situation: I am working in a group repo with branches and I am tying to install the dependencies for the client from create-react-app (where as I go to the master branch, git pull'd --> ran npm i | npm install). At that point i was saying what if you uninstall http-proxy at ^that point(after installing dependencies ad seeing the warning) instead of whitelisting? If that's a clearer way to ask the question?

Else: Again I thank you for your help!

jamesAppello avatar May 15 '20 15:05 jamesAppello

I'm actually more concerned as to what specifically is wrong within the http-proxy package that is causing the error in the first place.

jamesAppello avatar May 15 '20 15:05 jamesAppello

Disappointed that people are recommending whitelisting http-proxy or worse still completely disabling audit of devDependencies in response to this. I would guess that 90% of the people that read this thread and take that advice probably don't understand the full implications of it and will not reinstate the audit after http-proxy is fixed.

It's not just vulnerabilities that audit guards against but intentional exploits also. Just think about what things the code in those devDependencies has access to when it runs on your local machine or build agent:

  • Probably some private keys, database passwords, etc.
  • If you're in the cloud your build agent may well have privileged access to your cloud resources so it can deploy/modify things.
  • That code may not be directly included in your production JS files but it's able to access and manipulate those files so it could rewrite them any way it wanted.
  • It could duplicate itself to any npm packages you publish from your build agent

In summary: please don't do that.

dezfowler avatar May 15 '20 16:05 dezfowler

According to the advisory, this was reported back in February. Count me disappointed as well.

skottklebe avatar May 15 '20 16:05 skottklebe