Github: (https://github.com/khoadevvn)
Facebook: https://www.facebook.com/anhkhoavnk/
A critical Path Traversal vulnerability exists in the @npmcli/bin-links library (a core component used by the npm CLI v11.6.0 and earlier).
The vulnerability resides in the lib/get-paths.js and lib/index.js files due to insufficient sanitization of the bin field in package.json. By crafting a malicious package with traversal sequences (e.g., ../../), an attacker can escape the intended node_modules/.bin directory during installation.
The library uses path.resolve() on untrusted input from package.json without verifying if the resulting path remains within the expected boundaries.
Located in lib/get-paths.js:
for (const bin of Object.keys(pkg.bin)) {
const b = resolve(binTarg, bin); // <--- VULNERABILITY: Path Traversal
binSet.push(b);
if (isWindows) {
binSet.push(b + '.cmd');
binSet.push(b + '.ps1');
}
}