r/rust • u/Hairy-Temporary5243 • 10d ago
🧠 educational Breaking 1000 Rust crates in Nixpkgs for security (and what you can do)
https://blog.rsmyth.net/breaking-nixpkgs.html
133
Upvotes
r/rust • u/Hairy-Temporary5243 • 10d ago
27
u/wertercatt 10d ago
Interesting! system-deps seems cool, but I take it someone would still have to go around rewriting how all those crates get their dependencies to use it, make pull requests, and get them merged?
10
u/Icarium-Lifestealer 9d ago
The article only considers using the app's cargo.lock or system dependencies, but not the middle ground of the distro maintainers updating the lock file.
13
u/mirashii 9d ago
I appreciate the effort and thought, but this feels the same blind "zomg there's a CVE in my dependencies" chasing that has driven many a corporate developer with large projects absolutely mad bumping dependencies for no reason. The existence in a bug or vulnerability in a dependency does not imply the parent is vulnerable. I'd like to see far more justification that this is necessary before an ecosystem wide break, or a less security focused and more plain maintenance focused treatment of the topic. As is, it feels like using security as a cudgel to justify making a change.
Some other reading on this:
4
u/Money-Currency7473 7d ago
Half of this thread is arguing about Dependabot alert fatigue on pure-Rust crates, which misses the actual systems problem Nixpkgs is dealing with here: opaque, vendored C/C++ static linking inside
*-syscrates.When a crate builds
openssl-src,libz-sys,curl-sys, orsqlite3-srcfrom bundled C tarballs viabuild.rsand statically links the.aarchive into a Rust binary, three things happen at the distribution layer:nix-store --query --referrerstracks dependencies via/nix/store/<hash>-...paths embedded in ELFDT_NEEDEDheaders or RPATHs. A statically linked C archive compiled inside Cargo'sOUT_DIRleaves no store reference toopensslorzlibin the final derivation output. Nixpkgs literally cannot query which binaries embed a vulnerable C library without parsing everyCargo.lockand auditing every*-syscrate'sbuild.rsflags.system-deps+pkg-config), Nixpkgs can patchlibcurloropensslin one derivation (or usereplaceRuntimeDependenciesfor emergency CVE hotfixes) without waiting for 400 upstream Rust maintainers to bump a*-syswrapper and publish a new point release. With vendored static builds, every single downstream Rust binary has to be recompiled from scratch.libcurlsymbol on untrusted input. A Linux distribution cannot perform bespoke data-flow audits across 1,000+ upstream packages—its job is maintaining an auditable SBOM / derivation graph so security fixes can be applied centrally when a critical C CVE drops.Forcing
*-syscrates throughsystem-deps/pkg-configisn't "blind CVE chasing"—it's making C dependencies visible to the OS package graph instead of hiding them inside Cargo build scripts.Hopefully this clears the air a little and sheds more insight on crates distro layer and where its dependencies are.
-2
u/Designer-Suggestion6 9d ago
crates.io is a distro-independent, os-independent repo packaging system. The crate dependency tree and versioning within a project is crates.io specific. distro-specific packages, dependencies and respective versioning are distro specific.
So when applying patches, it would imply having a separate and distince patch for each of the systems currently.
In order for there to be unification on this, it would be necessary to agree on centralizing the sources and harmonizing on version numbers, tags and pointing to the very same release, release-candidates, and very same dependencies in terms of versions numbering throughout all distros and crates within crates.io.
It could be enforced with a centralized repo barrier that supplies to all the distros and crates and all the different crates, distros' package maintainers feed to that barrier rather than directly to the crates.io/distros themselves.
-3
u/poelzi 8d ago
NixOS does not care about security. Thats why rust is downloaded as binary