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.
mia likes this.
reshared this
Kevin Beaumont
in reply to Kevin Beaumont • • •reshared this
Jayne 🇪🇺🏳️🌈 and AI6YR Ben reshared this.
Kevin Beaumont
in reply to Kevin Beaumont • • •Malicious JS in NPM libraries - Pastebin.com
PastebinKevin Beaumont
in reply to Kevin Beaumont • • •Kevin Beaumont
in reply to Kevin Beaumont • • •derekheld (@derekheld@infosec.exchange)
Infosec Exchangereshared this
Gerrit 🇪🇺🌍🍉🔻, Solarbird and jdm2 🇵🇷 reshared this.
Kevin Beaumont
in reply to Kevin Beaumont • • •reshared this
Lazarou Monkey Terror 🚀💙🌈, Hylke Bons 🥜, skry and Roni Rolle Laukkarinen reshared this.
Davey
in reply to Kevin Beaumont • • •Colin
in reply to Kevin Beaumont • • •Darby M. Dixon III
in reply to Kevin Beaumont • • •Kevin Beaumont
in reply to Kevin Beaumont • • •Roni Rolle Laukkarinen reshared this.
Kevin Beaumont
in reply to Kevin Beaumont • • •If you want an idea of scale of trojan attempt - 'color' alone had 32m downloads in a week, the combined attempt was pushing a billion due to upstream dependencies.
Hunt tip: look for registry.npmjs.org in proxy logs, package names are in the URLs.
reshared this
Lazarou Monkey Terror 🚀💙🌈, n1k0 and Bah humBiggles reshared this.
Adrian Sanabria
in reply to Kevin Beaumont • • •Martin Seeger
in reply to Kevin Beaumont • • •We could see that coming for a long time 😢. In a text I published in German magazine last year I even predicted that color packages would be used.
But what good did it do us to foresee it? Rather little or next to none…
Kevin Beaumont
in reply to Kevin Beaumont • • •additional backdoored packages
ansi-styles
debug
chalk
supports-color
strip-ansi
ansi-regex
has-ansi
reshared this
Parade du Grotesque 💀 and skry reshared this.
Kevin Beaumont
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.
Kevin Beaumont
in reply to Kevin Beaumont • • •reshared this
Michael Kohlman, Ayo, Federico Mena Quintero, Fullmetal Alejandro, skry, Abie, Ω 🌍 Gus Posey, craignicol, Ben Ramsey, Tofu Musubi and Billy Smith reshared this.
David Penfold
in reply to Kevin Beaumont • • •Ooh, please change your retina every three months...
It's a pretty neat ploy though.
Leo@ALLES
in reply to Kevin Beaumont • • •Cassandrich
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.
Leo@ALLES
in reply to Cassandrich • • •Cassandrich
in reply to Leo@ALLES • • •Cassandrich
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.
Cassandrich
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.
VessOnSecurity
in reply to Kevin Beaumont • • •But, but, but... They said 2FA prevented phishing!
When is 2FA not 2FA? When it is 2SV.
Neil
in reply to Kevin Beaumont • • •Edwin Martin
in reply to Kevin Beaumont • • •Simon Lucy
in reply to Kevin Beaumont • • •Brian Campbell
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)
has-ansi
npmBrian Campbell
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.
Brian Campbell
in reply to Brian Campbell • • •Also, holy hell the left-pad nature of some of these deps. Here's the entire source of has-ansi:
import ansiRegex from 'ansi-regex';
const regex = ansiRegex({onlyFirst: true});
export default function hasAnsi(string) {
return regex.test(string);
}
varx/tech
in reply to Kevin Beaumont • • •...phew, nothing dangerous then.
(Yeah yeah, I know they could swap it out for something worse.)
Matthew Booth
in reply to Kevin Beaumont • • •Davey
in reply to Matthew Booth • • •Affected websites would largely run fine but if they were handling crypto transactions, the request is altered to the benefit of the attackers, sending funds to their wallet instead.
JavaScript let's you redefine standard features, and the malicious script redefines fetch, which is the standard function for calling URLs
Adrian Sanabria
in reply to Kevin Beaumont • • •wow, Pastebin just tried to give me malware while trying to view malware on Pastebin
how appropo
Steve Loughran
in reply to Kevin Beaumont • • •the vessel of morganna
in reply to Steve Loughran • • •Eckes
in reply to Kevin Beaumont • • •Jules 🍺 reshared this.
haagen
in reply to Kevin Beaumont • • •Hannu Klemetti
in reply to Kevin Beaumont • • •Seems like they are fixing the problem by removing affected versions. At least is-arrayish shows now older version as latest when it was 0.3.3 moments ago.
Too bad that there is no trace in npm repo this happened, but I guess that's the only suitable option.
Aleksi Manninen
in reply to Kevin Beaumont • • •Tom Walker
in reply to Kevin Beaumont • • •reshared this
Adam Shostack, Cat 🐈🥗 (D.Burch), Neil Brown, Recovered Expert and M. Grégoire reshared this.
Rachel Rawlings
in reply to Tom Walker • • •sbszine
in reply to Tom Walker • • •fuzzyfuzzyfungus
in reply to Tom Walker • • •anmey
in reply to Tom Walker • • •@GossiTheDog
Kzad_Bhat
in reply to Kevin Beaumont • • •Sensitive content
yetzt
in reply to Kevin Beaumont • • •looks like npmjs.com/~qix
so lucky they didn't compromise
debugnpm | Profile
www.npmjs.com�
in reply to Kevin Beaumont • • •Jacob Alexander Tice
Unknown parent • • •The Penguin of Evil
Unknown parent • • •Amgine
Unknown parent • • •There are bike sheds in Skegness?
Painted what colour?
Alex
Unknown parent • • •esa
Unknown parent • • •kit
in reply to Amgine • • •greem (Graeme, not Graham)
Unknown parent • • •tautology
Unknown parent • • •the trend in npm to use trivial libraries, i.e.ones you can replace in one expression, really doesn't help.
When we do training on this I point the finger at is-even which is dependent on is-odd and is-number and can be replaced by (x % 2) == 0
Joe Mansfield reshared this.
codehorse
in reply to Kevin Beaumont • • •One would think that rimrafall and others should have done the job to raise awareness 😩
rx13
Unknown parent • • •Ray—Golden Retriever Whisperer—🔝Insights
Unknown parent • • •Ray—Golden Retriever Whisperer—🔝Insights
Unknown parent • • •Stefan Gast
Unknown parent • • •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.
DemocritusCaveman
in reply to Kevin Beaumont • • •Hey Gus
Unknown parent • • •it didn’t even occur to me how much more impactful some of the npm notifications for malicious packages could be.
> shouting “online store” into the computer
Easily one of the best vibe coding snipes in a while lol
Cadmus 🌲
Unknown parent • • •:hacker_p: :hacker_f: :hacker_t:
in reply to Kevin Beaumont • • •DemocritusCaveman
in reply to Kevin Beaumont • • •Doug Wade
Unknown parent • • •Rupert V/
Unknown parent • • •Dependency
xkcdPick Nick 🇨🇦 reshared this.
vlkr
in reply to Kevin Beaumont • • •Toni Aittoniemi
in reply to Kevin Beaumont • • •jz.tusk
Unknown parent • • •Wait, are you saying that they used a link in an email to go to reset a password?????
Because we taught my dad in his 80s to not click on links in emails.
Tomasz Tarczyński
Unknown parent • • •Scott Jackson
in reply to Kevin Beaumont • • •Kat Marchán 🐈
Unknown parent • • •grmbl
in reply to Kevin Beaumont • • •Erlend Oftedal
Unknown parent • • •Just One Package More
suno.comSludge
Unknown parent • • •SpaceLifeForm
in reply to Kevin Beaumont • • •Know we know npm is hosted in Nebraska.
xkcd.com/2347/
Dependency
xkcdPhil Burg (he/him)
Unknown parent • • •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.
Joxean Koret (@matalaz)
Unknown parent • • •Demiurg
in reply to Phil Burg (he/him) • • •Evan Prodromou
in reply to Kevin Beaumont • • •Michael Eggers 🇺🇦🇪🇺
in reply to Kevin Beaumont • • •Onno (VK6FLAB)
in reply to Kevin Beaumont • • •Ben Ramsey
in reply to Phil Burg (he/him) • • •Phil Burg (he/him)
in reply to Ben Ramsey • • •Thanks Ben, makes sense.
Phil Burg (he/him)
in reply to Demiurg • • •Bernard Sheppard
in reply to Rupert V/ • • •@rupert
I don't even have to click through to know which one you have linked to. Thank you for your service.
@GossiTheDog
Aaron
in reply to Phil Burg (he/him) • • •Here's the fun part:
The way npm works, I'm fairly sure it's impossible to know the answer to your question.
@GossiTheDog
RiskyThinking
Unknown parent • • •lisawilliams
in reply to Kevin Beaumont • • •Pick Nick 🇨🇦
in reply to Rupert V/ • • •@rupert
My first thought.
Well, second actually.
The first was I told you so.
#GitStuffed
@GossiTheDog
Hippo 🍉
Unknown parent • • •shucks, I have the following libraries in #Convo 😳
- color-convert
- color-names
- ansi-styles
- debug
- chalk
- supports-color
People, be careful when trying to do any #cryptocurrency transactions using an #XMPP messaging app on #KaiOS 🤑
Pontificator.OMF
Unknown parent • • •Tane Piper ⁂
Unknown parent • • •I finally got around to writing about the entire mess (not just the latest incident)
tane.codes/@tanepiper/11517389…
Tane Piper ⁂ (@tanepiper@tane.codes)
Tane's Fedeverserx13
Unknown parent • • •@cczona
Yes, but it's an rfc, which means churn on that standard is low. Is it such an endeavor to maintain that you need someone looking after it? Idk
For sure some of these seem a bit silly to me. Boolean thing being one of the worst
rx13
Unknown parent • • •@cczona
URL parsers aren't valid TLD-aware (if implementing the RFC)
Adrian Sanabria
Unknown parent • • •I understand the concept, I’m just saying I can’t recall many cases where the attacker is as bold as just
cat malware.js >> main.js
Kimberly
Unknown parent • • •Sturmflut
in reply to Kevin Beaumont • • •Andrew Jorgensen
Unknown parent • • •Bruno Girin
Unknown parent • • •They've got big sheds in Skegness.
Peter Goulborn
Unknown parent • • •Emory
Unknown parent • • •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…
GitHub - org-axiopisty/overnight-manager: a toolkit intended to be used to identify potentially tainted package releases
GitHubCalisti 🏳️🌈🦇
Unknown parent • • •Stumpy The Mutt
Unknown parent • • •Kevin Granade
in reply to kit • • •Build a bike shed, the more terrible the better.
Invite some neighbors over to see it, start an argument about what color it should be.
Duck out of the argument and hide for a week.
Come back and hollow out the square acre of paint your neighbors put in the bikeshed, creating a mansion.