Malicious npm packages detected across Red Hat Cloud Services (github.com)

617 points by kurmiashish 4 hours ago

eranation 2 hours ago

Hope it's ok I hijack this thread again about setting up cooldowns... (copy pasting my last comment when tanstack was compromised):

I know people have opinions about cooldowns, but they would have saved you from axios, tanstack, (+ @redhat-cloud-services) and many other recent npm supply chain attacks. If you have Artifactory / Nexus, you probably already have cooldowns, but it's easy to set up if you don't. Why cooldowns? Most npm (or pypi) compromises were taken down within hours, cooldowns simply mean - ignore any package with release date younger than N days (1 day can work, 3 days is ok, 7 days is a bit of an overkill but works too)

How to set them up?

- use latest pnpm, they added 1 day cooldown by default https://pnpm.io/supply-chain-security

- or if you want a one click fix, use https://depsguard.com (cli that adds cooldowns + other recommended settings to npm, pnpm, yarn, bun, uv, dependabot and, disclaimer: I’m the maintainer)

- or use https://cooldowns.dev which is more focused on, well, cooldowns, with also a script to help set it up locally

All are open source / free.

If you know how to edit your ~/.npmrc etc, you don't really need any of them, but if you have a loved one who just needs a one click fix, these can likely save them from the next attack.

Caveat - if you need to patch a new critical CVE, you need to bypass the cooldown, but each of them have a way to do so (described in detail in depsguard.com / cooldowns.dev) In the past few months, while I don't have hard numbers, it seems more risk has come from Software Supply Chain attacks (malicious versions pushed) than from new zero day CVEs (even in the age of Mythos driven vulnerability discovery)

pavel_lishin an hour ago

A friend of mine has a github repo with references to how to set things up in sane and slightly more secure manner: https://github.com/jordanconway/package-manager-hardening

nicolewhite 43 minutes ago

From that repo:

> Exact version pinning — specifying precise versions (1.0.0, ==1.0.0, =1.0.0, = 5.31.0) rather than ranges (^, ~>, >=) in package manifests. Ranges allow any version satisfying the constraint to be resolved at install time; exact pins mean only one version is ever valid.

My understanding is that pinning the dependency within the manifest isn't the mechanism that prevents the version from changing across installs -- it's the lockfile that accomplishes this.

eranation 37 minutes ago

Normal_gaussian an hour ago

> If you know how to edit your ~/.npmrc etc, you don't really need any of them, but if you have a loved one who just needs a one click fix, these can likely save them from the next attack.

This feels like a very very small group of people; and people who really could do with opening the file and adding the line.

eranation an hour ago

I wish that was the case. Asking people to do something simple, doesn't matter how simple it is, depends on how simple they view it. Changing your own car's oil is actually not that hard, once you know how to do it, most people don't even try. Think of QR codes, people hardly used them for many years, because you needed to download an app for it, small step. It only started to catch up when you had it built in the camera app in most providers. In any funnel, each step, no matter how easy, adds friction, remove the friction and you get bigger adoption.

So yes, everyone could open a file and edit it, also everyone could watch a youtube video on how to do X and yet choose to have someone else do it for them :)

Normal_gaussian 44 minutes ago

hedora an hour ago

StilesCrisis an hour ago

make3 5 minutes ago

theoretical question, do cooldowns still work if everyone has them?

chillax 2 minutes ago

Companies such as socket and safedep will still scan new packages and alert on malware (if they are able to detect it) so the packages are taken down before they pass your cool down

ZiiS 3 minutes ago

Less well maybe but yes. Security researchers still proactively test them, and the maintainer has a much better chance of catching it themselves.

doctorpangloss an hour ago

> Caveat - if you need to patch a new critical CVE, you need to bypass the cooldown,

by now, you should have received the feedback about why cooldowns don't make sense and why nobody is adopting them. look, you are writing an expression of the reason why right there.

eranation 32 minutes ago

I don't agree that nobody is adopting them. Can you please elaborate?

- Most companies I know have a 24 hours (at least) cooldown via their Artifactory / Nexus. They have ways to bypass it for urgent CVEs

- pnpm just adopted 24 hours cooldown as default, based on community feedback.

doctorpangloss 26 minutes ago

dmix 4 hours ago

Our company uses yarn 4 which has an option to prevent you from installing an npm package for the first number of days of its release. Most of these seem to be caught within that timeframe (1-3 days).

https://gist.github.com/mcollina/b294a6c39ee700d24073c0e5a4e...

0xbadcafebee 2 hours ago

The package event-stream was compromised and went unnoticed for 60 days: https://medium.com/intrinsic-blog/compromised-npm-package-ev...

The package axios was compromised, and hijacked the author's credentials, so every attempt at a fix was unfixed. https://www.trendmicro.com/en_us/research/26/c/axios-npm-pac...

The xz utility was backdoored for 2 months: https://gigazine.net/gsc_news/en/20240403-timeline-of-xz-ope...

A student researcher took over Python ctx and PHPass package maintainership, pushing out malicious changes, and that took over 7 days to be detected and fixed: https://infosecwriteups.com/how-i-hacked-ctx-and-phpass-modu...

Kaspersky found multiple PyPI packages that had been exploited for more than a year: https://www.kaspersky.com/about/press-releases/kaspersky-unc...

"LoftyLife" packages were exploited for several months: https://securelist.com/lofylife-malicious-npm-packages/10701...

Now that the attack window has changed to 7 days, all new exploits like these will come with time bombs to not trigger until 8 days.

pixl97 an hour ago

Instant attacks are much easier and more common than delayed attacks. Security is an onion.

Sayrus 2 hours ago

> Now that the attack window has changed to 7 days, all new exploits like these will come with time bombs to not trigger until 8 days.

Many automated scanners use static code analysis rather than run the installation script. Not all of them are caught, but a good part of them are and you'd be saved by a delay.

mihaelm 3 hours ago

`pnpm` also has that and it's on by default since `v11`:

https://pnpm.io/settings#minimumreleaseage

vinnymac 2 hours ago

It’s on by default in yarn 4 too now, but pnpm was the first to market that default minimum gate.

https://github.com/yarnpkg/berry/pull/7135

user3939382 an hour ago

iwhalen 4 hours ago

uv supports the same for any Python developers out there: https://docs.astral.sh/uv/concepts/resolution/#dependency-co...

KORraN 3 hours ago

pip has recently added a similar option, i.e.

`pip install --uploaded-prior-to P7D pre-commit`

https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-upl...

no-name-here 2 hours ago

Sadly I haven't seen that Visual Studio/Rider/dotnet/VS Code have such a feature for the C#/dotnet/nuget ecosystem.

orphea 2 hours ago

darth_avocado 4 hours ago

And somehow poetry doesn’t in 2026.

armanckeser 3 hours ago

dist-epoch 3 hours ago

wg0 2 hours ago

If everybody starts to delay for 3 days, wouldn't it be the case that everyone would discover it on the 3rd day?

pixl97 an hour ago

Most attacks are discovered 'pretty quickly' via scanning services and groups that monitor repositories. The problem is even an hour gap could mean tens of thousands of downloads and executions.

cortesoft 2 hours ago

Vulnerability scanners and security researchers would be looking those first 3 days

darth_avocado 3 hours ago

There is something to be said about the need to keep all the packages as the latest and the greatest at all times. Every minor version update doesn’t need to be immediately applied. And maybe high and critical vulnerabilities don’t need to be a minor version upgrade.

Waterluvian 3 hours ago

I’m having a real problem at work with security theatre and the growing push to obsess over numbers of “vulnerabilities” in our projects. And then auto Dependabot PRs that encourage churn to fix issues that if an informed person actually reviews easily concludes it doesn’t affect us in the slightest.

chrisweekly 3 hours ago

"maybe high and critical vulnerabilities don’t need to be a minor version upgrade"

huh? what do you suggest instead?

darth_avocado 3 hours ago

kylebebak 2 hours ago

npm supports this now as well, with e.g. `min-release-age=7` in `.npmrc`

winrid an hour ago

not if you have internal repos?

hedora 43 minutes ago

phoronixrly 4 hours ago

What happens when everyone adopts this policy? You just change it to two weeks?

blm126 3 hours ago

The one week cooldown option is not relying on other users to be a canary for you. Its just giving automated scanners a chance to notice. This is the perfect example. I don't think step security found this by accident. They are actively monitoring NPM package releases at some level.

There is something to be said that Microsoft should be scanning packages pre-release. They aren't, though, so for right now there is a ton of value with very little downside if people implement a one week cooldown period.

To answer your question directly, though. If everyone else moves to a one week cooldown, I would absolutely suggest a two week cooldown is a good idea. Being the "slow" moving organization is a good security trade-off so long as you don't take it to extremes and have escape hatches when you actually need to be moving quickly.

hedora 40 minutes ago

phoronixrly 3 hours ago

JoshTriplett 4 hours ago

A large array of automated and semi-automated security scanners are finding things quickly. The main benefit of waiting before updating is to give those scanners time to work.

genxy 2 hours ago

Ukv 3 hours ago

Security scans and authors realizing an unauthorized version was pushed will generally happen regardless of whether regular users updated. Even for compromises that are found by users updating, it'd generally be better to reduce the number of people affected with a slow roll-out rather than everyone jumping on at once.

Tomte 4 hours ago

You rely on the security companies scanning the packages.

exitb 4 hours ago

ZiiS 3 hours ago

sandos 3 hours ago

BoredPositron 4 hours ago

Always one day more than people on HN tell you. If something is compromised you will hear people complaining here that three days is not enough.

bakugo 3 hours ago

This will never happen unless it's made the default. Most people will always stick with the defaults.

olejorgenb 2 hours ago

pnpm also support this

dmix 2 hours ago

The gist link above covers how to use it in yarn, npm, and pnpm

insanitybit 3 hours ago

Just some suggestions:

1. Dependency cooldowns of 1-2 days seem to be extremely effective without negatively impacting your ability to patch for CVEs.

2. Anywhere you have `npm install` or `npm test` or anything where code executes, that should happen in an environment that has no privileges. In your github actions you can do this semi-straightforwardly by using two separate jobs - one to build the artifacts and test them, another to do any sort of publishing, signing, etc. If you use AI, add a skill / guidance to enforce this pattern.

3. If you use Github Actions, install the latest version of zizmor. It will significantly improve your posture.

(2) means that you are no longer "wormable", which is a massive part of the problem that we have today. (1) gives companies more time to respond to the attacks.

There are some vendors in this space that you can and should evaluate as well.

spockz 20 minutes ago

Should we instead of these cooldowns just run builds in isolated contexts?

I’m running a maven proxy locally. All builds happen inside containers. I only use public repos for python, npm, and go. So these builds happen also in containers but don’t need a repository proxy.

insanitybit 4 minutes ago

> Should we instead of these cooldowns just run builds in isolated contexts?

I'd suggest both. Cooldown for 1-2 days is very cheap and you likely won't even notice it, so it's quite harmless and from what I've seen even just 24 hours is enough to let security companies pick up malware.

But yeah, isolation is a must-have.

pixl97 an hour ago

>install the latest version of zizmor.

What if it gets compromised?

More of a joke. But was funny after saying that new packages should be delayed.

insanitybit 44 minutes ago

lol yeah I thought of that as typing but figured I'd avoid the complexity. "latest version" means, give or take, whichever the latest one was that contained a bunch of new rules around supply chain stuff.

tmpz22 an hour ago

> anything where code executes

ALL the agentic orchestrators like codex, claude-code, etc. seem to do this by default.

gbuk2013 4 hours ago

I came across this interesting rant the other day: https://github.com/uNetworking/uWebSockets.js/blob/master/mi...

It does make sense that the right way would be to fork every dependency you use and install from your own repo reviewing and merging from upstream as needed. Would be a giant PITA though. :)

Cthulhu_ 3 hours ago

Nothing that couldn't be automated; in Go land this is (arguably) called vendoring (https://go.dev/ref/mod#vendoring). Good to offload or reduce dependencies on 3rd party dependency hosters, pull a dependency into your own code review tools, and to ensure reproducible builds long term.

Izkata 3 hours ago

It's a generic and very old term for committing dependencies to your repo, it's not go-specific.

gbuk2013 3 hours ago

I mean there’s nothing stopping you from committing node_modules to git (after running something like https://github.com/timoxley/cruft on it) and reviewing code changes on dependency updates.

I even managed to make that part of the workflow on one team I worked with but several other teams since thought it was a crazy idea. :)

Bilal_io 3 hours ago

The problem would be the dependencies of your dependencies, and keep going many levels.

nafey 2 hours ago

The problem is that node.js doesn't have a good standard library so one must rely on external packages to build even basic apps.

skydhash 2 hours ago

pipo234 3 hours ago

But presumably, you only include dependencies that you trust and those dependencies themselves do their trusting more strictly than you. Trust is built on vetting, signatures and reputation.

That is, at least what we do, in theory. In practice, we cross fingers and let the LLM pick dependencies, are satisfied if it just works and we either update our deps frequently or infrequently.

jruohonen 2 hours ago

no-name-here 2 hours ago

repelsteeltje 3 hours ago

That might change the odds, but unless you fork diligently (and monkeypatch each and every future vulnerability) you might ship a compromised fork forever.

olejorgenb 2 hours ago

Except most of the attacks so far has not landed actually source code changes to git IIRC. They have targeting the release files directly.

lights0123 2 hours ago

whynotmaybe 2 hours ago

Shouldn't you also restrict version number for a package not just the latest?

dboreham 3 hours ago

I think the general idea that your supply chain should be rooted in source repositories and associated commit hashes is the right one. Tooling can be made to automate the process of putting together a product from those defined sources. Some languages/systems already have some support for this. E.g. Golang and Rust. The concept of a "binary" artifact is really dead now everyone uses git and builds are quick. It lives on in things like npm and docker hub but we don't actually need it.

Zardoz84 an hour ago

DUB , for D Lang does that.

paulddraper 2 hours ago

The problem is the volume of dependencies. Most modern JavaScript, Python, Rust, Go, etc. projects have many dozens of transitive dependencies.

marcosdumay 2 hours ago

Hum... You should check your JavaScript numbers again.

I have never seen a project that uses npm and has only dozens of dependencies. Normal numbers are in the 10s of thousands (including different versions of some deps).

mbreese 2 hours ago

Let’s not ignore that dependencies are far more common in JS than any of those other languages. My Go or Python projects generally only include a handful of external packages. Node projects on the other hand…

paulddraper 2 hours ago

twodave 3 hours ago

For smaller shops (by small I mean <1,000 employees) this isn't even tenable. We (engineering team of about 10 people) mitigate what we can via tooling and cooldown periods/minimum release age. This will work as long as these malicious packages remain reasonably detectable. I think that's the proper balance, because we can adjust the # of days we are willing to risk against the SOTA of detection tooling.

kitd 3 hours ago

Hmm, same day as RH and IBM announce Project Lightwell to help detect and fix supply chain vulns.

https://www.redhat.com/en/lightwell

mellosouls 3 hours ago

Should link to the original announcement I think:

https://www.stepsecurity.io/blog/multiple-redhat-cloud-servi...

nailer 3 hours ago

Yes. Also Red Hat is misspelt in the title.

Sudhanshu2310 3 hours ago

We have done the complete analysis and there are 32 packages share the same publishing pipeline. https://safedep.io/redhat-cloud-services-hit-by-mini-shai-hu...

lepuski 2 hours ago

Qubes offers the strongest protection against these threats. It's surprising it isn't more commonly adopted.

exabrial 2 hours ago

NPM broken by design. And the NIH syndrom that runs rampant in the community wont let them do anything simple.

beart a few seconds ago

I don't follow your second sentence. Doesn't npm have the opposite problem of 'not invented here'? By adopting many external packages rather than developing in-house, npm projects tend to have large, complex dependency trees. It has long been the complaint that packages such as https://www.npmjs.com/package/is-windows create potential vulnerabilities and maintenance headaches, when writing the same piece of code directly is so simple.

king_zee 3 hours ago

I've made it a habit now to use the --before=2026-05-30 flag when installing packages, where it'll pick the version released before the date you specify, I usually pick around 5 days ago

t-sauer 2 hours ago

If you use npm 11, you can simplify your workflow by setting min-release-age to 5. https://docs.npmjs.com/cli/v11/using-npm/config#min-release-...

mihaelm 3 hours ago

I just use `pnpm` and set up a liberal `minimumReleaseAge`: https://pnpm.io/settings#minimumreleaseage

Thankfully, it's on by default since v11.

sync 2 hours ago

If using straight npm (v11.10.0 or higher), you can just add to .npmrc in the project root:

min-release-age=5

sourcegrift 3 hours ago

Yarn 4 can automate this

vinnymac 2 hours ago

In case others are unaware, you just have to set https://yarnpkg.com/configuration/yarnrc#npmMinimalAgeGate to the value you want. It defaults to 1 day.

majorbugger 2 hours ago

I would like to meet the person behind the "postinstall scripts" idea and try to understand how they thought it was a good idea.

MadrasTh0rn 44 minutes ago

Y'know just to talk a little bit

voidUpdate 3 hours ago

One thing I've never understood is why NPM allows packages to run code immediately after they are installed. What's the use case for that? A package should just be some code you can call on at runtime

tom1337 3 hours ago

Some packages need to build native dependencies. sharp for example needs to build libvips on the system [0] to work

0: https://github.com/lovell/sharp/blob/main/install/build.js

yread 4 minutes ago

Nuget just handles it so much better. Netvips assumes libvips is available and they provide packages for common platforms. No need to waste electricity rebuilding stuff, or install native build chains, build and test deps. Similar for Skia or Sqlite or whatever.

vinnymac 2 hours ago

I’ve always felt this automation shouldn’t exist at all, but should rather be selectively controlled via a hook. The hooks yarn offers out of the box for example can be used to run any code you need to after install. Putting the project owner in control instead of the dependency.

mark_l_watson 3 hours ago

I turn off running scripts on installation. So far, no inconveniences.

Surac 2 hours ago

Npm is just borked by design. I hop it will take javascrip with it

zeraye 42 minutes ago

There is some effort to make NPM more secure https://github.com/npm/cli/pull/9360.

rochak 3 hours ago

If this is what will take for folks to move away from JS ecosystem, I'll take it.

renox 2 hours ago

Bah, I think that these kind of vulnerabilities exist in any "packaging ecosystem" where the base language offer "ambient authorities"(any library can access your filesystem) which is .. all of them! AFAIK only research languages do not provide these ambient authorities :-(

czbond an hour ago

I am not a JS dev, but had to interact with the ecosystem some. It became so bad I won't install anything without it being in a Docker or Podman container.

jollyllama 2 hours ago

This x1000. This is the culmination of 15 years of frontend dev culture. Why does RedHat even have an NPM repo?

kogasa240p 2 hours ago

Seconded

indy 4 hours ago

This is a completely unexpected turn of events that no one could have possibly foreseen.

arianvanp 4 hours ago

Given they use nx my bet is on developer laptop compromise through the nx vscode extension that also compromised GitHub engineer's laptop

dist-epoch 3 hours ago

the security of their packages should not depend on one laptop being compromised

general_reveal 3 hours ago

That’s why I switched to Java.

Rp8yXmdmr 3 hours ago

You are absolutely right. The dangerous part of NPM packages is the post-install script. Therefore moving from JavaScript to Java removes the threat.

keyle 3 hours ago

    AbstractFinalFactoryShaiHuludSerialisedFactory

general_reveal 3 hours ago

Yeah but you don’t have to use that I think. I think us Node people can just pretend to write Ecmascript 2 in Java and be fine.

UqWBcuFx6NV4r 3 hours ago

…. lol

mschuster91 3 hours ago

Meh maven plugins are just as juicy a target as npm is

exabrial 2 hours ago

https://github.com/s4u/pgpverify-maven-plugin

If you want paranoid mode, you can verify literally every part of the maven build process.

general_reveal 3 hours ago

What do u recommend?

phishin 3 hours ago

Chainguard based images, packages and libraries are first line of defense. Expensive? Yes. Foolproof? No. I think these types services will be mandatory in the near future.

dralley 3 hours ago

How would that help? These are not general purpose, base system libraries, these are libraries specific to a product that uses them. Either you're not using them and hence they would not be installed in the first place, or you're using them because you have the product installed.

Though I would expect that Insights uses RPM packages to ship components and not the public NPM packages.

SSLy 3 hours ago

it wouldn't surprise me if insights was in fact a wrapper around npm install

czbond 2 hours ago

Podman? Podman for OSX comes with a login item from "Red Hat, Inc". Anyone know how to check if this subcomponent utilizes these npms?

wg0 2 hours ago

Question - is there no way to catch these criminals?

a13n an hour ago

It’s difficult to determine which individuals are involved and even if you manage to do that they almost certainly live in countries without extradition.

paulbjensen 3 hours ago

Looks like RedHat got compromised by a Black Hat…

ex-aws-dude 2 hours ago

Has anyone thought of having an agent review all dependency upgrades before upgrading?

I feel like that would at least catch some of these

Pxtl 2 hours ago

The combined features that make npm particularly vulnerable:

1) Update by default. Manually updating your package references is annoying and does lead to other security issues as you don't automatically get latest, but it makes this risk much lower.

2) Code executed on install. Statically-typed languages don't run the code until you use them, and that might not happen on the developer machine at all for first run after upgrade, it might be a lower-priv test-server.

3) Culture of many tiny modules (this is good! It's the natural way to fight NIH! Yay modularity!) means many more points-of-failure for security for this kind of attack.

kogasa240p 2 hours ago

Throw the JS ecosystem into the sun at this point.

grugdev42 3 hours ago

The joke is on you NPM! I only use CDNs for my JS libraries.

iconicBark 3 hours ago

Is this more secure?? I would genuinely love to know

n_e 2 hours ago

Yes (assuming they're doing frontend dev and including the resources from the page). The code is fetched and executed from the browser, so It'll have to escape the browser sandbox to do something nefarious.

bdcravens 3 hours ago

Yes, none of npm's lifecycle hooks. You're just pulling bytes over the wire.

runtime_terror 2 hours ago

lostmsu 3 hours ago

Same. I came back to do a little frontend work a couple of years ago and was horrified by the replacement of script tags with subresource integrity with npm and bundlers.

freakynit 4 hours ago

Lol.. yet again npm and install-scripts abuse at play.

Updated:

1. All exploitation techniques used since May 2025: https://npm-supply-chain-attack-techniques.pagey.site/

2. All attacks that happened since May 2025: https://npm-supply-chain-attacks-25-26.pagey.site/

replwoacause 2 hours ago

It's becoming laughable how frequently this is happening. Wow.

tetsgima 3 hours ago

man we gotta do smth with preinstall hooks atp

Escapade5160 2 hours ago

Can someone give a tldr on why this happens so much with npm ? I can't recall seeing this with any other package manager. Is npm just the default used these days and therefore sees this more often?

Noaidi an hour ago

Human society, and our technology, is a fragile system built on our hubris, a cheap replacement for the Divine Eye of Providence.

anoncow 2 hours ago

This seems to be sinister

Havoc 3 hours ago

The entire ecosystem is cursed

thewebguyd 2 hours ago

Always has been. I remember poking fun at it 15+ years ago (queue the 'MongoDB is web scale' meme video).

kittikitti 3 hours ago

I'm refactoring all my personal and research projects to utilize pure HTML/CSS without any dependency of JavaScript. This was always on the table but the cybersecurity risks from all programming languages and frameworks have increased due to AI.

I know of fundamental issues with JavaScript and see no reason why it's still standard on all web browsers.

rvz 4 hours ago

This repository itself had to previously update from the axios supply chain attack [0] (co-authored by Claude lol). But just by looking at the change itself, the package is unpinned and won't solve the problem if another malicious security update happens again.

So if you have an unpinned version of this package and you run 'npm install', you immediately downloaded the compromised version and that's that.

[0] https://github.com/RedHatInsights/javascript-clients/commit/...

shrikant 3 hours ago

Oooh now I'm wondering if this may have contributed to their Docker image distribution service getting disrupted earlier today... https://status.redhat.com/incidents/jn6r256zc62c

what_hn 4 hours ago

Same actors again?

bobkb 3 hours ago

When will npm issues stop ? This has become a big pain !

bpavuk 3 hours ago

Violence!

bel8 2 hours ago

The XML extension I use in VSCode is by Red Hat.

Oh dear. Here we go again.

m3kw9 4 hours ago

At some point, they need a new system for these "packages", you've got to be insane to install any of these right now.

hsibenMohamed 3 hours ago

Salam

jofzar 4 hours ago

'No Way to Prevent This,' Says Only package manager Where This Regularly Happens

Edit: some people don't understand that it's a defence to https://en.wikipedia.org/wiki/%27No_Way_to_Prevent_This,%27_...

Someone1234 3 hours ago

Let me provide context, since a bunch of people responding with "every package manager can be hit!!!" npm, by design, allows all packages to run package supplied arbitrary code as the logged-in user after an update completes.

That's an INSANE default. pnpm, by contrast, allows you to essentially "opt-in" only specific packages that need this (e.g. four out of thirty, in one of our projects). Then tacks on tons of other security settings, like minimum age, no trust downgrade, etc etc.

All attackers can attack packages by updating how a package functions; but npm is particularly problematic as it runs non-sandbox scripts as the calling user. Putting not just your project at risk, but your entire machine/network.

And this stuff has been known about for YEARS, they've taken no action.

bob1029 3 hours ago

Furthering the idea that not all package managers are the same, there are entire cycles of the moon where I don't open nuget once. Some ecosystems simply don't need to vendor out very often, and these are the ones where you generally find the least news like this.

In about 99% of cases, I have the option to pick between Microsoft, a 3rd party or myself. I'm picking that first option every time I can. If M$ can't handle it, I'm hand rolling it.

Dapper remains the only constant 3rd party dependency in my projects. I don't know how much longer this will last with LLM assistance. The frontier models are very good at writing repositories over arbitrary sql schemas with low level primitives now.

johannes1234321 3 hours ago

homebrewer 3 hours ago

matheusmoreira 3 hours ago

> allows all packages to run package supplied arbitrary code as the logged-in user after an update completes

As opposed to the completely untrusted package supplied arbitrary code that the logged in user executes when they actually use the package immediately after installing it?

saturn_vk 2 hours ago

lionkor an hour ago

Sankozi an hour ago

chrisweekly 3 hours ago

Yes, this.

Regarding npm CLIENTS, PNPM is fundamentally different from (and superior to) npm or yarn.

Strongest possible recommendation to use pnpm.

It's also a good idea to use a private registry (eg via jfrog), acting as a proxy / pull-through cache, and point trad SAST and maybe AI scanners at it.

But dropping the npm client in favor of pnpm is a no-brainer. Speed, disk space, security, determinism, flexibility, fine-grained control over your dependency graph...

rixed 2 hours ago

One hour ago, while looking casually at a package.json, I saw this and was horrified:

  rm -rf pkg/snippets & rmdir pkg\\snippets /s /q & wasm-pack build --target bundler && node prepare-web.js
Looked like a strange mix of unix shell and msdos batch that would, on my box, try to rmdir "/s" and "/q". I asked Claude about this, and he replied something like "Yes that's a standard and clever hack to delete a directory that works both on linux and windows!".

Poor Claude has been trained on so much awful human code that it required several prompts for it to admit that there was indeed a problem.

The industry is the process by which convenient crap like this gets standardized.

tremon 2 hours ago

lokar 2 hours ago

cozzyd 2 hours ago

PunchyHamster 2 hours ago

sigmoid10 3 hours ago

>Putting not just your project at risk, but your entire machine/network.

Between average hackers and extortion groups, foreign governments and state sponsored actors and last but not least my own government, I don't think there's much room left for non-compromised supply chains these days. Treat everything that can run foreign code as potentially compromized and keep everything compartmentalized. If you keep your crypto wallets or private banking info on the same machine where you do development, you're asking to get shafted one day. Or if you keep your big corporate github keys on the same machine where you do private weekend projects. It doesn't matter what you use in particular, even if some vectors are currently more popular than others.

renegade-otter 2 hours ago

jmull an hour ago

> That's an INSANE default.

I agree that not running arbitrary installation scripts is the right default, but it's just an incremental improvement.

The practical difference between code that runs at installation and code that runs when the package is executed is, very typically, a small amount of time.

IMO, the hyperbole here hurts because it distracts from more effective efforts.

Someone1234 an hour ago

bakkoting an hour ago

They have taken action as of very recently. The latest version [1] of npm warns when there are install scripts and tells you they will be disabled by default in a future version, with a per-dependency opt in mechanism [2].

[1] https://github.com/npm/cli/releases/tag/v11.16.0

[2] https://github.com/npm/rfcs/pull/868

hedora an hour ago

dns_snek 3 hours ago

> since a bunch of people responding with "every package manager can be hit!!!" npm, by design, allows all packages to run package supplied arbitrary code as the logged-in user after an update completes.

This is semi-common and in no way unique to NPM.

Ajedi32 3 hours ago

an0malous 3 hours ago

matheusmoreira 2 hours ago

halapro an hour ago

npm is so bad at everything it's insane.

SIXTEEN YEARS of development and they can't even resolve a tree of dependencies in the correct manner unless you nuke the lockfile and node_modules.

Dependency resolution is literally the number one task and they fail at it. How can you expect them to be good at anything else? Absolute joke.

tln an hour ago

Maybe NPM is scared to break a ton of packages? I also think action from NPM on the repo level is vital

I went through the package.json on my machine - seems like ~400 / 60000 or 0.7% have (pre|post)install. (That's not all of the scripts that run at install)

Seems to me like a backwards compatibility is a non argument since pnpm is popular enough to stand as existence proof that scripts can be, at least, opt-in

IMO - pre- and post- install scripts should just be abolished/deprecated. It should require a special dispensation from npm to even publish one. A better system for binaries (needed by esbuild) is probably needed.

Even saying "just use pnpm" isn't enough, we need to get the developer community to herd immunity and that isn't going to happen on an opt-in basis.

I would love for npm to sandbox as well. But I think the better way forward is just turn off scripts.

semiquaver 3 hours ago

> they've taken no action.

Not running lifecycle scripts by default is eventually going to be the default behavior. Late is worse (edit: I meant better) than not at all. https://github.com/npm/rfcs/pull/868

brookst 3 hours ago

Kuinox 3 hours ago

Mosts packages manager, allow that.

pnpm can still be exposed, afterall the worm simply have to wait you run tests locally.

homebrewer 3 hours ago

Someone1234 3 hours ago

pajko an hour ago

So do the pre- and post-install scripts of Debian packages. The problem is not this but the lack of verified and controlled release channel.

Romario77 2 hours ago

I think another thing that affects security is that in javascript culture people often tie to the latest version instead of concrete version.

This makes it so an update to a popular library can compromise a huge number of packages that depend on it.

In Java for example almost all packages specify a concrete version, even if someone compromises the latest the blast radius is usually pretty small.

m4rtink an hour ago

Pxtl 2 hours ago

tardedmeme 37 minutes ago

Every package manager, by design, allows arbitrary code execution after the update completes. It is the entire purpose of a package manager.

insanitybit 3 hours ago

> That's an INSANE default.

It's also the standard, and by far it's the contrast to not allow this. pnpm has a massive advantage of being the non-standard package manager, npm does not have that - what do you suggest that npm does?

btown 3 hours ago

westoque 2 hours ago

i've been thinking about this as well. but having built a startup, i've learned that users don't care as long as they are given the value and most convenience. they don't really care much at security as much as we do. just look at openclaw? but maybe it's our job to make sure it is taken care of vs assuming the user cares and just make it look seamless.

dijksterhuis 2 hours ago

tonymet 2 hours ago

So does dpkg & rpm

m4rtink an hour ago

PunchyHamster 2 hours ago

> Let me provide context, since a bunch of people responding with "every package manager can be hit!!!" npm, by design, allows all packages to run package supplied arbitrary code as the logged-in user after an update completes.

Many package formats before NPM allowed for it, and frankly, it matters little, because if it can add code to your app it can run malicious code. The fact it executes on package install rather than when dev runs tests or the app matters little, and in general if environment is sandboxes, the package install is also ran in the same sandbox so disallowing it changes little.

so yes, every package manager can be hit, the reason is twofold

* JS is such a lowest common denominator it has that much more clueless users so just by scale every issue will be more common than in other languages

* extreme fragmentation leading to hundreds of packages needed for even small projects, which is again more chances for compromise

ImPostingOnHN 3 hours ago

Nearly every package manager I've ever used had post-install scripts. Most run as root, since that's what usually what the package manager runs as.

It's not unreasonable: you're already installing software, which presents risks. If post-install scripts were not a thing, a payload could still run because you ran the software you installed. Or because the installer added it to auto-run. Or because the installer placed it somewhere where it would be dynamically loaded all the time.

bandrami 3 hours ago

jdiff 3 hours ago

skydhash 3 hours ago

TylerE 3 hours ago

chuckadams 4 hours ago

The big attacks of today are spread across several package ecosystems: TrapDoor and Shai-Hulud have been hitting npm, pypi, composer, and crates with the same malware.

throwwwll 3 hours ago

And all of them "thought" of security as an after-after-after-after-after-thought.

freakynit 3 hours ago

kalcode 3 hours ago

People make this joke often. It's package managers and how loose we are with installing them, not NPM.

Cargo,PyPi,Nuget,PHP has had these recent too.

It's not just only NPM. It's frequently repeated here just cause of the average bias against Node.

But this problem isn't isolated to NPM.

Defletter 3 hours ago

The problem is compounded with NPM though thanks to lifecycle scripts: yes, any and all package managers create a risk of supply-chain attack, but NPM makes it dangerous to merely open a project up in an IDE.

dns_snek 3 hours ago

okanat 3 hours ago

kalcode 3 hours ago

Kuinox 3 hours ago

paulddraper 2 hours ago

latexr 3 hours ago

> It's frequently repeated here just cause of the average bias against Node.

It’s frequently repeated here because NPM is where it keeps happening over and over and over and over and over and over again.

stingraycharles 3 hours ago

How many package managers allow executing arbitrary code as part of the installation process by default?

icedchai an hour ago

philipwhiuk 2 hours ago

In short, the problem is `npm` not NPM.

xena an hour ago

ajross 4 hours ago

PyPI and Cargo are, 100%, vulnerable to this same class of compromises. That NPM sucks isn't a statement that everyone else doesn't.

latexr 3 hours ago

tonymet 2 hours ago

Npm developers can relate to Windows being a target because it’s the most popular package manager.

Why would you target xyz pkg niche manager knowing that only 200 people will install them?

NPM does perform active offline & online vuln scanning on the packages. Everyone can do more, but they are going to be the #1 target.

TZubiri 3 hours ago

tbf this is happening with a lot of package managers now, including pypi and composer

nailer 3 hours ago

I've deleted and am rewriting this, to be more explicit, because HN downmodded the first comment to hell but I know I'm right and the crowd is wrong.

So, explicitly:

- pip

- Cargo

- apt/dpkg

- dnf/yum

- Homebrew

- RubyGems

- Composer (limited)

- Maven

...all allow scripts.

We understand the reference, it's just not correct: most package managers allow scripts, npm is the most successful package manager.

npm shouldn't allow scripts, but exploits happen everywhere.

m4rtink 3 hours ago

If DNF/RPM is used there will often be a separate distro maintainer that should ideally review any changes coming from the upstream before pulling them into the distribution.

Also not all maintainers always pull in the latest upstream changes, only rebasing to new stable release or when the new features or fixes are actually needed for the distro stack.

Definitely not bulletproof but still IMHO more robust than "Lets just spray latest code from upstream without any review directly to production with a firehose!" that seems to be the norm.

tetha 11 minutes ago

isityettime 2 hours ago

cozzyd 2 hours ago

krautsauer 2 hours ago

Are scripts even necessary? I don't think e.g. mvn has any form of scripts¹, but if the dependency is compromised, you're likely to execute whatever compromised code is in there the next time you do mvn verify (or whatever). Slightly less wormable maybe, running tests or at least checking whether your thing still runs after upgrading package versions is really common, no?

¹ Annotation processors are a thing and somewhat similar to rust macros in function, but you need to set those up manually for each dependency, iirc.

Zardoz84 an hour ago

bananamogul an hour ago

You didn't include Perl's CPAN, which I think is older (1995) than all of these. And it allows scripts as well.

xienze 2 hours ago

Maven does not run arbitrary scripts just by including a dependency.

matheusmoreira 2 hours ago

> HN downmodded the first comment to hell but I know I'm right and the crowd is wrong.

Got downvoted for saying it too. Don't let it discourage you.

wang_li 2 hours ago

It's not the package manager, it's the repo and the cryptographic signatures that are trusted by the package manager and the users who choose to point their pacakge managers at those repos. The fundamental problem here is that people's risk assessment is treating a user named devioustiger12345 as having the same situation and story as Microsoft/Apple/Red Hat.

matheusmoreira 4 hours ago

All programming language package managers are vulnerable. They all have the exact same caveats as the Arch Linux User Repository. There are no trusted maintainers taking responsibility for things. Any random person can make an account and push packages.

myaccountonhn 3 hours ago

It's far far harder to do something exploits like this in elm because effects are tagged. There are solutions out there.

saturn_vk 2 hours ago

IIRC, go cannot run arbitrary code at build time, so that should not make it vulnerable

matheusmoreira 2 hours ago

CBLT 3 hours ago

Eh, it's worse than that. The GP comment is repeating a joke derived from an Onion headline about gun control. Where the very poignant message is about political will to make change. However, the npm ecosystem is very much willing and has already made several changes. If we're going to engage in discussion instead of meme-posting, the GP should have (imo) included real commentary _in addition to_ the meme they really wanted to post. What is the policy they want? Why do they see the NPM ecosystem as still resistant to change?

gbear605 3 hours ago

jauntywundrkind 3 hours ago

throwwwll 3 hours ago

Nix enters the room.

(Everyone claps.)

ajross 3 hours ago

While true, tarring Arch here is a little unfair. AUR isn't enabled by default. It can't even be used via the same package front end, and in fact the "official" usage model requires that you clone the source yourself.

Indeed, AUR is bad as a software distribution mechanism (really it's best understood as a proving ground for baby packages before they get real maintainers and distro blessing), but it's less bad than NPM which puts the malware in the trusted/default/automated path.

matheusmoreira 3 hours ago

Ancapistani 3 hours ago

the__alchemist 4 hours ago

I think this is a thought-terminating cliche, and false equivalences. Stating "This area where problems occur at a high rate is not a problem, as problems can happen elsewhere too" is a curt dismissal of a valid concern. It implies the course of action, rather than to address a high-problem area, is to ignore any solutions which aren't global, or equate it to lower-incidence areas.

You bring up a good point that this class of problem, or related ones can occur with other package managers. It was frustrating how long it took the Crates.io team (Rust manager) to address name squatting, in what appeared to be a "no perfect solution exists, so we won't act" line of reasoning.

matheusmoreira 3 hours ago

kalcode 3 hours ago

junon 3 hours ago

Please stop posting this on every single security incident thread with npm. It was funny once, it's just rehashing the same debate over and over.

da_chicken 3 hours ago

On the other hand, if the same problem keeps happening, it's hard to argue that the problem isn't foundational to the design and that it should be called out until either the problem is fixed or the design abandoned.

chipdale 3 hours ago

Why should they stop? Maybe they want to rehash the issue that's not being adequately addressed. Maybe it's not supposed to be funny.

How do you propose we address this issue? Instead of policing what people say, are you interested in sharing your or someone else ideas?

junon 3 hours ago

rectang 3 hours ago

Opponents of gun control surely feel the same way about the Onion’s story.

dist-epoch 3 hours ago

if RedHat is unable to secure their packages, what can we expect from mere mortals...

cozzyd 2 hours ago

this looks like another GitHub Actions workflow compromise...

Is it really so hard for people to make releases manually?

buckle8017 4 hours ago

Redhat's entire reason for existence is to prevent this.

cozzyd 3 hours ago

did RPM packages get compromised?

dada216 3 hours ago

not really, no.

rob_c 3 hours ago

So why else do we pay someone to package and certify/verify open source projects? This is absolutely 90++% of what should be RedHats core day job.

duozerk 2 hours ago

MadrasTh0rn 3 hours ago

Fucking Microsoft

_pdp_ 2 hours ago

Why blame on NPM? Would you blame GitLab if an opensource maintainer was hacked and as a result the repo contains malicious changes?

All of these recent incidents is just developers doing stupid things ... like using their compromised devices for making production changes, which is basically a big red flag to begin with.

In fact, the entire situation has been exacerbated by coding agents because now practically everything happens on a single device that touches hundreds of different production systems with full production credentials.

gred 2 hours ago

Days since last malicious packages in NPM: 0 (evergreen)

Days since last malicious packages in PyPI: 30

Days since last malicious packages in Maven: 120

I'm sure this isn't 100% accurate, and there are probably better metrics (average number of malicious packages per year, average number of developers affected per year, etc) but they aren't as easy as a quick Google News search.

_pdp_ 2 hours ago

Except that the JavaScript / NPM ecosystem is 6-7 times larger than Python and Java / Maven.

https://chatgpt.com/share/6a1da751-0d88-832e-ace7-572bc786e0...

Check the linked resource which has the actual data.

gred an hour ago

calvinmorrison an hour ago

no because I dont ship production software from gitlab, I use upstream maintained packages?