Executive brief
npm is the package manager widely used by JavaScript developers to install dependencies. Versions prior to 6.13.3 allow malicious packages to create symlinks pointing to arbitrary files on a user's system during installation, potentially enabling attackers to overwrite or access sensitive files. The vulnerability affects only files accessible to the user running npm install, but can be exploited by package publishers to conduct supply-chain attacks.
Technical details
npm CLI versions before 6.13.3 fail to validate symlink targets in the bin field of package.json, allowing packages to create symlinks that point outside the node_modules directory. An attacker can craft a malicious package with a bin entry that symlinks to arbitrary filesystem paths, leading to arbitrary file write or read depending on the target location and user permissions. The attack requires package installation and bypasses the --ignore-scripts flag; however, it does not work through install scripts. The vulnerability was patched in npm 6.13.3. The attack is exploitable via the package manager's normal installation workflow without requiring user interaction beyond running npm install.
Affected products
- npm npm <6.13.3
Timeline
- 2019-12-13: disclosed
- 2019-12-13: patched: npm 6.13.3 released