4

After running npm audit I have (this is just one of) a moderate warning

Moderate      │ Prototype pollution
Package       │ hoek
Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3
Dependency of │ karma
Path          | karma > log4js > loggly > request > hawk > sntp > hoek

I can see that hoek is a dependency of karma (further down the chain). Looking at the Karma repo on GitHub I can see that this has been raised but no immediate fix has been prioritised.

Is this something that we just have to accept for now until they have updated their dependencies or can we tell our application to use a more recent version of hoek and apply to all packages?

Estus Flask
  • 206,104
  • 70
  • 425
  • 565
Richlewis
  • 15,070
  • 37
  • 122
  • 283

2 Answers2

2

You can npm install the fixed version of the dependency from a pull request or a commit. E.g.

npm install github:winstonjs/node-loggly#pull/79/head

Then delete the added line in package.json e.g. "loggly": "github:winstonjs/node-loggly#pull/79/head"

In package-lock.json search for loggly and where it shows "version": "<some git url>", delete the url and replace it with the appropriate version number e.g "1.1.1".

Jesse
  • 805
  • 9
  • 11
1

The problem is that loggly hasn't be updated for a long time and is hard-coded to request version that uses hoek version with specified vulnerability. There is open issue.

Considering a role of hoek package here, it's unlikely that it causes real security issue.

From a user's perspective, it's possible to fix security issue by using a branch where this dependency is fixed, e.g. this pull request:

"karma": "^2.0.2",
"loggly": "github:winstonjs/node-loggly#pull/79/head"

Since loggly branch version matches constraints in log4js, this replaces original loggly with fixed one (possibly requires to purge node_modules to take effect).

This causes

400 Bad Request - POST https://registry.npmjs.org/-/npm/v1/security/audits

error for npm audit, so it likely should be left as is for now.

Estus Flask
  • 206,104
  • 70
  • 425
  • 565
  • Just in case others come across this: [loggly](https://github.com/winstonjs/node-loggly) has an officially maintained fork: [node-loggly-bulk](https://github.com/loggly/node-loggly-bulk) which addresses the vulnerability. Also, recent versions of log4js (v2.6.0 on) no longer include loggly as a dependency. So, if you're using a recent version of karma check your package-lock.json or yarn.lock to make sure you aren't getting pinned to an older version of log4js. – eddies Jul 16 '18 at 06:17