r/programming • • Sep 29 '26

nine npm packages shipping worm that spread by itself over SSH

https://safedep.io/dirtyblanket-express-impersonation-npm/
453 Upvotes

47 comments sorted by

312

u/New_Hold8135 Sep 29 '26

It's not all npm but it is always npm.

77

u/vips7L Sep 29 '26

And it’s always an install hook. 

26

u/YeOldeMemeShoppe Sep 30 '26

This is the actual problem. Having code run on download of a package that you aren’t even depending on is insane. I’m surprised it endured so much, considering I was already hearing about supply chain attacks a decade ago.

13

u/syklemil Sep 30 '26

It's not that unheard of to have some build step, but it really should be disabled by default, without access to the network by default, and generally sandboxed by default.

6

u/Primary_Ads Oct 01 '26

in general dependencies would benefit from more sandboxing. should a json parser need network or filesystem access?

27

u/Vakz Sep 29 '26

Don't know if something in npm's design makes it inherently more vulnerable, or if it's targeted more because it's so popular among new people.

This also seems to be a case of typo squatting rather than hijacking existing packages, which is a difficult thing to fight in other ways than scanning all uploaded packages or manually approving uploaders, which I doubt would be popular with the community either.

And of course, defaulting to running install hooks without approving is idiocy. We moved all repos to pnpm for that reason. They seem to have at least somewhat more secure defaults.

28

u/One_Ninja_8512 Sep 29 '26

It's just the scale. A frontend project can have like up to 1 GB worth of dependencies and the final build will be about a couple of MB gzipped. It's just a weird ecosystem where each package has dozens of dependencies.

17

u/Vakz Sep 29 '26

That's not really unique to npm though. Python, Rust and to a certain degree Java have the same insane depth of dependency hierarchies, but some reason they don't seem to be targeted nearly as much as npm.

8

u/ThiefMaster Sep 29 '26

Absolutely not the case for Python. 70 lines requirements.in (direct deps) --> 132 non-commented lines in requirements.txt (from uv-pip-compiled). So on average each package comes with 1 extra dependency

26

u/One_Ninja_8512 Sep 29 '26

No, it is really unique and your comparison is way off. I just created a venv and added Django as a dependency – three dependencies installed total, a little more than 20 MB on disk. Then I created a new Angular project with their CLI tool which pulled almost 200 packages at over 230 MB, this is a plain project with boilerplate only. How are they even comparable?

10

u/CloudsOfMagellan Sep 30 '26

Angular is shipping a whole ass compiler though, you'd be better off comparing against something like express or nestjs, which are both still massively bloated but are more comparable.

1

u/One_Ninja_8512 Sep 30 '26

Right, the comparison might not be entirely accurate and I'll admit I've never worked with Django so there's a good chance I missed something. But the point is, why 200 packages? Nobody can simply create a self-reliant package with no dependencies? It's just that you have to put a lot more trust in the whole chain of dependencies if doing serious frontend work, which doesn't have to be the case, really.

0

u/[deleted] Sep 30 '26 edited Sep 30 '26

[removed] — view removed comment

1

u/One_Ninja_8512 Sep 30 '26

But the point is, even if it ships with a compiler why so many dependencies? No other ecosystem is like that

6

u/wonkytalky Sep 30 '26

I've had to build a few windows-centric applications recently and absolutely could not believe the sheer size of all the dependencies. This was after all the standard Windows frameworks were already installed.

6

u/bwainfweeze Sep 30 '26

Having observed the npm commit history I get the impression that npm wasn’t designed until around 8.0 when substantial architectural changes started to show up. Prior to that lock files didn’t function at all, despite three attempts to make them work.

But it is an ecosystem that was born on open source so it uses a lot of third party code. Many small libraries, and many large libraries with lots of dependencies of which you only use 20%.

6

u/Atulin Sep 30 '26
> npm i is-even
Installing 36 packages...
Detected 82 vulnerabilities, run npm audit fix to fix them
> npm audit fix
> Detected 184 vulnerabilities, run npm audit fix to fix them

125

u/tanksc Sep 29 '26

I feel like we are going to look back at this and wonder what the hell we were ever thinking with these supply chain attack vectors

89

u/NotQuiteDeadZed Sep 29 '26

It’s the universal answer that applies to everything around us. I mean just look at people’s attitudes towards anything tech.

Privacy and security will always be sacrificed at the altar of convenience

20 years ago it was ignorance, now it’s laziness and indifference.

23

u/PaperMartin Sep 29 '26

This doesn't happen when privacy and security is implemented in a way that doesn't require a massive loss of convenience though. At some point peoples still have to be able to do what they need with their devices without everything taking a year & some arcane rituals to do

9

u/tanksc Sep 29 '26

I hear ya, but at the same time when I took cybersecurity courses at uni almost a decade ago, it was preached as a fact that as convenience increases, privacy and security decrease (was on my first test)

To be fair, the professor also asked why I would use more privacy respecting options in terms of software if I didn’t have anything to hide.

But I think that’s why this opinion is so wide spread

3

u/One_Ninja_8512 Sep 29 '26

why I would use more privacy respecting options in terms of software if I didn’t have anything to hide

I wonder how this argument unfolds if I do say that I have something to hide? Yeah I do, what's the problem with that?

4

u/tanksc Sep 29 '26

Had I not been young and naive I would have given this a shot lol. As a 19 year old, an ex police chief teaching cybersecurity 101 scared the shit out of me lol

8

u/NotQuiteDeadZed Sep 29 '26

True, but that requires developers putting in the effort to break the cycle and consumers being willing to make small sacrifices in their expectations. People are willing to sacrifice way too much just for the slightest added convenience.

9

u/winky9827 Sep 29 '26

Speaking of attitudes toward tech, I'm seeing an alarming rise in the growing number of open source projects with install instructions that read a script from a web site and pipe it to the shell. People really just have no security sense at all.

6

u/Nona_Suomi Sep 30 '26

Meh, besides some convenience this really isn't that much different from downloading a tarball, extracting it, and running `./configure && make && sudo make install`.

4

u/winky9827 Sep 30 '26

I agree, which is why I hate that they are conditioning people to use one-liners to execute shell scripts from the internet. That's a major attack vector being used carelessly.

2

u/rentar42 Sep 30 '26

curl | sh is the "harmless" option by now. I've seen "paste these paragraphs into your favorite AI tool to install". More than once ...

4

u/winky9827 Sep 30 '26

I agree, those are even worse. At least the shell script is deterministic.

14

u/Dreadgoat Sep 29 '26

Oldheads warned about npm (and other convenience-first package management systems) from the beginning. It's always been known to be a terrible idea, but that loses to the fact that the convenience is just SO convenient.

It's not a specific-to-software issue, though. There just hasn't yet been a cataclysmic enough event for standards to be put in place. Humans always cut corners until it causes enough damage, then re-establish the new corners.

-1

u/tanksc Sep 29 '26

its giving pre 9/11 flight experience for sure

3

u/Hipolipolopigus Sep 30 '26

Everyone rolling their own things to some degree with the same carelessness wouldn't result in an improvement. You'd just hear about exploits less while they take longer to get addressed (if they get addressed at all).

3

u/Mellowindiffere Sep 30 '26 edited Sep 30 '26

Because modern software «engineers» are glorified UI designers with some coding skills. The shit they forgo teaching in universities baffles me and we’re still feeling the effects of the bootcamp coders and leetcoders. Turns out it really is important to have fundamental knowledge.

1

u/Sherbet-Famous Sep 30 '26

Not my company, not my problem 🤷‍♀️

39

u/6769626a6f62 Sep 29 '26

Days since last npm exploit: 0 0

19

u/UnexpectedAnanas Sep 29 '26

Days since last npm exploit: 0 NaN

48

u/rcklmbr Sep 29 '26

Interesting topic, couldn’t read it because of AI Slop

0

u/[deleted] Sep 29 '26

[deleted] — view deleted comment

0

u/[deleted] Sep 29 '26

[deleted] — view deleted comment

0

u/[deleted] Sep 29 '26

[deleted] — view deleted comment

15

u/vips7L Sep 29 '26

You’ll understand more if you just read the thing instead of summarizing it

9

u/Nice_Mix_1021 Sep 29 '26

crazy on the part that it pretending to be express js

6

u/trxxruraxvr Sep 29 '26

Meanwhile safedep.io is blocked by dns4eu

We have prevented you from accessing potentially malicious website.

2

u/encidius Sep 29 '26

It's a false positive. SafeDep.io is a legitimate infosec website.

0

u/[deleted] Sep 29 '26

[deleted] — view deleted comment

5

u/N_T_F_D Sep 29 '26

If you can't be bothered to type your own answers just don't do it, nobody wants to read paragraphs upon paragraphs of textual diarrhea

3

u/starball-tgz Sep 30 '26 edited Sep 30 '26

so... give your ssh keys passwords? and don't let your package manager install stuff on hooks / manually allowlist? (which is what pnpm does, IIRC) not that that magically solves everything, but... it seems like it would prevent this.

1

u/Primary_Ads Oct 01 '26

were any other packages affected?