What is npm? How do I know I'm not using it?
Selfhosted
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
-
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
-
No spam posting.
-
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
-
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
-
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
-
No trolling.
-
No low-effort posts. This is subjective and will largely be determined by the community member reports.
Resources:
- selfh.st Newsletter and index of selfhosted software and apps
- awesome-selfhosted software
- awesome-sysadmin resources
- Self-Hosted Podcast from Jupiter Broadcasting
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
Short answer: If you don’t know if you’re using it, you’re very likely not using it.
Npm is a package manager for node.js, a programming framework for JavaScript.
Don't. Use. Npm.
That applies to pip and crate and all the other shitty lang package managers that totally fail at security
What about using pip just to download basic common libraries for offline use?
Don't do it.
What should be used instead?
A package manager that uses cryptographic signatures. Apt had this since 2005 iirc. Use apt.
if the dev(s) gets compromised there's the same issue, except with an extra checkmark on it.
Packages are reviewed by package maintainers.
Humans are required to solve a malicious insider. But most supply chain vulns of these shitty software dependency managers were resolved decades ago by freely available cryptography
Human review really should be what's needed, maybe not even just by the package maintainers.
Easy, just vendor all your dependencies! Can't have a supply chain attack if you are the supply chain.
so many workplaces I have been at used npm.
We just recently switched from npm to pnpm, due to all the supply chain attacks. I did the PR for it, even.
Our release schedule is like a year though so we don't really have to worry much about releasing compromised dependencies. But still, better to be on the safer side.
Yep. And so many workplaces have had security vulnerabilities caused by dumb decisions that could have been easily avoided
Can we stop using npm now?
I swear to god the number of attacks like this or spawned from other attacks like this is fucking stupid. I’ve gender seen anything like it.
This problem has nothing to do with NPM. Checkmarx was compromised last month, and during that compromise there were malicious VS Code extensions published to Visual Studio Code Marketplace. A Bitwarden developer says that somebody ran one of those malicious extensions, and GitHub API keys were stolen which were used in publishing the malicious CLI package.
It's probably better that it happened on NPM. If the CLI were only downloadable from the Bitwarden website, it would have likely taken longer for somebody to notice something was wrong.
Yes, but NPM has been had countless security problems, this isn't a new problem. Even tho this instance is not a problem of NPM itself, it still has been proven as one of the most unreliable and insecure package managers out there.
I'm not a particular fan of npm, but you'll probably see this kind of thing with any package manager of similar size. More a matter of what's the most attractive target than the package tech itself.
Npm probably has the biggest attack surface and many of the libraries hosted there are in extremely widespread use. They've taken some steps to mitigate these supply chain attacks, but as we've seen with more recent examples, it's unrealistic to think they can be prevented completely. Most of these attacks use stolen developer credentials, which invalidates almost all potential security measures on the registry side and the best you can hope for is catching a malicious package quickly. To be clear: I think the JS ecosystem is uniquely positioned to be the prime target of supply chain attacks and while that doesn't excuse the slow implementation of security measures from the npm team, the people arguing that other package managers and registries aren't vulnerable to this have to be huffing fumes.
That’s fair, I won’t pretend pypi/pip and running uvx is much safer than npx.
But why hasn’t JavaScript established a defacto stdlib to replace ask the left pads and is even type packages?
I’ve taken a near zero dependency policy on my personal projects regardless, and now I run most code in containers to sandbox it.
If you're asking why there isn't one shipped with JS, the answer is because JS is built for the web, and the "don't break the web" rule makes changing things in JS hard, as well as browser devs pushing back hard on anything that increases install size.
If you're asking why as a community, we haven't agreed on a single package to be a stdlib - lodash.
But why hasn’t JavaScript established a defacto stdlib to replace ask the left pads and is even type packages?
I'm guessing things were working out pretty alright, even with the insane amount of dependencies per project. The awareness and the increasing frequency of supply chain attacks is relatively recent for npm. But who knows, maybe the tech giants in control of the web standards are happy to keep using their own vendored registries.
Genuine question. How is NPM more vulnerable than other repos? Haven't similar supply chain attacks succeeded at least as well as this one through GitHub itself and even Linux package repos?
Larger standard libraries do a lot. It's a lot harder to sneak vulnerabilities into the basic C# or Java or C++ libraries than it is to add a vulnerability to something one dude maintains in the javascript ecosystem.
And since javascript libraries tend to be so small and focused, it's become standard practice for even other libraries to pull in as many of those as they want.
And it stacks. Your libraries pull in other libraries which can pull in their own libraries. I had a project recently where I had maybe a dozen direct dependencies and they ended up pulling in 1,311 total libraries, largely all maintained by different people.
In a more sane ecosystem like C#, all the basics like string manipulation, email, or logging have libraries provided by Microsoft that have oversight when they're changed. There can be better, third-party libraries for these things (log4net is pretty great), but they have to compete with their reputation and value over the standard library, which tends to be a high bar. And libraries made on top of that system are generally pulling all those same, certified standard libraries. So you pull in 3 libraries and only one of those pulls in another third party single library. And you end up with 4 total third party libraries.
Javascript just doesn't really have a certified standard library.
(This certified standard library doesn't have to be proprietary. Microsoft has made C# open source, and Linus Torvalds with the Linux Kernel Organization holds ultimate responsibility for the Linux kernel.)
I will almost always choose .NET as my development platform when greenfielding a project for exactly this reason. It's an incredibly robust standard library that virtually guarantees I won't need to pull in a litany of additional utility libraries, and I can also expect that what libraries I do choose to bring in are highly unlikely to drag along a ridiculous parade of dependencies.
Part of the problem is also how many packages people bring in, even for the simplest of things.
It has only been available for 2h30 on NPM, so unless you had the misfortune of installing the latest version in this short window, you should be fine. Thankfully people have been able to quickly catch this.
This is one of the reasons why I update a version or two behind. The other reason is because I'm lazy.
reposting the tl;dr I wrote from another community...
Yesterday, for about 1h30min (starting at 5:57pm ET / 21:57 UTC) anyone installing the latest version of the command line interface of bitwarden was installing malware.
The malware steals GitHub/npm tokens, .ssh, .env, shell history, GitHub Actions and cloud secrets, then exfiltrates the data to private domains and as GitHub commits and doesn't seem to be targeting Bitwarden specifically, or user vaults.
There's no evidence that end user vault data was accessed or at risk, or that production data or production systems were compromised, according to their official statement.
It seems there were 334 bitwarden CLI downloads in this time period, some or many of which might have been from bots, so this is a higher bound to the number of affected users.
lots of people recommend bitwarden, but i am more at peace with an offline password manager that i control like Keepass. You can also go the GNU route and use "pass" on Linux too
Or use a physical key like Yubikey to login
Only if yubibkey worked for more than the handful of sites/services. I have one for my bitwarden as majority of places want to send a text or us totp.
Does this include the brew version?