9 ms·
Malware found on NPM infecting local package with reverse shell
- JTbane 2y agoBack in the day repositories had 'maintainers' who reviewed packages before they became included. I guess no one really cares in the web dev world; it's a free-for-all.
- giantg2 2y agoWeb dev has always been a hot mess.
- CamJN 2y agoIt’s not just web dev: go, rust, swift, ruby, python none of them do any checking. In fact the only repo I know of doing any checking is Java’s Maven/Sonotype and it’s automated not manual.
- debugnik 2y agoOCaml's opam does have a review process, although I'm not sure how exhaustive. It's got a proper maintenance team checking for package compatibility, updating manifests and removing problematic versions. I don't think this would be viable if the OCaml community grew larger though.
- SunlitCat 2y agoAnd people bash c/c++ for not having some kind of central package management system. Hah!
- carlmr 2y agoIMO C/C++ is not much better, sure, no central package management system, but then people rewrite everything because it's too hard to use a dependency. Now if you do want to use one of the 1000 rewrites of a library, you'll have a lot more checking to do, and integration is still painful. Painless package management is a good thing. Central package repositories without any checking isn't. You don't have to throw away the good because of the bad.
- lolinder 2y ago> Painless package management is a good thing. Central package repositories without any checking isn't. There's a reason why these things come hand in hand, though. If the package management is so painless that everyone is creating packages, then who is going to pay for the thoroughly checked central repository? And if you can't fund a central repository, how do you get package management to be painless? The balance that most language ecosystems seem to land on is painless package management by way of free-for-all.
- carlmr 2y ago>And if you can't fund a central repository, how do you get package management to be painless? You could host your own package server with your own packages, and have the painless package manager retrieve these painlessly. Of course we're in this situation because people want to see the painlessness with what other people built. But other people includes malicious actors every once in a while.
- bluGill 2y agoI have that in C++: we wrote our own in house package manager. Painless for any package that has passed our review, but since it is our manager we have enforced rules that you need to pass before you can get a new package in thus ensuring it is hard to use something that hasn't been through review. I'm looking at rust, and that it doesn't work well with our package manager (and our rules for review) is one of the big negatives! Note, if you want to do the above just use Conan. We wrote our package manager before Conan existed, and it isn't worth replacing, but it isn't worth maintaining our own. What is important is that you can enforce your review rules in the package manager not what the package manager is.
- JTbane 2y agoCorrect me if I'm wrong but the usual advice in the C/C++ world is just grab the source code of any libraries you want and build them yourself (or use built-in OS libs). This is not great if you have a lot of dependencies.
- rcxdude 2y agoYeah! nothing like the xz backdoor could happen there! wait...
- bqmjjx0kac 2y agoI'm curious how much review happens in Nix packages. It seems like individual packages have maintainers (who are typically not the software authors). I wonder how much latitude they have to add their own patches, change the source repo's URL, or other sneaky things.
- bamboozled 2y agoNot a lot in most cases. You’re still just grabbing a package and blindly building whatever source code you get from the web. Unless the maintainer is doing their due diligence nothing. Goes the same for almost all packages in all distros though. I’d say most of us have some connection to what we’re packaging but there are plenty of hastily approved and merged “bump to version x” commits happening.
- jowea 2y agoNixpkgs package maintainers don't usually have commit rights. I assume that if one tried to include some weird patch, the reviewer would at least glance at it before committing.
- c0wb0yc0d3r 2y agoI’ve never looked at the process of making a nixpkg, but wouldn’t the review process only catch something malicious if it was added to the packaging process? Anything malicious added to the build process wouldn’t show up correct? At least not unless the package maintainer was familiar and looked themself?
- jowea 2y agoI am not sure I understand the distinction between the packaging and build process, at least in the context of nixpkgs. Packages in nixpkgs are essentially build instructions, which you can either build/compile locally (like Gentoo) but normally you download them from the cache. Official packages for the nixpkgs cache are built/compiled on Nix's own infrastructure, not by the maintainers, so you can't just sneak malicious code in that way without cracking into the server. What package maintainers do is contribute these build instructions, called derivations. Here's an example for a moderately complex one: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/mindforger/default.nix https://github.com/NixOS/nixpkgs/blob/master/pkgs/applicatio... https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/mindforger/hunspell_pkgconfig.patch https://github.com/NixOS/nixpkgs/blob/master/pkgs/applicatio... As you can see, you can include a patch to the source files, add custom bash commands to be executed and you can point the source code download link to anywhere you want. You could do something malicious in any of these steps, but I expect the reviewer to at least look at it and build it locally for testing before committing, in addition to any other interested party.
- BrenBarn 2y agoSome alternative sources for other languages do it. Conda-forge has a process that involves some amount of human vetting. It's true that it doesn't provide much protection against some kinds of attacks, but it makes it harder to just drop something in and suddenly have a bunch of people using it without anyone ever looking at it.
- reaperducer 2y agoBack in the day repositories had 'maintainers' who reviewed packages before they became included. Then "walled garden" became a pejorative, and well… here we are.
- skeaker 2y agoPardon? Maybe my definition of that term is just different but that seems wholly unrelated.
- cute_boi 2y agoI think they should start scanning package with the help of AI.
- user432678 2y ago“Let’s 10x that shit”?
- SunlitCat 2y agoNah! Then we would need to add some blockchain and maybe sprinkle some other Buzzwords here and there for good measurement!
- nottorp 2y agoThe AI scanner must use blockchain validation and of course, be written in Rust. Actually, just rewrite all the packages on npm in rust and that will automatically get rid of any security problem.
- deleted 2y ago[deleted]
- love2read 2y agoThe fact that http fetches and fs reads don't prompt the user are continually the craziest part of the `npx` and `package.json`'s `postinstall`. Does anyone have a solution to wrap binary execution (or npm execution) and require explicit user authorization for network or fs calls?
- 2OEH8eoCRo0 2y agoUse Rust
- user432678 2y agoAccording to the comment below, it should be “Use Java”.
- 2OEH8eoCRo0 2y agoMy comment was made in jest
- SCdF 2y agoDefinitely stop using jest
- user432678 2y agoI bet someone already had entertained an idea to add cryptominer to Jest, nobody would notice slight increase to those tests running times on CI. Maybe it could even start funding those open source maintainers enough to finally make ES6 modules non-experimental.
- 0rzech 2y agoSee https://github.com/rust-lang/cargo/issues/13897#issue-2288844675 https://github.com/rust-lang/cargo/issues/13897#issue-228884... and https://github.com/rust-lang/cargo/issues/13897#issuecomment-2104346349 https://github.com/rust-lang/cargo/issues/13897#issuecomment... .
- phito 2y agoMalware in a crypto-related JavaScript package. Surprised Pikachu face
- tedd4u 2y agoI think the industry is going to soon look back on building with Wild West open-source repos like we looked back on not having absolutely everything running on HTTPS in the Snowden era. I know Google has "assured" open source repos for Python and Java [1]. Are there other similar providers for those and other languages? [1] https://cloud.google.com/assured-open-source-software/docs/overview https://cloud.google.com/assured-open-source-software/docs/o...
- Kaytaro 2y agoIf you include commercial offerings Red Hat has offered this for awhile, and many semi-successful startups have tried creating a business model solving this.
- theteapot 2y ago> npm is a package manager for the JavaScript programming language maintained by npm, Inc., a subsidiary of GitHub. -- [1] and Microsoft own Github so Microsoft is the provider? Pretty sure they're running malware scanners over NPM constantly at the least. NPM also has (optional) provenance [2] to a Github build workflow which is as strong as being "assured" by Google IMO. Only problem is it's optional. [1]: https://en.wikipedia.org/wiki/Npm https://en.wikipedia.org/wiki/Npm [2]: https://github.blog/security/supply-chain-security/introducing-npm-package-provenance/ https://github.blog/security/supply-chain-security/introduci...
- giantg2 2y agoAny reasonable company already knows this and sets up a proxy repo of scanned/approved versions (this is important for licensing too).
- 0cf8612b2e1e 2y agoHow much is that automated scanning worth? Sure, we have mirrored repos, but I assume the malware authors pre test their code on a suite of detectors in CI. So infected packages will happily be mirrored internally for consumption.
- megadata 2y agoCould we start a community review pool?
- dingi 2y agoWhy does NPM always seem to have this kind of issues? Why do we rarely hear about similar problems with Maven Central, for example?
- carlmr 2y agoBiggest target had biggest number of issues?
- _mlbt 2y agoI think a lot of it comes down to attack surface. JavaScript famously has a very limited standard library, so it is very common to pull in massive dependency chains of modules containing trivial functionality. Contrast this to Java, C#, and Python, where you can write robust applications with just the standard libraries.
- thewebguyd 2y agoYep. See left-pad from from 2016. Something so trivial it was basically part of every other major language's standard library (and it is now in JS, but wans't at the time). Other gems exist in the NPM world like is-odd, isarray, and is-negative-zero. The whole ecosystem developed this absurd culture of micro-packages that all do something insanely trivial that's built-in to pretty much every other language. All of it is a result of trying to force the web into doing things it was never really designed for or meant to do. Browsers were never supposed to be full application runtimes, and yet we (as an industry) keep doubling down on it
- whstl 2y agoThe culture of micro-packages is mostly pushed by people with financial interests. The modus operandi is to add a semi-useful package to a popular project, and then divide said project into other sub-projects just to bump the numbers. Then those individuals start claiming that they have "25 packages that are foundational to the web infrastructure", while in fact it's just a spinner that has 24 dependencies, some of those being one-liner packages. Parallel to that we also have things like Babel, which has hundreds of packages, a huge chunk of them being almost empty and only triggering flags in the core package.
- theteapot 2y agoPut `ignore-scripts=true` in your .npmrc
- gruez 2y agothat just delays the exploit. The exploit can still run next time you import the file.
- theteapot 2y agoThis mostly defends against name squatting and other malicious dependencies that never get imported. Haven't reviewed code but article says its entry point is install script. install scripts don't run on import. I guess you saying it triggers from import too.
- deanc 2y agoI'd like to see a world where the JS community focused more on improving the stdlib across the browser and in nodejs - much like bun is doing. Common packages for node such as mysql2, axios etc. are so widely used and are huge attack vectors should they ever be compromised.
- DimmieMan 2y agoDeno is perhaps a better example with browser API's, part off the winterTC committee and a growing set of std packages[1]. Possibly more importantly, it has a security model that defends against this kind of exploit. I will agree with the sentiment though, I get not wanting to jump on new shiny things but for some reason I keep getting the vibe that the community is closer to crab mentality than healthy skepticism, downright hostile towards any project making a genuine effort to improve things. [1]https://jsr.io/@std https://jsr.io/@std
- azemetre 2y agoMy issue with deno and jsr is that it only exists at the discretion of VC funding. That does not feel like a sustainable ecosystem where the incentives are misaligned (wanting a return on capital versus proper open engineering).
- sieabahlpark 2y ago[dead]
- geenat 2y agoDownloads used in infrastructure... VSCode Extensions, Github repos, PyPI, NPM, etc. all need to be scrutinized. Open source at least has the option to audit; closed source (or "closed build" stuff like 7zip) is at far higher risk: mostly just VirusTotal which mostly will not catch backdoors of this type. Mainland China, Russia, North Korea, use these vectors for corporate and government espionage: https://www.youtube.com/watch?v=y27B-sKIUHA https://www.youtube.com/watch?v=y27B-sKIUHA ...XZ, Swoole are 2 examples off the top of my head.
- deleted 2y ago[deleted]
- distalx 2y agoThe open-source ecosystem's strength is also its weakness. Relying solely on community vigilance isn't cutting it anymore.
- feross 2y agoExactly. Linus’s Law — “given enough eyeballs, all bugs are shallow” — falls apart when everyone assumes someone else is doing the watching. In reality, most packages (and especially their transitive dependencies) get zero meaningful review. Attackers know this and exploit it. Community vigilance just doesn’t scale — we need better tools to actually inspect what code is doing.
- johnfernow 2y agoI agree with you. To be fair though, the concept likely seemed more reasonable in 1999. Hardware, browsers, and websites (and their front- and back-end services) were all less complex back then. Also less bloat. Not that things were more secure, but a popular tool may have had more meaningful review. At times, complexity is worth the trade-offs. Modern C++ compilers are more complex than ones in the 80s and 90s, but the assembly code they generate runs much faster. Rust is complex but provides massive security benefits while maintaining great performance. At times though, stuff is just bloated or poorly designed. But it's not always clear how to intelligently design a project. If you add too many features to a single large project, it becomes unwieldy to maintain that large project, and the harder it is to audit this critical piece of infrastructure. Yet, if you don't add enough features, people will use packages from random devs, risking their own security, while harming the maintainability of their own project. I don't know how we solve that problem. Alternatively, you could ask devs to reinvent the wheel and write a lot more code on their own (which they probably won't, either because they don't want to, or because the employer requires a solution on too short of a timeline to do so), but that could also jeopardize security. Many if not most web devs have to deal with authentication and encryption, both of which (the overwhelming majority) very much should not do on their own. Good luck asking a junior dev to correctly implement AES-256 encryption (or something equivalent or better) on their own without using existing libraries. The answer is almost certainly some kind of mix, but it's not clear what exactly that should look like.
- amelius 2y agoI'm guessing we have to move to a setup where a developer enters code while being watched by an AI. Then the AI can give warnings if a line of code appears in the repository that wasn't on the developer's screen while they were looking.
- delfinom 2y agoWe will need an AI to watch the AI so that the first AI isn't working for the bad guy too
- submeta 2y agoWhat‘s the advice? Only develop in a sandbox environment? Otherwise chances are our main machines get compromised?
- rcxdude 2y agoVet your dependencies, at least to the level of making sure your direct ones are actually real projects done by known people and reasonably widely used. Note that for all the buzz about these kinds of attacks, there's relatively little evidence they are actually successful at being downloaded and installed by anything but automated scanning/archiving systems.
- Joel_Mckay 2y ago"I'm shocked, shocked... well not that shocked... " It is the curse of all out-of-band package managers... where eventually some lamer shows up to ruin the fun for everybody. =3
- timewizard 2y agoThe is the intersection of "user friendly" and "self installed." It exists anywhere this is tried. The entire idea that 'postinstall' or 'preinstall' or any sort of _script_ needs to run after you've fetched a package of what should be /interpreted/ code is completely insane on any "modern" desktop OS. From what I can tell the main use case is avoiding the problems from users who cannot figure out how to set an environment variable or reliably run a subshell.
- xyst 2y agoPeople wonder why I run their shitty apps in VMs and nuke the VM afterwards. This is why, lol.
- fsflover 2y agoSounds like Qubes OS, which is my daily driver.
- BrouteMinou 2y agoI am reading this while downloading half the internet doing a `cargo build` for my hello world program. At least it's not the cursed javascript, right...
- vaxman 2y agoDownloading NodeJS modules and containers from "public" data sources that are either vetted or are vetted by unknown parties, isStupid == TRUE. Play stupid games, win stupid prizes. It's unfortunately not a problem specific to Node, goes back to at least the early Linux kernel and CPAN days. As GenZ has invaded Wall Street, they have started to pay attention to this concern and call it a "supply chain integrity" issue. Ironically, GenZ also leads the charge in most companies to "trust everything" because "everyone is doing it." (In most corporations, "perception is the reality" and if everyone perceives jumping off the cliff is The Way https://youtu.be/V-SJQdREDKM https://youtu.be/V-SJQdREDKM) A solution is for ID.me to begin issuing developer certificates (for free to those offering themselves up as developers) and for the old system of public repositories and mirrors to be replaced by a single source of truth operated by a new entity jointly sponsored by the $15.4 Trillion worth of companies: Amazon, Google, Meta, Apple, nVidia, Tesla and Microsoft in such a way that everything in every repository can be traced back to the actual biometric signature of a developer and their related IRL context. These entity, its sponsors and ID.me also need to observe a regulation that they will NOT "track" or share information between each other (or others) about developers indexed off their developer certificates beyond what's necessary to host the repositories and to manage access to developer-only programs (such as Xcode signing, etc.) Ideally the JV will be located in Switzerland (perhaps with the hardware located in a Svalbard-like facility) using some UN supervised process (overseen by Nato, Russia, China and the Plebeians) to vet all workers.
- vaxman 2y ago*-either NOT vetted or were vetted by unknown/untrusted parties
- hackburg 2y ago[dead]