Live data from Hacker News

Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

socket.dev

541–550 of 1001 posts

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#541
post #405

As a user of npm-hosted packages in my own projects, I'm not really sure what to do to protect myself. It's not feasible for me to audit every single one of my dependencies, and every one of my dependencies' dependencies, and so on. Even if I had the time to do that, I'm not a typescript/javascript expert, and I'm certain there are a lot of obfuscated things that an attacker could do that I wouldn't realize was embed…

Install less dependencies, code more.

Copy-paste more.

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#542

Earlier quoted context omitted.

That's very naive. We can do better than this.

Almost all software has a no warranty clause. I am not a lawyer but in pretty plain English every piece of software I have ever used has said exactly that I can fuck off if I expect it to work or do anything. To clarify - I dont think it is naive to assume the software is as-is with all responsibilities on the user since that is exactly what lawyers have made all software companies say that for over 50 years.

I'm not sure what your point is. I was saying it's naive to think that everyone is going to review all dependencies, and we can do better than requiring them to.

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#543

Earlier quoted context omitted.

pnpm just added this: https://pnpm.io/blog/releases/10.16

This sounds nice in theory, but does it really solve the issue? I think that if no one's installing that package then no one is noticing the malware and no one is reporting that package either. It merely slightly improves the chances that author would notice a version they didn't release, but this doesn't work if author is not particularly actively working the compromised project.

These days compromised packages are often detected automatically by software that scans all packages uploaded to npm like https://socket.dev or https://snyk.io. So I imagine it's still useful to have those services scan these packages first, before they go out to the masses.

Measures like this also aren't meant to be "final solutions" either, but stop-gaps. Slowing the spread can still be helpful when a large scale attack like this does occur. But I'm also not entirely sure how much that weighs against potentially slowing the discovery as well.

Ultimately this is still a repository problem and not a package manager one. These are merely band-aids. The responsibility lies with npm (the repository) to implement proper solutions here.

> The responsibility lies with

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#544
post #487

Earlier quoted context omitted.

A brief but important point is that this primarily holds true in the context of rewriting/vendoring utilities yourself, not when discussing importing small vs. large dependencies. Just because dependencies do a lot more than you need, doesn't mean you should automatically reach for the smallest dependency that fits your needs. If you need 5 of the dozens of Lodash functions, for instance, it might be best to just ins…

Yes, fewer, larger, trustworthy dependencies with tree shaking is the way to go if you ask me.

Almost like a standard library..

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#545
post #487

Earlier quoted context omitted.

Most dependencies do much more than we need from them. Often it means we only need one or a few functions from them. This means one doesn't need to rewrite whole dependencies usually. Don't use dependencies for things you can trivially write yourself, and use them for cases where it would be too much work to write yourself.

A brief but important point is that this primarily holds true in the context of rewriting/vendoring utilities yourself, not when discussing importing small vs. large dependencies. Just because dependencies do a lot more than you need, doesn't mean you should automatically reach for the smallest dependency that fits your needs. If you need 5 of the dozens of Lodash functions, for instance, it might be best to just ins…

I think the level of protection you get from that depends on how the unused code detection interacts with whatever tricks someone is using for malicious code.

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#546
post #489
post #405

As a user of npm-hosted packages in my own projects, I'm not really sure what to do to protect myself. It's not feasible for me to audit every single one of my dependencies, and every one of my dependencies' dependencies, and so on. Even if I had the time to do that, I'm not a typescript/javascript expert, and I'm certain there are a lot of obfuscated things that an attacker could do that I wouldn't realize was embed…

Personally, I go further than this and just never update dependencies unless the dependency has a bug that affects my usage of it. Vulnerabilities are included. It is insane to me how many developers update dependencies in a project regularly. You should almost never be updating dependencies, when you do it should be because it fixes a bug (including a security issue) that you have in your project, or a new feature t…

Fully disagree. The problem is that when you do need to upgrade, either for a bug fix, security fix, or new feature that you need/want, it's a lot easier to upgrade if your last upgrade was 3 months ago than if it was 3 years ago.

This has bitten me so many times (usually at large orgs where policy is to be conservative about upgrades) that I can't even consider not upgrading all my dependencies at least once a quarter.

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#547

I'm coming to the unfortunate realizattion that supply chain attacks like this are simply baked into the modern JavaScript ecosystem. Vendoring can mitigate your immediate exposure, but does not solve this problem. These attacks may just be the final push I needed to take server rendering (without js) more seriously. The HTMX folks convinced me that I can get REALLY far without any JavaScript, and my apps will probab…

> These attacks may just be the final push I needed to take server rendering (without js) more seriously

Have fun, seems like a misguided reason to do that though.

A. A package hosted somewhere using a language was compromised!

B. I am not going to program in the language anymore!

I don't see how B follows A.

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#548
For a large subset of packages (like the browser ones), as a layman, it seems feasible to do static analysis for:

1) fetch calls

2) obfuscation (like sketchy lookup tables and hex string construction)

Like for (1) the hostname should be statically resolvable and immutable. So you can list the hostnames it fetches from as well.

Is this feasible or am I underestimating the difficulty? Javascript seems to have no shortage of static analysis tools.

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#549
post #408
post #331

Earlier quoted context omitted.

Because then it's extra hassle and expense for new developers to publish a package, and we're trying to keep things decentralized.

Decentralized? This is a centralized package registry. There is nothing decentralized about it.

oh right, good point, I wonder when somebody will just sue NPM for any damage caused. That's really the only way we'll see change I think.

Re: Shai-Hulud malware attack: Tinycolor and over 40 NPM packages compromised

#550
post #486
post #405

As a user of npm-hosted packages in my own projects, I'm not really sure what to do to protect myself. It's not feasible for me to audit every single one of my dependencies, and every one of my dependencies' dependencies, and so on. Even if I had the time to do that, I'm not a typescript/javascript expert, and I'm certain there are a lot of obfuscated things that an attacker could do that I wouldn't realize was embed…

pnpm just added minimum age for dependencies https://pnpm.io/blog/releases/10.16#new-setting-for-delayed-...

Oh brilliant. I've been meaning to start migrating my use to pnpm; this is the push I needed.
Post reply on HN