panamax-rs / panamax

Mirror rustup and crates.io repositories, for offline Rust and cargo usage.
Apache License 2.0
443 stars 46 forks source link

Crate whitelisting #109

Closed SoulSharer closed 1 year ago

SoulSharer commented 1 year ago

First of all I would like to say thanks to everyone who contributed to this project and its original author! This project helped a lot with furthering adoption in restricted environments.

Potential security issues with downloading arbitrary crates from crates.io is a concern for most companies trying to adopt Rust. If anything history teaches us, it is easy to push malicious software into open registries and to receive malicious dependencies without notice. NPM registry is famous for these kinds of problems.

I'm thinking to implement whitelisting for crates, so that only a subset of crates.io could be downloaded for offline mirroring for the sake of security.

How I see this working

[crates.whitelist]
some-crate = { version = "1.2.3" } # download only 1.2.3 version
some-crate = { version = "^2.0.0" } # download everything up to 2.0.0 (inclusive)
some-crate = { version = "1.2.3", deps-download = false } # prevent dependency downloading

[crates.blacklist]
#  Possibility in the future

Downsides

The downside of this approach is that:

  1. It can be tedious to list all the crates manually and update their version ranges every time. https://github.com/panamax-rs/panamax/issues/106
  2. We can still hit issue with security by blindly downloading all dependency up to a last specified in deps index

Any thoughts on the matter are welcome!

SoulSharer commented 1 year ago

It's been almost a month, closing, since I won't have time to devote to this.