cached-path-relative@1.0.0 vulnerabilities

Memoize the results of the path.relative function

Direct Vulnerabilities

Known vulnerabilities in the cached-path-relative package. This does not include vulnerabilities belonging to this package’s dependencies.

Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities and provides fixes for free.
Fix for free
Vulnerability Vulnerable Version
  • H
Prototype Pollution

cached-path-relative is a memoize the results of the path.relative function.

Affected versions of this package are vulnerable to Prototype Pollution via the cache variable that is set as {} instead of Object.create(null) in the cachedPathRelative function, which allows access to the parent prototype properties when the object is used to create the cached relative path. When using the origin path as __proto__, the attribute of the object is accessed instead of a path.

Note: This vulnerability derives from an incomplete fix in https://security.snyk.io/vuln/SNYK-JS-CACHEDPATHRELATIVE-72573

###PoC

let cpr = require("cached-path-relative");
process.chdir("tst");
cpr("__proto__", "polluted")
console.log({}.polluted);

//output: ../polluted

How to fix Prototype Pollution?

Upgrade cached-path-relative to version 1.1.0 or higher.

<1.1.0
  • H
Prototype Pollution

cached-path-relative is a memoize the results of the path.relative function.

Affected versions of this package are vulnerable to Prototype Pollution. An attacker could inject properties on Object.prototype which are then inherited by all the JS objects through the prototype chain.

How to fix Prototype Pollution?

Upgrade cached-path-relative to version 1.0.2 or higher.

<1.0.2