Oooh nice
post
I made a wrapp er script named npm on my $PATH that passes input to pnpm instead because of this. I don't think my team is ready to adopt something like that, but it seems to be working okay so far. Nobody has complained.
"Look at how all these much smaller package ecosystems don't have the problems of the largest one."
is the tl;dr of this article.
Npm having a lot of packages at least partially a problem of lacking standard library, no? And partially developer culture where every trivial thing is a package. Anyway, similar thing will happen to rust soon enough (*looks at 1 gig of dependencies for a cli program*).
Interestingly, developers in ecosystems like Go, Rust, and those utilizing native Web APIs—where robust standard libraries drastically reduce reliance on third-party code and strict cryptographic verification is built into the core toolchain—reported zero instances of a college dropout’s weekend project wiping out global logistics infrastructure today.
As someone who's built a career in Rust, it is 100% susceptible to an attack like this. The community is just generally paranoid enough to avoid depending on super niche packages.
Even so, Cargo still doesn't have code signing and crates.io doesn't have 2FA. They just barely rolled out email alerts for new crates being published with your API key.
And there's dozens of single-author crates that are depended upon by millions of lines of code, any one of which could easily be a vector in a supply chain attack. In fact there have been attempted supply chain attacks against crates.io, but to my knowledge they've all relied on typo-squatting.
We're definitely overdue for a major attack.
Today I had to build and install an application using Crates. It recursively pulled 700 other packages and gave me a gut feeling comparable to testicular torsion. I don't care how paranoid the community is, it only takes one careless maintainer to node-ipc or left-pad an entire dependency tree.
Crates.io does support trusted publishing for GitHub and gitlab. It's not much, but it's Honest work.
... I which it supported forgego
It's not enforced though, and there's no way as a consumer to see how a crate was published.
To be extremely fair, crates.io has a huge maintenance bottleneck because AFAIK it doesn't even have a single dedicated developer. But that's definitely a big part of the problem.
The Rust Foundation is really just not pulling in enough revenue to support the project properly. They really ought to figure out more revenue streams than just sponsorships and donations.
Nice. I've always been paranoid of typo squatting but never knew it had an official name or people that implement it. Thanks for the share
I guess one benefit is rust development often doesn't use bleeding edge version for everything, where you pull the entirety of crates.io through your machine when you open your IDE. From what I've seen most projects use == versions and lock files.
I don't know enough about rust though. Could an attacker change historical crate versions to a payload and then cargo pulls them because they changed? Or will cargo only pull an update if you change to a different version on your machine?
You can't overwrite previously published versions.
Application projects are recommended to check-in the Cargo.lock which pins dependency versions but you can always just run cargo update at any time which automatically upgrades all dependencies to the newest version allowed by the Cargo.toml.
Some projects get around this by pinning the dependency in the Cargo.toml (using =) or by vendoring all their dependencies, which is a huge pain in the ass.
Cargo does not respect lockfiles by default, AFAIK. You need to explicitly pass the --locked flag.
That sounds better and worse. An attack could persist past one specific version without anyone noticing for a bit.
I can tell without clicking that it's Snaps
Too lazy to check, but did they parody the entire Onion article or just the headline? Lol
Pebcak.
I write this as someone who fully hates npm and javascript, but it's not even a package manager issue. The issue is that someone gets hacked and their credentials get stolen. This could happen to any ecosystem, it's just more likely to be beneficial if you target JS because of ubiquity.
People would need to develop entirely new credential management protocols to circumvent this and they'd probably be risky to automate to the same degree of convenience that we have now so, unless you're looking to spin up containers for each and every step of development or, god forbid, write/vendor your dependencies it's actually not easy at all to prevent this sort of thing.
Interestingly, developers in ecosystems like Go, Rust, and those utilizing native Web APIs—where robust standard libraries drastically reduce reliance on third-party code and strict cryptographic verification is built into the core toolchain
Does NPM really not do cryptographic verification or is this part of the joke? I always assumed the attacks were due to a compromised key or something, but this is implying you can just push whatever you want to an NPM package if you have the author's login?
The recent attack didn’t have to do with cryptographic signatures. It was a supply chain worm, with GitHub Actions being the vector. https://snyk.io/blog/tanstack-npm-packages-compromised/
Rust
Rust is doing pretty poorly right now.
among the 999 most popular crates on crates.io, around 17% contained code that do not match their code repository.
https://kerkour.com/rust-supply-chain-nightmare
Rust programs that are compiled with cargo, when compiled as dependencies of another program or when compiling a binary itself, can execute arbitrary code via build time scripts, and they are executed unsandboxed. This is a security nightmare.
push whatever you want to an NPM package if you have the author’s login
This is how all language package managers work, unfortunately. The login's security can be improved, via things like 2fa, but it's currently very bad. Having multiple parties use keys to sign packages after reviewing all changes, is a thing unique to distro package managers, and it is why Linux distros are extremely resilient against supply chain attacks.
Cargo distributes libraries as sources, not precompiled objects.
Yes, that is true.
Thought, even this remains problematic because cargo does execute build/compile time scripts, unsandboxed, that can be used to do malicious things, similar to the problems with npm.
Unlike javascript, where at least it is an interpreted language people can audit, you would have to reverse engineer these binaries to figure out what they do.
If you cargo install something you get source code (unless the library packages a binary, but that's the same as if it were JS or Python or C). Rust dependencies don't become binary until the final product.
Auditing Rust binaries isn't much worse than auditing minified and uglified JS. I've done both.
EDIT:
Rust
Rust is doing pretty poorly right now.
among the 999 most popular crates on crates.io, around 17% contained code that do not match their code repository.
https://kerkour.com/rust-supply-chain-nightmare
I just went through the article and I don't think I agree with the assessment that "Rust is doing pretty poorly right now." It feels disingenuous, given the content of the article you linked:
826 crates match their upstream repositories at the revision they were built at. 74 crates have revisions that cannot be found in their repositories, whether due to later squash merges, rebases or revisions simply not being pushed. 73 crates do not have VCS info, either because they were built with old Cargo versions, built with --allow-dirty, or not built from a repo clone at all. 77 crates do not declare a repository in their Cargo manifest. 7 crates would match their upstream repository but for one or more symlinks being incorrectly handled. 3 crates declare repositories that do not exist. 3 crates have submodules that do not exist. 3 crates cannot be found within their repositories. 3 crates cannot be built due to cargo package errors. ... Only 8 crate versions straight up don’t match their upstream repositories. None of these were malicious: seven were updates from vendored upstreams (such as wrapped C libraries) that weren’t represented in their repository at the point the crate version was published, and the last was the inadvertent inclusion of .github files that hadn’t yet been pushed to the GitHub repository.
This is how all language package managers work, unfortunately
npm does actually support signing and provenance (tracking how the package was built), so in some ways it can be more secure than other package managers. https://docs.npmjs.com/generating-provenance-statements
If you use one of the CI/CD systems they support (currently Github Actions and Gitlab CI), it can attach a signed attestation to the package stating the commit hash that was used to build the package, along with the steps taken to build it. This is combined with trusted packaging using OpenID Connect with short-lived tokens that are only obtainable in the correct CI environment, rather than using access tokens or username and password.
It only supports some CI systems because they have to guarantee that the connection between the CI system and npm is secure.
Some of the recent issues have been attacks on the CI system, rather than npm itself. For example, a Github Action that's only supposed to run for commits to the main branch, but unintentionally runs for some subset of pull requests too.
Of course, all this stuff is optional, and pushing to npm directly from a developer's computer still works and is still not verifiable at all.
I think the best approach is what Flathub/Flatpak, F-Droid (Android) and Composer/Packagist (PHP) do. You provide your repository URL, and they build the code on their end. Packages are always guaranteed to be built from code in the repo.
Debian Linux is also moving towards requiring repeatable builds, meaning that a package built from source should be byte-for-byte identical to the package in the repo.
Another day of vaguely pointing at Javascript when asked where the circus is.
It's funny that we've had SLSA4-compliant package managers for 25 years, but we leave juniors un-mentored and this is what they build as they self-teach ... over and over and over.
Hilarious idea brought down by the AI slop thumbnail. The vulneráéilíties on that screen sure look OOTΓKAL.
ai! slop!!
oh, and the text is pristine, the misinformation nexus is here!! fsm help us all
all 5 comments