Upcoming breaking changes for npm v12 (github.blog)

464 points by plasma a day ago

192 comments:

by bastawhiz 7 hours ago

I'm not sure how I missed that npm was acquired by GitHub, but man, a lot of stuff suddenly makes a lot of sense. I really can't think of a worse home for such a critical part of the Node ecosystem.

by beardsciences 5 hours ago

I literally said "Oh, of course" out loud.

by afavour 5 hours ago

Eh, it was pretty terrible before the acquisition too...

by classified 4 hours ago

Strategical positioning for enshittification, control and future squeezing of profits. Embrace, Extend, Extinguish.

https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguis...

by sneak 2 hours ago

I don't think Microsoft is trying to extend and extinguish javascript or typescript. I do, however, think they are using their standard anticompetitive playbook to disadvantage IDEs that aren't VS Code and agents that aren't Copilot.

For example, it requires some hackery to use your Copilot subscription via the Copilot extension in VSCodium (the f/oss distribution).

They want the default to be writing javascript (where the default is npm), written in VS Code, publishing to GitHub. You can already see NPC devs mindlessly following this pattern.

The response is to refuse to use Microsoft software. Use a Mac, don't use Excel or Word, don't use VS Code. I've also pulled my repos from GitHub and won't publish there or on npm. Their ecosystem makes the world worse, even before you factor in the fact that they happily provide services to ICE to aid them in running concentration camps.

by altruios 2 hours ago

> The response is to refuse to use Microsoft software. Use a Mac

Or Linux: an actual FOSS OS.

by atraac 11 hours ago

postinstall scripts should've been removed long time ago, it's the cancer of NPM packages. There's so many deeply nested, uncontrolled postinstalls that run randomly when you pull something it's insane, I don't know how someone at some point ever though that was a good idea.

by VMG 9 hours ago

I must admit I don't really understand what the point of the post-install script concern is.

Usually, you run the actual packaged dependency code at some point anyway, and usually with the same permissions as the install process.

So all of these setup scripts (good or bad) can just move their entrypoint from npm to wherever the `import` or `require` happens.

It seems to me that this is a small stumbling block at best, unless the whole ecosystem moves to a deno-like sandboxed environment. Maybe that is the plan?

by jeremyjh 7 hours ago

A lot of packages are only used in the browser; if you don't use SSR they'd only be executed by node in unit tests in something like jest, but that is not the only way to run unit tests (Cypress can run them in a headless browser [1], for example). Running those sand-boxed would be the next logical step.

Removing automated execution of postinstall is a necessary step and may as well be the first one.

[1] https://docs.cypress.io/app/component-testing/get-started?ut...

by vbezhenar 8 hours ago

You can build application outside of container, but run it in container. I think that it is simpler workflow, than everything in container (when you actually need to develop it with IDE).

I didn't try devcontainers stuff, TBH. But that's how I often develop my apps.

That said, there are other attack surfaces for that approach. For example I'm not sure if I can trust LSP server not to execute application code. So keeping everything in a container or in a VM seems to be the only sane approach to work with code you don't trust.

by rafaelmn 8 hours ago

>You can build application outside of container, but run it in container. I think that it is simpler workflow, than everything in container (when you actually need to develop it with IDE).

At this point I will not do any dev outside of a container - so many things can be supply chained in the OSS dev stack it's just not worth it, and once you get used to developing in containers it's actually a lot cleaner to move between hosts - you're essentially treating your client as a remote terminal.

If you're doing web dev work in this day an age SSH with tmux or some editor with SSH server support should be your dev setup.

by padjo 7 hours ago

If you only use npm to manage client side deps then it removes the ability to compromise a devs machine or the CI server. Seems like nice attack vectors to just eliminate entirely.

by stefan_ 3 hours ago

If you want to build a modern web frontend you will need to use npm. But a lot of those only ever run in the users browser where they can't do any harm. I would never consider the insanity of that ecosystem for backend work.

by re-thc 3 hours ago

> So all of these setup scripts (good or bad) can just move their entrypoint from npm to wherever the `import` or `require` happens.

That would / could kill performance

> Usually, you run the actual packaged dependency code at some point anyway, and usually with the same permissions as the install process.

So I doubt most people trace every dependency they install all the way. So sometimes it comes upstream. Maybe you don't run it. It could have been a dev dependency accidentally set for runtime and now you have it.

by gear54rus 10 hours ago

Absolutely not, there are plenty of use-cases for them. https://www.npmjs.com/package/patch-package comes to mind off the top of my head.

Hopefully current hysteria will not result in some bs decisions like this.

by homebrewer 10 hours ago

Your own link says that a proper package manager (e.g. pnpm) supports this out of the box.

If there are other use cases that really need post-install scripts, you can whitelist just those in pnpm. In projects I'm working with, there are often zero post-install scripts that must be enabled for everything to work properly, and it's usually from poorly cobbled packages that use them to download prebuilt binaries (well written packages, like biome or tsgo, use per-architecture subpackages).

You enable just one or two of those, and block everything else.

by atraac 7 hours ago

How would getting rid of postinstall break patch-package? If people use a package, and that package needs some kind of step to get working, user of that package should decide when that step happens. He can very well just call patch before building on his own. There's zero issues with that approach and the upside is he actually has control.

I work in a monorepo where running install calls dozens of deeply nested postinstalls of some elaborate NextJs or React Native dependencies other projects use. It's borderline insane. Unless you regularly screen everything, it's impossible to know whether one of those is compromised, especially in the world of Node where is-even is being used and the sheer amount of crypto scams around.

by philipwhiuk 10 hours ago

The entire use-case of that package is a security nightmare.

by gear54rus 10 hours ago

Then don't use it. Just don't presume to tell me if I can or can't.

by dgellow 10 hours ago

Given that has an impact over the whole industry, I will for sure tell you that patching on install SHOULD NOT be a thing. Up to you to run your own post install script yourself

by gear54rus 10 hours ago

It absolutely should and maybe I'll run and advertise a fork that will behave properly. Yay open-source.

by prophesi 5 hours ago

Or maybe just add a script in package.json to run whatever patch-package does (eg, "install:patch": "npm install && patch-package") instead of whitelisting every package to have that power.

by ramon156 10 hours ago

Elaborate on the "behave properly". What is properly here?

by port11 9 hours ago

You’re free to allow scripts as per the linked docs for NPM 12. But the vast majority of us will appreciate the reduced attack surface.

by jeremyjh 7 hours ago

TFA explains how this works, and how to opt out.

by tuckwat 19 hours ago

I bet there have been a hundred different discussions about this inside of NPM since it was disclosed 10 years ago. With Shai Halud it's gotten too big to ignore.

by Eji1700 14 hours ago

I do love that javascript's history is basically just coder mentality distilled. "oh yeah we'll fix that shortly" is almost always "oh fuck now we have to"

by the8472 an hour ago

A different framing would be things moving from a high-trust equilibrium to a low-trust one due to a few bad actors and no other way to stop their activities.

Security part reasonable code robustness, part Red Queen's race. Attackers expend ongoing effort for new exploits, defenders expend ongoing effort to get back into a secure place, everyone ending up where they started.

If world were a nicer place we wouldn't have to "fix that shortly".

by port11 9 hours ago

I chuckled, but this is more about the history of NPM.

In retrospect, allowing an ES consortium seat (Microsoft) to own the largest package repo for the language… might have been a bad idea? Google is one of the worst members of the language board, but Microsoft might be a close second.

Given their ownership of GitHub came with a general community unease, perhaps it’s not surprising that NPM isn’t dating much better. 16 years later we are getting good security controls. Okay.

I’m happy with Deno for most of my needs!

by appplication 14 hours ago

Great, now it’s python’s turn next

by karakanb 20 hours ago

It is not obvious from the post but it seems like the allow list for the scripts supports whitelisting packages instead of a global setting. This should make it easier to maintain org-wise rules to allow scripts only for specific packages.

Is there a linter that could be used for scenarios like this to prevent unsafe default on package manager config?

by philipwhiuk 10 hours ago

grep?

by alexghr 14 hours ago

Are the current LTS node versions (iirc 22, 24, 26) going to update the bundled npm to v12 to benefit from these security fixes? All come with npm v11 now

by jamiem 13 hours ago

Major npm version bumps have landed mid-stream for node in the past: v18.19.0[1] and v20.10.0[2] bumped npm 9 to 10.

[1]: https://nodejs.org/en/blog/release/v18.19.0#npm-updated-to-v... [2]: https://nodejs.org/en/blog/release/v20.10.0

by b112 12 hours ago

They are changes in defaults, which could be construed as a security posture change, but the security fix is in everyone's hands. Just set proper defaults, as per article, and done.

I think the best part of this change, is that the default change will mean that lots of new DEVs just running an install, will see instant breakage with annoying packages that presume these settings are on. It should force people to stop expecting scripts to be runnable, for example.

by partsch 13 hours ago

I wonder if there are still reasons to use yarn? Has yarn also implemented safeguards to protect against supply chain attacks? Until now, I only knew about pnpm. It’s great that npm has followed up.

by arcatek 9 hours ago

Of course. Modern Yarn releases (4.x) are deterministic to a fault and you can rely on it to have a consistent behavior across your whole team. As for feature-wise I'd say it's a lot of small details that together add up once you grow used to them.

The next major release will keep pushing in that direction with both better performances and features we couldn't implement until now due to their reliance on said perfs improvements.

Disclaimer: I'm the Yarn lead maintainer.

by mkesper 8 hours ago

It was a giant mistake to keep 'classic' (umnaintained, unpatched) yarn around. Switched to pnpm in part due to that reason.

by arcatek 7 hours ago

It's not exactly unmaintained (we merged a couple of security patches in the past years), I agree that we should have do something about it.

We'll be correcting this situation starting from the 6.x release, which we expect somewhere in August.

by tuwtuwtuwtuw 9 hours ago

Deterministic to a fault unless you mix Windows and Linux.

https://github.com/yarnpkg/berry/issues/6105

by arcatek 7 hours ago

As mentioned in the issue you link the problem comes from third-party packages with non-deterministic build scripts in git dependencies, or files on disk being actually different (although I guess we could at least try to normalize crlf, but as you can guess it will break someone).

by rozenmd 11 hours ago

I worked on a project that used yarn from the early days all the way up to v3, it's slow as hell, but it works. They also have the supply chain protections.

Eventually we snapped and migrated to pnpm. Installs (both in CI and on local dev machines) are significantly faster. Turned out to be about a day's work to migrate with an LLM's help.

by arcatek 9 hours ago

I don't doubt that 3.x probably has worst perfs (it's almost two years old now), but just to clarify we closely track performances and Yarn and pnpm and pretty much on similar level:

https://p.datadoghq.eu/sb/d2wdprp9uki7gfks-c562c42f4dfd0ade4...

by homebrewer 10 hours ago

One distinguishing feature is their optional install strategy: running packages directly from compressed archives instead of unpacking them into node_modules.

https://yarnpkg.com/features/pnp

Very similar to using .jar's in Java instead of directory trees of .class files.

It's somewhat hacky though, and editor/tool support varies.

- since there are far fewer small files, it can be faster especially on Windows if you're forced to work on it for some reason

- the archives can be stored into the git repository (through git-lfs or friends), removing dependency on the internet and the package registry

by Zanfa 9 hours ago

I don't know what NPM is doing, but yarn installs deps much faster than NPM

by reddalo 5 hours ago

I feel like Bun is even faster than yarn, but I'm afraid to keep using Bun since they made AI rewrite it completely in another language

by partsch 12 hours ago

To the people downvoting my comment: Feel free to answer my question. I really don't know the answer.

by aniceperson a day ago

didn't know npm was owned by github.. well, that explains things...

by shagie 21 hours ago

NPM Is Joining GitHub - https://news.ycombinator.com/item?id=22594549 (March 16, 2020; 571 comments; 1829 points) - https://github.blog/news-insights/company-news/npm-is-joinin...

Some of it aged... interesting.

Top comment:

> Microsoft doesn’t do everything right but the GitHub acquisition has honestly gone better than I ever expected. Rather than forcing GitHub to adopt Microsoft centric policies, Microsoft has adopted more GitHub stuff, especially from a product POV. GitHub still runs as a separate company (different logins and health care and hiring systems) with its own policies and point of view.

> ...

by w29UiIm2Xz 20 hours ago

To be fair, the vibes (at the time) were that Microsoft has changed. Probably, in some way, a zero-interest rate phenomena.

by ok_dad 18 hours ago

Young people thought M$ was changing, the old folks knew it was just another cycle of embrace, extend, extinguish.

by tyre 15 hours ago

Young people were… right?

VS Code is open source. (Cursor is built on it!)

GitHub didn’t embrace, extend, extinguish git. You can git push to a different company (e.g. Gitlab) and you’ve migrated. The biggest problems with GitHub are scaling and availability, not lock-in.

Microsoft today is nothing like it was 30 or 20 years ago.

Fifteen years ago we were writing HTML and JavaScript specifically for Internet Explorer. Edge is built on Chromium.

by pietervdvn 11 hours ago

VScode might be open source (to a degree), but the levers of control are on a different location. See https://ghuntley.com/fracture/ for an excellent blog on it.

by beezlewax 14 hours ago

Do microsoft own git now?

I don't think so

by inigyou 3 hours ago

Pedantically no, but in practice almost yes. So many programmers born after 2006 think that Git and GitHub are the same thing.

by z33k 15 hours ago

Good luck migrating the ”forge” part with the ”git” part. Your github org settings, pull requests, rulesets, CI/CD pipelines, containers, copilot... The lock-in always comes from the ”forge” part, never the ”git” part.

by albedoa 15 hours ago

> GitHub didn’t embrace, extend, extinguish git.

Literally nobody has said that it did? This is a wild strawman. Who are you trying to fool.

by jraph 12 hours ago

> VS Code is open source

Open core at best. It's proprietary software built on top of an open source base. The remote coding feature is proprietary and you need to run proprietary software on the remote server / container to use it. People maintaining forks (like Codium and the Theia IDE) are not allowed to use VS Code's marketplace. Many of their flagship VS Code extensions are proprietary. Why would they do this if they believed in open source?

The distinction is quite important. VS Code aims to get control of the development process of those who are not using Visual Studio. That's the only reason why VS Code exists. VS Code is not a gift no strings attached.

By the way the title of https://code.visualstudio.com/ is a lie that says "The open source AI code editor". Three lines under, there's "By using VS Code, you agree to its license and privacy statement.". The license is https://code.visualstudio.com/license, which is very much like your usual horrible Microsoft EULA, including tracking and forbidden reverse engineering, decompiling or disassembling. Really, the only thing missing there is the license key field at first run.

GitHub is still proprietary SaaS also aiming to control the whole open source ecosystem. With GitHub, a big chunk of the open source (and free software! Which is even sadder) world relies on proprietary infra. That's as close as Extinguish as you can get (it's just that git is not the thing that's Extinguished). GitHub is actually a pretty good example of lock-in, see what other commenters wrote on this.

30 years later, Microsoft, still the same lying company trying to control its users and the world with proprietary software. With the twist that they try a bit harder to look cool and open source (since the moment they realized open source wasn't going to disappear, not before). They really are not, especially for end-user facing software, including when the end-users are developers.

The only thing that dramatically changed is that they don't publicly claim Linux is cancer anymore, and that's probably because they are coerced into dealing with Linux. Exactly like the Web against their failed attempt to privatize it with MSN (MicroSoft Network) (the current MSN news frontpage and the memory of their messenger are only shadows of the original ambitions behind MSN).

At least the stability and consistency is comforting… or not.

Don't fall for their open washing. They just play along and attempt to get control on what they didn't manage to extinguish. Only forced changes happened, the spirit seems intact.

by pjmlp 13 hours ago

Old folks are also aware that applies to every single big tech company that actually sponsors the FOSS tools many don't want to pay anything back, while expecting to be paid themselves.

Old folks also remember the days when it was possible to make a living out of selling software tools.

by hnfong 13 hours ago

The ruthlessness of the Microsoft that we remember was probably due to influence from Bill Gates.

He is famous for hyper-competitiveness and strong desire to win at all costs.

by Dylan16807 16 hours ago

Microsoft has been causing a lot of problems lately but I completely disagree that it fits the pattern of "embrace, extend, extinguish".

by Forgeties79 12 hours ago

Remember when folks thought Phil Spencer was gonna right the Xbox ship lol

by altmanaltman 15 hours ago

it was all good until AI entered the chat

by shimman 20 hours ago

MSFT acquisition of NPM was a massive shit show, they fired many staff engineers and people that were at github for quite a while. Top comment was a liar.

by _pythonlover_ 13 hours ago

I was part of the npm team at GitHub. They laid off almost the entire team to focus on AI (CTO literally told us on the layoff announcement call that they're doing this to focus on Copilot)

by moi2388 5 hours ago

Fortunately npm was a shitshow long before ai

by tomnipotent 18 hours ago

> they fired many staff engineers

Would you rather the company went under after it ran out of money and had to fire everyone instead? Not to mention a quarter of the company was laid off the year before the acquisition.

by 7bit 13 hours ago

Was that the case? Can you provide sources to your claims and provide a foundation to your theories?

by dust-jacket 10 hours ago

https://www.theregister.com/software/2019/04/01/nice-people-...

Year before the MSFT takeover. No idea about their actual financials but they were definitely shedding headcount pre 2020, including kicking people for trying to unionise.

by 7bit 9 hours ago

Nothing in there suggests that this was done to save the company from bankruptcy, which was the wild claim.

by tomnipotent 4 hours ago

No one said anything about bankruptcy, you seem to have made that up for your "argument" or whatever this is. The company didn't have a viable business model and was running out of cash. MSFT right-sized the team for the project they wanted it to be, rather than the business model the prior company was trying to be.

by 7bit an hour ago

Learn to read

> Would you rather the company went under after it ran out of money and had to fire everyone instead?

by shimman 5 hours ago

Yeah, it's like people are forgetting that the executive team at GitHub was composed of sex pests and people defending said sex pest. Of course they'll call any attempt at unionizing as "damaging" to the company and must be blamed accordingly!

After all the company was in such dire straights that they were acquired for $7.5 billion! Only companies with terrible prospects get acquired, that's just business 102.

by tomnipotent 12 hours ago

It's literally a Google search away. If you had the time to write this comment, you had more than enough time to do the search.

by jasonlotito 5 hours ago

Google said you are 100% wrong.

by tomnipotent 4 hours ago

Right, the very public two rounds of layoffs the company did right before being "acquired" had nothing to do with them running out of money.

by 7bit 9 hours ago

Not my job to proof the wild claim that the layoffs were to save the company from bankruptcy .

by tomnipotent 4 hours ago

The company raised $10M, did two rounds of layoffs totaling a quarter of the company, and was then acquired not long after. Early stage companies like that don't do layoffs unless it's to extend cash runway, but run wild with whatever unfounded fantasy you have about it all.

by shimman 17 hours ago

Uhh, I'd expect the trillion dollar transnational corporation to do right by it's workers rather than rat fucking them to appease corporate do-nothing leeches if I'm being frank.

by luckman212 16 hours ago

> I'd expect the trillion dollar transnational corporation to do right

you would? has any trillion dollar corporation ever?

by shimman 15 hours ago

No, and that's why we must destroy them. Figuratively then literally.

by altmanaltman 15 hours ago

Destroy what exactly? And replace with what?

by Dr4kn 12 hours ago

With smaller companies that can't yield global power. It would be better if cloud, office and OS would be separate. Then you wouldn't get shuffed OneDrive into the OS. It's also better for competition if the playing field is equal and one solution isn't the only one that can deeply integrate. Build APIs or don't do it.

by Forgeties79 12 hours ago

Can y’all just state your opinions on these things rather than constantly asking bait-y questions?

by shimman 5 hours ago

Enemies of democracy don't want to do this because it would require acknowledge that technology companies in the US have been mostly a force of evil rather than good and the idea we should change that makes a small minority of people uncomfortable.

by ralph84 19 hours ago

NPM (the company) was about to go under in 2020. They raised VC but never found a sustainable business model. GitHub acquired them to keep the ecosystem alive. The acquisition hasn't really benefitted GitHub much at all.

by materielle 19 hours ago

I don’t know if this is the case here, but it’s very hard in general to judge how much software projects ought to cost.

Software projects will grow in complexity to consume whatever budget you give it. If you hire 50 devs and give them a bunch of business objectives, they are going to do what they do and write a ton of software.

It’s not obvious to me that it would be theoretically impossible to build a cheaper package manager.

by monster_truck 19 hours ago

And additionally was it truly worth buying if this is what we've ended up with? Some things should be allowed to fail

by arcatek 9 hours ago

Eh, easy to say. Remember how Sourceforge started shipping ads in binaries people downloaded? If you think failing was the worst scenario, you lack imagination.

by joeyhage 21 hours ago

Most people know this but the _real_ reason it explains things is that GitHub is owned by Microsoft. Oh, and Microsoft moved GitHub to Azure

by amitport 16 hours ago

To be fair, NPM sucked long before it got acquired by Github/Microsoft.

And to be fair 2: The other package repos also suck.

by jbverschoor 14 hours ago

Yeah, but the azure supply chain attack explains why all of a sudden they can make this change.

It seems that if you want to get something important changed in npm, you simply need exploit some of its short comings against Microsoft instead of discussing why it’s necessary.

by creesch 9 hours ago

> And to be fair 2: The other package repos also suck.

If you mean other languages, then yeah a lot of similar issues and weirdness there as well. Maven dependencies in any complex project are a "fun" challenge as well.

Though the sort of recurring supply chain attacks you see within the npm ecosystem is something I haven't seen elsewhere to this degree.

by tempay 14 hours ago

To be fair, the entire problem space sucks and I’m not sure it’s possible not to.

by domh 13 hours ago

I knew it was owned by github, but this is the first time I've personally seen the release notes on github's blog instead of npm's.

by BowBun 21 hours ago

yes, since 2020

by beart 18 hours ago

Does the allow list in package.json pin to the package version, or only to the package name?

by thatmf 20 hours ago

> allowScripts defaults to off

Nice that they're following pnpm's lead on this after [checks watch]... 18 months?

by MrBuddyCasino 17 hours ago

Java‘s Maven never had them, never felt a need for them.

What is their purpose in JS land?

by tuananh 16 hours ago

native modules. nodejs can have native modules (written in C++, Rust, etc...). Projects usually ship prebuilt natives binaries (for each arch/OS/Nodejs ABI combination) hosted on GitHub Releases and download them automatically at installation time; fallback to build from source if not found. that's where scripts are used

the reason for not bundling all native binaries is becasue the no. of combinations are huge and it can make module size hundreds of MBs

by sroussey 13 hours ago

Having a non-script method of downloading the right native binary would be a good next step.

by MrBuddyCasino 12 hours ago

Yeah this seems manageable.

by bakkoting 4 hours ago

This used to be more common but the pattern these days is to have the binaries split into optionalDependencies which declare their supported CPU etc, one per supported platform. Then npm will install just the matching one (optionalDependencies that require a different platform aren't installed).

The fact that most of the ecosystem has moved to this pattern is a big part of why this change is now feasible.

by rswail 5 hours ago

Not an NPM user, but you can't specify a set of arch combinations and NPM will get the appropriate prebuilts?

That sounds like an NPM problem that would be relatively easy to fix.

Can the builds be sandboxed with strictly limited capabilities?

All of this sounds solvable, why hasn't it?

by vardump 10 hours ago

There should be a path for local building as well. Node.js is being used on a lot of embedded systems. I’d imagine there are also lots of other reasons for local builds.

by tuananh 10 hours ago

there's fallback to build from source but it would require the builder to have all the toolchain installed (whatever the library is using: could be gcc, python, rustc....)

by inigyou 3 hours ago

Maven has plugins which are downloadable modules that run at install time, IIRC?

by dgoldstein0 17 hours ago

Off the top of my head the purposes I've seen for them: - building native bindings (node-sass) - asking for funding (core-js)

... Probably a few more but the native case is probably the biggest and the packages I'm using nowadays ship precompiled blobs in optionalDependencies. Install scripts seem to be out of favor.

by WorldMaker an hour ago

After the backlash of using postinstall scripts for funding requests, most of that moved to the dedicated infrastructure of the `"funding"` key in package.json [1] and the `npm fund` [2] command. (Not that most companies/users pay any more attention to this funding request messaging other than maybe adding `--no-fund` to some of their `npm install` scripts, but it is still an improvement over using scripts to do it.)

[1] https://docs.npmjs.com/cli/v10/configuring-npm/package-json?...

[2] https://docs.npmjs.com/cli/v11/commands/npm-fund

by ComputerGuru 20 hours ago

My big question as an OSS dev distributing some precompiled binaries via npm for easy installation: does allowScripts also default to disabled when directly installing a package (globally or otherwise)?

by jamiem 14 hours ago

Yes, all install scripts will be disabled by default regardless of if they are from direct or transitive dependencies.

But if you're already following the os + cpu + optionalDependencies model to distribute your precompiled binaries you should be fine.

by efortis 21 hours ago

this release fixes a vulnerability reported 10 years ago

https://www.kb.cert.org/vuls/id/319816

by ares623 17 hours ago

Breaking: AI fixes 10 year old vulnerability!

by butz 5 hours ago

Better late than never.

by peterkelly 12 hours ago

Now all the malware can move from the install script to the module itself where it will inevitably still be run

by chimpanzee2 12 hours ago

Cool, but I default to pnpm these days anyway.

by TZubiri 21 hours ago

Looks good? But doesn't this just change the compromise window from first installation to first run?

by semiquaver 21 hours ago

Ok? Not sure what a package manager can do about the fact that eventually you want to run the things you install.

by frabcus 12 hours ago

Have any kind of provenance. eg like Debian has for 30 years. Key signing in person etc

by tpetry 10 hours ago

That has also been implemented recently. With staged publishing the author must verify a new release with 2FA so automated attacks dont work anymore. Some human in the loop must verify a release.

by grassfedgeek 21 hours ago

"First run" doesn't exist for JavaScript libs used only in web apps. So for that entire class of packages this change makes them safe.

by Rohansi 16 hours ago

Don't forget about tests. That'll run code for every package that is imported. Yes, imported, because in JS importing means "run all the top level code in this file". So to continue exploiting you just place your malicious code in index.js instead of a postinstall script. Not as guaranteed to run but still very likely.

by tabwidth 20 hours ago

Build tooling still runs though. Your bundler plugin or PostCSS transform gets full fs access at build time, nobody's auditing that.

by TZubiri 19 hours ago

Build deps are even disregarded as less critical than runtime deps traditionally. So deps like sphynx for building docs are still a dev side supply chain vector.

https://github.com/kennethreitz/pytheory/issues/47

The reason this may be overlooked is because build deps are only ran by the devs, but not the users, so users dismiss it as safe. However, if a build dep is infected, the infection may spread to the actual package code, which will then of course be run by the user.

Not theoretical, Microsoft is currently under attack by a worm that spreads through vs code extensions, which then spread to actual packages that users run.

by pjio 14 hours ago

> So for that entire class of packages this change makes them safe.

This is misleading. The change addresses one important attack vector. But if one runs the application directly on the host for development, if the package is imported like pointed out in the other comments or the package intends to steal user credentials from production, it is far from "being safe". Safer, but still needs scrutiny.

by WatchDog 20 hours ago

"First run" certainly exists in web apps, it's just running JS in a browser rather than a shell script on a developer or CI machine.

There is plenty of malicious stuff you can do from the browser.

by TZubiri 19 hours ago

But this is npm, the execution environment is not the browser, but the server.

Most packages are imported via import/require, even if it's a browser only package. Because of SSR and reasons.

Or maybe not, let's look at a random browser only example, angular and react will use SSR, so they will execute in the server, let's check Jquery:

https://www.npmjs.com/package/jquery

Docs suggest just using a script tag instead of npm, when using npm install, they suggest to run import statement, which can execute arbitrary code.

The bottom line seems to be that if you are using npm, it's cause you are using node, and therefore you will run the imported code in the server, otherwise you would use a script tag.

But maybe there's a way to define a browser only package or .js URL such that it is only downloaded and served but never executed server side?

In any case, not a huge usecase of npm, which again, is designed for node which is backend.

Randome example,

include

by christophilus 21 hours ago

Better than nothing. That’s the same problem every package manager has.

by insanitybit 21 hours ago

Yes, but that's actually a huge win. I can't know what a package needs to do at install time - the dev knows that. But I know what my tests and program need to do at runtime because it's my job to understand those things.

The dev has to be responsible for ensuring that their build scripts are safe, I need to be responsible for ensuring that my runtime is safe.

It'd be great to have more tools for untrusting libraries (iframes are awesome for this on the frontend) but this is still a massive win.

by tentacleuno 11 hours ago

v8 does have a sandbox feature for running untrusted scripts, and it's quite good. There's also Node's VM module.

by Someone1234 21 hours ago

I’m sure we’d all welcome your alternative and or superior proposals.

Without that, this just comes across like unconstructive commentary.

This moves the needle a little your proposals or the lack thereof don’t move it at all. So I’ll take this over nothing.

by spartanatreyu 20 hours ago

We already have alternative and superior proposals, it's called Deno.

It's node + npm compatible and its permission system locks everything down by default.

If you know ahead of time, you can turn on which permissions something is supposed to have in the config file.

Or you can just not use a config file at all. Anytime it needs a permission: it asks you what it wants. You can say yes or no, and those are saved in the config file for next time. If you say no, the script throws an error where it tried to access something it didn't have permission for.

---

Example:

- My linter wants access to my file system?

  - You can have read access to ./src/ts/
- My bundler wants read and write access to my file system?

  - You can have read access to ./src/ts and write access to ./build-output

  - Huh, what's that? The bundler was trying to both read and write a file in ./src/ts?

  - We don't want input files getting overwritten, that's a recipe for hard-to-diagnose race conditions. Looks like the permission system did more than just keep things secure, it's like a type system for IO.

  - Oh, look at that, there was a very subtle bundler misconfig, let me fix that now. How long would that have existed if we didn't use deno...
- Oh what's this? An updated dependency I've been using for 6 months suddenly asking for access to my .env file, and asking to run curl in a separate process? How about "no". Why would a simple DOM utility dependency be asking for those permissions? Ah, looks like it was part of a credential stealing supply chain attack. Glad I wasn't using node.

---

Addendum: Node now has a permission system, but it's broken by design so it's useless.

by tpetry 10 hours ago

Can you clarify why the node permission system is broken but the deno one works? For an outsider like me both look like the same.

by TZubiri 17 hours ago

You'll notice that my comment was a question, you can tell by the presence of question marks at the end of the sentence.

Additionally, if a comment were to hypothetically point out an issue, that is valuable on its own. If someone reacts to a comment that points out an issue this defensively, it's a huge red flag.

by mschuster91 21 hours ago

An idea might be to not just pin "package xyz allowed", but "package xyz postinstall allowed with hash <1234>".

by jffry 20 hours ago

The default behavior for the automated "add everything existing to the allowlist" is to include the specific version: https://docs.npmjs.com/cli/v11/using-npm/config#allow-script...

Together with a lockfile that does achieve "package xyz postinstall allowed with hash <1234>"

by Zopieux 20 hours ago

Eh, that only took a few dozen actively exploited supply-chain vulns in the span of two years!

by dawnerd 20 hours ago

Only took Microsoft themselves getting hit with it for things to change.

by thrdbndndn 18 hours ago

How do you allow scripts for tools installed globally?

by jamiem 14 hours ago

Either pass the --allow-scripts=<pkg> flag with npx or npm install -g, or set allow-scripts=<pkg> in .npmrc

by z3t4 10 hours ago

npmjs.org is a joke at this point. I guess their support is run by LLM because you can just write to them and they will transfer ownership of any module nilly willy.

by tobyhinloopen 10 hours ago

That’s a bold claim to randomly write without any supporting sources

by z3t4 9 hours ago

I've got an example and submitted it via bug bounty channel, but they classified it as "social engineering".

by jbverschoor 14 hours ago

And when will we get rid of the vendored node_modules, and make it read only?

by heldrida 20 hours ago

> The resulting allowlist is written to package.json

Couldn’t this effectively result in the same process we get in pre-12 defaults?

by CGamesPlay 17 hours ago

It's unstated, but I'm willing to assume that only the root package.json is consulted to decide if these scripts are allowed. Otherwise, yes, this would not actually change anything.

by heldrida 11 hours ago

Thanks for the sanity check!

Had a quick read on my mobile, and that was my first impression.

Guess its more of a way to make the maintainers accountable instead of making npm reputation the main focus.

by philipwhiuk 10 hours ago

> On balance, it’s npm’s belief that the utility of having installation scripts is greater than the risk of worms. This is a tradeoff that we will continue to evaluate.

They chose...poorly

by Pxtl 19 hours ago

I would've assumed lockfile-by-default. We're still going with auto-updating?

by jbreckmckye 18 hours ago

You do get a lockfile by default

by retardedsecguy 19 hours ago

npm is basically pnpm now

by cute_boi 17 hours ago

Except pnpm is written in Rust and is very fast, saves disk and has much more advantage.

by uasi 11 hours ago

> pnpm is written in Rust

Not just yet. The Rust rewrite of the installation engine is still experimental and available as an opt-in preview[0].

[0] https://github.com/pnpm/pnpm/releases/tag/v11.2.2

by cute_boi 21 hours ago

They should have added a 1-day age limit by default, so security scanners have some time.

by KolmogorovComp 21 hours ago

I don't think it'd necessarily be a good decision, sometimes CVE are actively exploited and need quick patching.

A better safety net would be to require active 2FA proof for every package update.

by therealmarv 19 hours ago

As if supply chain attacks could have been prevented by 2fa or passkeys always.

You want delays by x days because supply chain attacks get caught very often within 1-2 days. And if you really really want to make an exception for a zero day then that's no problem and you can still quick patch by exclusion of that rule. They don't contradict in a unsolvable problem. You want both, you get both.

by doctorpangloss 19 hours ago

How do you know what's a zero day fix?

(You write something)

So then you have to check every package's updates and decide if you update, yes?

by tuwtuwtuwtuw 8 hours ago

Yes, you need to check security issues reported for packages and then take a decision. What is the alternative?

by jnwatson 21 hours ago

If you need a quick patch, you pass another parameter to turn off the 1 day. 1 day delay will prevent more problems than it makes.

by b112 12 hours ago

While I think this may be true, what validation do you have on this point?

Have you rolled the numbers, vs all of the high-pri security updates that will be missed on day one, and exploited?

What is really needed is simply more nuance. I agree the delay can help, but honestly the entire ecosystem is broken. There shouldn't be a single thing installed, without someone having an eyes-on. That's how this is fixed.

Distros aren't perfect, but they handle this a load better. And this really runs to the problem, people want "new new new", yet often have very little real reason to want it. 99% of npm packages could be 5 years old, and no one would care.

But outside of that, npm could operate like a distro, but with more of a Debian unstable -> testing method, where it typically takes a few days for this migration to happen.

My point is, the fix isn't publishing by default, then hoping to catch. The fix is that nothing gets published, without a QA/validation step. Of course, that takes money. There is naturally, a super easy fix for that.

The code stays open source. The licensing stays <insert whatever by author>. However?

The ToS for using any or all of the npm architecture is if you're a company, you pay. If you neglect to pay, eg you don't register as a corporate entity, set up and account, and pay per use, then as per ToS the licensing is invalid, and you're fined via a copyright infringement. And yes, this would mean all npm packages would have an altered licensing model, basically with this tacked on.

Is what I'm saying perfect? Nope. Yet it's the general path which should be taken. And frankly, with the way things are going, this level of audit would allow for staff also categorize licenses, ensure accurate template files, and so on.

And some of this is the perfect use of an LLM. Not to do the work, but to flag with human review.

--

This ecosystem is done. Its model is broken. The concept of downloading random stuff without auditing in any way, is broken. The industry will be moving away, is starting to move away, and is having to move away.

So... how can this survive with that concept?

If one doesn't like my proposal above, then they should provide an alterative which allows:

* companies to have validate of licensing * audits which validate change is not untoward

by dns_snek an hour ago

> Have you rolled the numbers, vs all of the high-pri security updates that will be missed on day one, and exploited?

(Different person here) I don't have data and I don't think I need it. You either have a process to push security-critical updates out very rapidly or you don't.

If you have that process then nothing changes for you because that cooldown won't be used in that context.

If you don't have that process then nothing changes for you because you weren't pushing out those time-sensitive patches to begin with. But now you won't get hit by drive-by supply chain attacks.

The vast majority of "high severity vulnerabilities" in your dependencies are just noise by the virtue of not being exploitable in the manner that they're used in your project.

by alexdns 20 hours ago

so this parameter can be passed by the attackers also thus making your point pointless

by gbear605 20 hours ago

The idea of the parameter is stopping the attackers from getting on your system in the first place

by therealmarv 19 hours ago

that parameter cannot be set by a package, you only can set it

by woodruffw 16 hours ago

I think you want both of these things. Realistically we're not at a point yet where all MFA credentials are phishing resistant.

by hedora 15 hours ago

“How do I get my security hardened CD pipeline to 2FA?”

by geophph 20 hours ago

The maintainer of pnpm mentioned this on the pod rocket podcast recently. Based on recent npm exploits they decided to (and based on a poll they did most users agreed) set to 1 day by default in v11. Can always choose to change it if you desire.

by frabcus 12 hours ago

LLMs are reducing n-day exploit time rapidly.

https://red.anthropic.com/2026/n-days/

So that is a poor bandaid to use now. Maybe instead validate things before, and have more of a cathedral and human reputation system.

by themafia 20 hours ago

The "aw geez, enough is enough" release.

Finally.

by Tiberium 21 hours ago

I hope GitHub changes their vibecoded badges, what does RETIRED even signify in this context? Why does the preview have to be in ominous red?

by mort96 21 hours ago

Hahaha that's amazing, just a big red "RETIRED" badge above their blog post? What the hell

by petetnt 21 hours ago

Breaking changes have had that tag for ages

by mort96 20 hours ago

Really? Retired? What does that even mean in this context, why not "breaking" or something else that suggests breaking change?

by behindsight 19 hours ago

> Retired? What does that even mean in this context

"retired" is probably a followup to functionality that was "deprecated".

I agree "breaking" would be clearer

by mort96 13 hours ago

What exactly is it that's now retired that used to be deprecated? Isn't this just a collection of breaking changes to defaults?

by behindsight 13 hours ago

if you go to the full changelog on the blog and click on the "retired" button, the url will have type=deprecations as the parameter.

It's a holdover from previous posts where there were more clearly defined deprecations.

but yes, in this case it's more of a behavioural change of defaults, so they just picked the closest vaguely mapped retired/deprecations tag.

1: https://github.blog/changelog/?type=deprecations

by sheept 20 hours ago

The changelog design has been like that since last year,[0] which predates today's slop design of small caps and monospace text (probably because they both are based on the same design trend). A year ago, vibe coded websites leaned more on sans serif and gradient text.

[0]: https://github.blog/changelog/2025-05-05-improvements-to-cha...

by cookiengineer 17 hours ago

What a pointless change.

If you force every user to just use "--enable-unsecure-feature", guess what will happen?

This is not about improving security. This is about shifting blame.

A much better alternative would've been the introduction of sandboxes or simulation runs that would output which scripts and programs are running due to unpredictable dependencies. This way the user could check before the actual execution, and maintain an allow list much easier. That could be done via an npm update && npm upgrade workflow where the update generates the list that the user has to manually confirm.

Heck, even a chroot would be an improvement, and they're almost pointless these days, considering how good malware got at escaping chroots.

by woodruffw 16 hours ago

I don't think it's pointless. A large number (the majority?) of users probably don't need install scripts, so disabling them by default is a net security improvement. Those that do can enable the insecure behavior, which will become an explicit decision that is trackable, auditable, etc.

You're not wrong about sandboxing, but sandboxing isn't something that can just be blithely introduced to a large packaging ecosystem that previously assumed full system access. Doing so results in the same kind of regression you point out: if the sandboxing breaks peoples' builds, they'll just disable it and move on with their goals.

by garbagepatch 16 hours ago

Most users don't need it. Having it on by default is a feature for malware writers not users.

But to your point, Node has had permission flags for a while[0] but allows everything by default. Npm could use them to increase security even more. I just hope it doesn't take them another 10 years to change the default.

[0] https://nodejs.org/api/permissions.html

by hedora 15 hours ago

Most packages don’t need it, but I imagine a large percentage of users do since most projects pull in an insane number of packages.

Still, “default off” is better. It would be nice if there were a lightweight way to fork upstream packages, and cache the native builds. It’d improve build times, make the build step more explicit / sandboxable and allow for easier binary builds for operating systems and processors that M$ treats as second class.

by inigyou 3 hours ago

This is pip with --break-system-packages heh

by recursive 16 hours ago

I'm not going to get forced.

by imtringued 8 hours ago

This is kind of like arguing that immutable by default variables are pointless.

If you force every user to just write "mut", guess what will happen?

They will write "mut" when they need mutable variables, which in practice turns out to be the minority of variables.

It's the same with "Option". The vast majority of variables or struct members do not need to be nullable at all.

by cookiengineer 6 hours ago

> If you force every user to just write "mut", guess what will happen?

This is the wrong analogy.

The equivalent analogy would be using a compiler flag that is triggered for all dependencies and all included libraries without a per-library or per-file changeability. Something like "gcc --force-mut-all-yolo".

Variables have scopes of concern. This new NPM feature has no scope. And that's what my critique is about, because it makes it still unpredictable if any of your dependencies of dependencies needs a script.

The spread vector of potential malware stays identical, because the reason the miasma worm is spreading so fast is because of dependencies of dependencies that are impossible to audit on a case-by-case basis, given the lack of sandboxes and the lack of allowlisting scripts on a per-dep-and-version basis.

by SCLeo 18 hours ago

I don't get it. How does this help with anything? You pull in a dependency to use it, right?

by dlopes7 17 hours ago

Well pulling some code is different than running a script on your machine

by SCLeo 5 hours ago

Frequency of actions matter, especially for security changes. If we are talking about git, I agree. If we are talking about npm, I bet 95%+ times people install packages in order to use them, not just to admire the code.

Someone else in this thread mentioned that npm can be used to manage pure front end libraries, which is a fair point.

by zarzavat 18 hours ago

There's an easy way to stop most supply chain attacks:

1. Publishing users must approve each and every release from a smartphone app.

2. Publishing users must provide verified government ID.

The first step prevents the types of attacks where an attacker gets control of a maintainer's computer and publishes a new release.

The second step discourages attacks where a user tries to get a malicious package used by others.

When combined with the security features that already exist, e.g. delays and automatic scanning, it would make it considerably harder to pull off a successful attack.

by ifwinterco 14 hours ago

Issue is this is such a pain (and shuts out a large percentage of the world population) that you'll inevitably get a parallel ecosystem of packages without these onerous controls that everyone would end up using.

I don't know how to square the circle but any variation of "make it safer but really painful and difficult for anyone to publish a package" has this problem

by inigyou 3 hours ago

How would this prevent Shai Halud?

Data from: Hacker News, provided by Hacker News (unofficial) API