3 ms·
I think this is a good project, but I also feel like this problem really needs to be solved by NPM, especially since in many cases it is solved pretty trivially
by hn_throwaway_99 5y ago
I think this is a good project, but I also feel like this problem really needs to be solved by NPM, especially since in many cases it is solved pretty trivially.
The single biggest reason that NPM is so vulnerable to supply-chain attacks is that running `npm install` or `npm update` will always install the absolute latest semver-compatible version, regardless of how long that version has been published or any other criteria.
If suppose those two NPM commands instead had flags like --conservative, --default or --canary (OK, I suck at naming, but you get the idea) where, for example:
1. --conservative installs the most recent version has been released for at least 2 weeks or has at least 10000 downloads.
2. --default only requires the most recent version to have been released for at least 1 day or has at least 1000 downloads.
3. --canary would give you the existing behavior, where you get the most recent semver-compatible version even if it's only a second old.
The idea being that, depending on the risk level of your project, you could use a different flag. Furthermore, security researchers and companies like Snyk could install packages in --canary mode in sandboxes to look for malware.
The fact is that despite all the (deserved) handwringing about NPM supply chain attacks like with ua-parser-js and the faker/color fiasco, most of these issues are discovered very quickly. Minor changes to NPM would provide a huge amount of additional security (for those who need it) with extremely little cost.
- tehlike 5y agoYou can change nom registry url to be socket managed one, which would not let you install compromised packages - wouldn't that work?