5 ms·
> People dramatically overestimate the correctness of their [C/C++] code Genuinely interested: what do people think of their tons of third-party dependencies i
by palata 3y ago
> People dramatically overestimate the correctness of their [C/C++] code
Genuinely interested: what do people think of their tons of third-party dependencies in Rust? My experience building Rust projects is that there are orders of magnitudes more dependencies than what would make me comfortable. At least in C/C++ it's much harder to get there.
- kibwen 3y agoI use embedded Rust for my day job. We keep our third-party dependencies purposefully minimal, but I adore that they're there when I need to reach for them. Like, we just needed a basic TCP stack to get our PoC up and running, so I can just grab smoltcp and be off to the races. Being written in C or C++ wouldn't obviate our need for a TCP stack, I'd still either need to get it from somewhere else or write it myself. And even if I can't use a third-party dependency for whatever reason (e.g. if it doesn't support no_std mode), I can still usually repurpose their existing test suite to give me confidence in my port or reimplementation.
- deleted 3y ago[deleted]
- iknowstuff 3y agoLong story short is that I trust their quality. The community is great about vetting unnecessary uses of unsafe code. That’s more than can be said about hand rolled equivalents in C/C++.
- palata 3y agoSo if you have 200 dependencies, you trust them just because they don't run what Rust calls "unsafe" code? What about safe code that could be malware?
- rockdoe 3y agoFYI Google and Mozilla audit all their dependencies and share them: * https://chromium.googlesource.com/chromiumos/third_party/rust_crates/+/refs/heads/main/cargo-vet/audits.toml https://chromium.googlesource.com/chromiumos/third_party/rus... * https://searchfox.org/mozilla-central/source/supply-chain/audits.toml https://searchfox.org/mozilla-central/source/supply-chain/au... It's quite likely that most of your dependencies were already audited.
- meragrin_ 3y agoSo what in there guarantees I can get the same thing they audited?
- GrumpySloth 3y agoVersion numbers. You can’t modify an already-published version of a Rust crate on crates.io.
- palata 3y agoWho in practice pins their dependencies (transitive included) on audited versions?
- rockdoe 3y agoSmall companies with little development experience like Google and Mozilla. (You can check the files I linked and see audits between deltas for minor version updates)
- palata 3y agoI guess my point was: "because [some teams at] Google/Mozilla do it right does not mean that everybody does it right".
- rendaw 3y agoIsn't this hierarchical trust? You select immediate dependencies that you believe are written by reasonably security-conscious people, not just anything that immediately solves a problem, and because they're reasonably security-conscious people they select their own dependencies the same way? And at each level vetting is implicitly shared with other users of the dependencies, some of whom will be more critical/inquisitive. I've heard the alarms about dependencies and I'm not sold. I feel like this is bleeding over from the JS/frontend world where people don't choose to do the above, for whatever reason. Whenever I add a dependency in Rust I look at crates.io downloads, dependents (any big projects there?), github stars, I browse the issues to see what sort of problems have been reported and when, with what sort of replies from the author, how many contributors there are, release history, what commits look like, and what other stuff the authors have worked on. I use a lot of dependencies, and I do rewrite stuff myself when I feel like I can't rely on a dependency.
- palata 3y agoThat's the thing about trust: not everyone uses it the same. There are documented examples of malware being injected to millions of dependents through package managers, so we know that "hierarchical trust" does not work. The big difference with a distro is that I choose to trust the distro maintainers, which is only a handful of people. Whereas with your hierarchical trust, you choose to trust many random people.
- rendaw 3y agoI know I remember there being a couple big events in the news, and I know the Javascript ecosystem is also a bigger target also because it's so popular, but do you have examples of these attacks?
- rockdoe 3y agoIn C/C++ every project ends up with a hand coded replacement for those external dependencies that is less well written and infinitely less tested.
- infamouscow 3y agoWhat about all of the projects where your assumptions are false?
- rockdoe 3y agoWhy would those need a lot of Rust dependencies then? If you want to hand-roll stuff, hand-roll! no_std is a thing because people use it.
- troad 3y agoI'm somewhat puzzled - the obvious answer is that you don't have to use them. Rust by itself is no less feature complete than C. Anything you can write in C without dependencies, you can write in Rust without dependencies too. Of course, dependency-reliance falls on a spectrum for any individual programmer. On the one hand you have script kiddies with 400 npm dependencies gathered from arcane Discord channels - on the other you have old bearded wizards who don't understand why you'd need printf() when you can just mov rax 1; syscall. I find Rust is not strongly opinionated about this. You can just as easily eschew dependencies as use them. There's usually a good array of options available, or you could always FFI to a C lib directly if you need to.
- palata 3y ago> I'm somewhat puzzled Because you find it fine to say that "people dramatically overestimate the correctness of their [C/C++] code", but not fine to say that "people tend to depend on too many third-parties that they never question"?
- iknowstuff 3y agoWe have solid data on how much Rust improves safety, while “too many” dependencies seems rather arbitrary. They tend to be high quality and better vetted/tested than bespoke code or copy-pasted hpp headers
- palata 3y ago> They tend to be high quality and better vetted/tested I thought anyone could publish rust packages, just like for PyPi? Are the packages audited before they are published in Rust? > “too many” dependencies seems rather arbitrary I would say that you have "too many" dependencies when you don't have control over them, e.g. because you can't afford auditing them or maintaining them. I have seen multiple Rust projects that I would rather rewrite myself than audit their tens (hundreds) of dependencies. That's "too many".
- 3y ago
- _w1tm 3y ago> At least in C/C++ it's much harder to get there. Interesting take. Poor package management as a security feature. As others have pointed out, instead of potentially poorly written third-party dependencies C/C++ will just have potentially poorly written homebrew replacements.
- palata 3y ago> Interesting take. Poor package management as a security feature. How poor is it to install a package with your system package manager instead of the language package manager? I wouldn't call it poor. The biggest difference I see is that language package managers are usually not curated (and that's a feature: "it's much faster than getting your package accepted in a distro"). My preference is to rely on curated package managers when I can. When I can't, then I am the maintainer, and therefore I need to handle the dependencies myself. You can call it "poor", but the fact that I maintain my dependencies is actually a security feature. When you depend on 600 third parties that you don't even know and that are not curated, it is a security problem.
- jnxx 3y ago> Genuinely interested: what do people think of their tons of third-party dependencies in Rust? Here are three things I think, and they have in fact nothing to do with Rust: 1. The easier it is to add dependencies, the more dependencies will be added on average - unless you work purposefully against that. 2. The effect of a rising average number of dependencies in libraries is that their number of dependencies grows as well, and the number of their dependencies' dependencies... up to dependency graphs of several hundred nodes size. Like in exponential growth. An example would be the dependency graph of jquery. 3. I observe this "exponential" growth can have chain-reaction-like effects, like if you have a mass of U235 that achieves critical mass. Below that critical value, some neutrons flying around might trigger a few fissions, but these die out. Above that value, neutrons lead to fissions which lead to more neutrons and so on. The same can happen with complexity in multi-component software. At some point, complexity goes through the roof. And the latter is especially true if backwards compatibility is not strictly observed, since backwards-incompatible changes tend to be infectuous in that they often make their client components (parents in the dependency graph) backwards-incompatible as well, in other words, there is breakage that propagates up the dependency graph. That breakage might die out and be able to be contained by local fixes, or it might propagate. And once your dependency graph becomes large enough, it is almost guaranteed, that you have breakage. All these things together is why I believe that systems like NixOS or Guix are the future (but of course there might be other developments in that space).
- palata 3y ago> All these things together is why I believe that systems like NixOS or Guix are the future (but of course there might be other developments in that space). That, or actually keeping control over the dependencies?
- jnxx 3y agoI think it is always wise to constrain unneeded dependencies. And this counts even more in embedded systems. But on the other hand, programming artefacts, languages and their library systems compete in terms of features, which will usually lead to an ever growing number of dependencies. At least this is what we observe. Even if not all of this is really necessary, this would probably be hard to reverse in general.