Upcoming breaking changes for npm v12
21 points by Jackevansevo
21 points by Jackevansevo
I've always found the emphasis on preinstall scripts (and their equivalents in other package managers) to be a bit silly - after all, the whole point of a package manager is to install arbitrary code. Even if npm install doesn't immediately run the code it downloaded, the next command you invoke after that probably will.
Admittedly, for a JavaScript package manager, this makes slightly more sense because some of the code the package manager installs might be destined to run in a browser, not the developer's machine. But:
Ultimately my view is that preinstall scripts are currently the path of least resistance for weaponizing a package compromise, so we currently see loads of them. (And as an individual, disabling preinstall scripts is perhaps a prudent defense, because you don't have to outrun the bear, just everyone else who gets exploited more easily than you.) But disabling preinstall scripts for everyone won't have a massive effect on the prevalence of supply chain attacks, it'll just move where in the package the malicious code goes.
I largely agree but I still like this change as a reduction in attack surface, even if it's only a relatively minor such reduction. Some other positives:
require which could trivially be called only on the paths where it's used), but the import defer proposal will someday help address that.the whole point of a package manager is to install arbitrary code. Even if npm install doesn't immediately run the code it downloaded, the next command you invoke after that probably will.
I think it's fair to see this not as solving the problem of these attacks, but rather shifting the blame. It's a big, click-wrap "Agree" button that you must press that absolves NPM of responsibility.