Malicious javascript compromise on npmjs.com

These packages, about a billion downloads prior

supports-hyperlinks
chalk-template
simple-swizzle
slice-ansi
error-ex
is-arrayish
wrap-ansi
backslash
color-string
color-convert
color
color-name

Thread follows.

in reply to Kevin Beaumont

Weekly download stats for impacted packages prior to incident

ansi-styles (371.41m)
debug (357.6m)
backslash (0.26m)
chalk-template (3.9m)
supports-hyperlinks (19.2m)
has-ansi (12.1m)
simple-swizzle (26.26m)
color-string (27.48m)
error-ex (47.17m)
color-name (191.71m)
is-arrayish (73.8m)
slice-ansi (59.8m)
color-convert (193.5m)
wrap-ansi (197.99m)
ansi-regex (243.64m)
supports-color (287.1m)
strip-ansi (261.17m)
chalk (299.99m)

Total 2674m

Stefano Marinelli reshared this.

in reply to Leo@ALLES

@leoluk Draconian systems that limit who can write and publish code are NOT the solution here.

The solution is not having LPMs (language package managers) that pull code from unvetted package repositories in an automated manner, and languages that encourage using thousands of random garbage microdependencies rather than well-vetted, versioned libraries.

in reply to Cassandrich

@leoluk We should not be placing the burden of "users don't get hit with malware" on maintainers locking down their workflows in ways that might be exclusionary or inaccessible.

Instead, the platforms that want to deliver unvetted code as part of a "supply chain" 🤮 need to get their act together and find a way that newly-published unvetted code doesn't end up as part of anyone's build, but instead goes through multiple layers of delay where it's only available to people who intend to be testing an unvetted bleeding edge and understand the dangers. With channels to request rapid review of tiny security-critical changes when needed for expediting them.

in reply to Cassandrich

@leoluk For the most part, none of these packages have any need for new versions to appear in anyone's builds for *months* if not years after publication, unless someone *specifically* has read the changes to the new version and sees a new feature they want from it.

LPM platforms should be designed around this basic principle that updates are mostly unwanted.

The only way anyone should ever get unexpected updates is if there's a serious security problem, in which case there should be a description of the problem and a small comprehensible patch prominently displayed.

IOW LPMs and similar platforms should behave like Debian Stable.

This entry was edited (2 months ago)
in reply to Kevin Beaumont

Do you have a list of the compromised versions?

A few of these, when I check I see that the version published this morning is still present and the latest version. But a quick glance at the code and I don't see the compromise; I'm just doing a quick scan, but some of these packages are so simple that there's really not many places you could hide it:

npmjs.com/package/has-ansi?act…

I'm just trying to compile a list of compromised versions so I can do a quick scan of our systems, but for some of these I haven't been able to find an exploited version.

Maybe the attackers script failed to insert the exploit, as we do see a number of these packages all updated at the same time, but I don't see the exploit code in them. Packages fitting that pattern:

* color
* supports-color
* strip-ansi
* ansi-regex
* has-ansi

(note: all of this is based on a quick glance using the code tab on the NPM registry; it's possible that I could have missed the right file, or missed it when scanning visually, or the code tab might not be showing the version it claims, or the like)

in reply to Brian Campbell

Here's my best attempt at a list of the bad versions:

- supports-hyperlinks 4.1.1
- chalk-template 1.1.1
- simple-swizzle 0.2.3 xxx
- slice-ansi 7.1.1
- error-ex 1.3.3
- is-arrayish 0.3.3
- wrap-ansi 9.0.1
- backslash 0.2.1
- color-string 2.1.1
- color-convert 3.1.1
- color 5.0.1 (???)
- color-name 2.0.1
- ansi-styles 6.2.2
- debug 4.4.2
- chalk 5.6.2 (???)
- supports-color 10.2.2 (???)
- strip-ansi 7.1.2 (???)
- ansi-regex 6.2.2 (???)
- has-ansi 6.0.2 (???)

"xxx" means that the bad version is still the latest version on NPM.

"???" means that a version was uploaded at the time of the attack, but I didn't see the exploit code in a quick visual scan of the code.

Some of this is guesswork because the bad versions have already been deleted.

in reply to Kevin Beaumont

the typical “I want the benefit but I don’t want to deal with the risk” issue. I’m telling the software companies when I give security training for their developers that they need to maintain their own repo with an allowlist of packages and versions and that they have to be rigid in keeping it small and properly governed.
One would think that rimrafall and others should have done the job to raise awareness 😩
Unknown parent

mastodon - Link to source

rx13

The worst part is like half the libraries that get phished these days are just the absolute laziest shit. It's an import to tell you if a string is a URL or if a string is a boolean-like value, which sure it's annoying to have to deal with these little edge cases, but these aren't problems you need to outsource maintenance of (When you run a million/billion dollar platform)
Unknown parent

mastodon - Link to source

Stefan Gast

This feels obvious, yet it seems that in light of the current events a little reminder is needed:
In programming, you need some good understanding on what you are doing.
Brute-force prompting an AI until it spits out something that appears to be working does not qualify for this.
Building some Frankenstein's application from hundreds of unchecked, mostly trivial third-party libraries does not qualify, either.
This entry was edited (2 months ago)
in reply to Kevin Beaumont

OK...so I just had a wallet drained. I'm still trying to figure out how it happened. It only got one of my wallets...so I don't know what's up with that. I'm very literate on cyber security, and I'm certain I didn't click on a suspicious email link. What is this code doing to drain the wallets, running an exploit? That would be strange...it was an android-based wallet (unstoppable).
Unknown parent

mastodon - Link to source

Phil Burg (he/him)

Help a dumb security guy out? I haven't been a developer since the 90s and I'm out of touch.

Has-ansi was downloaded 12 million times this week - does that mean 12 million applications currently under development added it to their codebase this week?

Or applications using it were deployed to 12 million endpoints this week?

Or 12 million web sessions pulled this JavaScript code this week?

Or....something else entirely?

I've tried to find an answer to this via Google but no joy.

in reply to Phil Burg (he/him)

@Standard_Phil Every time npm fetches the source code counts as a download. This usually happens when running “npm install” on a system that doesn’t have the source cached. A lot of those downloads are caused by CI/CD builds because they usually fetch the source for every dependency into a clean environment for running tests, packaging builds, etc.
Unknown parent

mastodon - Link to source

Emory

in case anyone is interested in this sort of thing i've been hacking together some patterns and helpers for Fabric AI that you can use to parse `git log`s to spot tagged releases without a corresponding commit. i would accept and consider any feedback if anyone tries it out and has suggestions.

github.com/org-axiopisty/overn…