Join the discussion

Write your take first — we'll ask for email only when you're ready to publish.

  • Hacker News
  • Unfortunately Cargo doesn’t have security controls in place to prevent these kinds of attacks. For example pnpm has controls to allowlist install scripts for dependencies and will warn about new install scripts (without executing them).

    There is an open issue for this: https://github.com/rust-lang/cargo/issues/13681

  • Compromising the code that is then most likely run in a test instead of compromising a build script is just a very slight inconvenience for the attacker.

    I share the dislike for arbitrary build scripts but restricting them will not help the supply chain issue in a significant way.

    Also there are several ways to control build.rs execution in the Cargo ecosystem as well, for example with cargo-deny.

  • The rust ecosystem is going to be hit by malware just like the NPM ecosystem. I have been saying it for years. They made the same mistakes or even worse mistakes because all it takes is a compromised serde to take the entire ecosystem down.
  • Here's a suggestion, do you think it could be this simple? If you write a package-manager, don't execute any of the downloaded code in an automated fashion. No hooks, no build-time metaprograms. If your language _needs_ metaprogramming to function, it's a huge secondary issue that I don't know how to solve. You can try to make a meta-program annotation which disables side-effects, but the metaprogram ultimately must write memory which expands the amount of code generated. All risk is introduced when the person downloading cannot preview the content in a safe place.
  • > arrayref is a small crate of four macros.

    Why do so many languages fall into this horrible practice?

  • just to clarify, by "horrible practice" you mean macros?
  • Only the ones that make it easy. Language package managers are a mistake.
  • Just like c++ thought threads wasn't a std library concern and then later changed they minds, rust will also change tac I predict
  • There are two reasons you might want to use a crate, The first being that you want to use a good solid implementation that you know someone has spent more time doing and works better than almost any solution you could integrate. The second is you don't want to spend time implementing that.

    Writing macros in rust is a pretty horrible experience but it's not difficult

  • The languages that have a poor standard library support have this issue and other languages encourage you to import tons of libraries to fix the problem.

    This is why Javascript and Typescript suffer from this the most and has little to nothing to do with "popularity" and likely 9/10 of these npm packages import an external library.

    Golang on the other-hand is just as popular and has a stronger standard library which people build against and it is encouraged to use its standard library rather than rolling your own or importing another package to solve the problem.

    by rvz
  • There was a recent talk which explored this question (Dependency Cultures, by Richard Feldman):

    https://www.youtube.com/watch?v=E82ly38YEEQ

    Summary: it's cultural. Rust likely inherited the practice from Nodejs, who inherited it from Ruby. I think in Rust online spaces in particular there is also this undercurrent of "you're not smart enough to use certain parts of the language, so download libraries that handle that stuff for you."

  • All those folks telling me to update my dependencies, this is why I don't do it. It's not laziness, it's undeniable foresight.
  • There's a reasonable solution to this. Tools like `cargo-audit` can tell you if a crate has security issues and guide you towards an update. You don't have to blindly update all dependencies this way.
  • What purpose does “undeniable” serve here? This tips over into hyperbole, in my opinion, whereas “it’s foresight” is much simpler and stronger. YMMV.
  • I mean, yes, update your dependencies. But probably after a week or so after they've been release and tested by the first penguins willing to jump into the ocean.
  • As long as your versions don't have any security issues...
  • We need effect based languages now. It's the only way to guarantee policies like no network, no file access, no unsafe code or FFI for a library before it even compiles. If anyone from epic is reading this please give us a timeline for open sorucing the Verse compiler.

    In the mean time I think it's possible to hack Cargo and run all build scripts in a microVM. The blast radius will be limited to malicious code in the binary instead of uploading all your CI secrets and deleting the whole hard drive.

  • Why does every build have the ability to run arbitrary code by default in the first place? That seems like something you should opt into only under very specific scenarios and even then it should probably be built around a WASM sandbox or microVM (as the parent suggested).
  • I have been working on a cross platform way of sandboxing without a VM:

    https://github.com/brianv0/formwork

    by prpl
  • Some shameless self promo - I'm working on one!

    https://hale-lang.org/proof/

  • https://github.com/insanitybit/witchy

    This is why I'm building this language. It's capabilities based. Build scripts can't just do whatever the hell they want to, everything is auditable, and it layers its sandboxing.

    It's for fun and anyone looking should understand that this is AI driven building with human driven design, but the goal is to demonstrate.

  • More than that, we need capability-based languages. No capability passed to it, no permission.
  • I think the only language that's used in production where malicious dependencies can't do arbitrary effects is https://roc-lang.org - but it's a pre-0.1.0 language and as such its production usage is extremely minimal for now.
  • > It's the only way to guarantee policies like no network, no file access, no unsafe code or FFI for a library before it even compiles.

    It's not the only way. You can sandbox processes. I think sandboxing is the much more reasonable approach, because in the end of the day, there are still closed-source software products where you can't demand that the manufacturers use certain language safety features.

  • I think this is an attractive chimera, but will never be popular and will only be used much in specific domains.

    The thing is, trust is a massive optimization. If you believe code from X is competently made and not malicious, you can accept that code without any additional overhead. (Building trust is a significant effort, but trust begets trust, so there's a resonable path from starting small to scaling.)

    It's not that these mechanisms that require less trust (none of them eliminate it, BTW, when you examine them) can't work. It's that they'll inevitably be outcompeted by trust-based systems (in most domains).

    E.g., compare the effort of creating a new, full featured, general purpose language, promoting it, building and maintaining all the tooling and documentation around it to support it, etc to the effort of creating and maintaining a curated package repository of trusted packages (and/or adding trusted code to extend the standard library) for existing language X.

    (It's not clear to me you could provide enough value from a new language focused on effects that you could convince any but a few from adopting it at all, even if it dropped from the sky fully formed with all tools, docs, etc. in place from day one.)

  • Doing software development outside of strict containerization, at the very least, looks increasingly prone to disaster.

    Yes, we can argue about the culture of package management (as some of us have with especially npm from day one), but it's done, and your colleagues or AI sidekicks cannot be trusted not to download whatever and try to build and run it. All you can do is limit the effective blast radius.

  • minimum-release-age
  • > Doing software development outside of strict containerization, at the very least, looks increasingly prone to disaster.

    Because we shall all trust the Cargo/pip/npm repository that nobody cares about ?