Separating fetching from building for better security

To clarify, if I have a dependency which checks their configs into source control and includes them in the published crate, cargo won't load them? Even if .cargo/config.toml includes a [patch] section, or something similar?

Regardless, it would be nice to know which cargo commands can execute arbitrary code vs. which commands can't, as it isn't obvious to me at first blush.

Correct. Config is for environmental / transient settings. It is dependent on the environment it is run from independent of the project. The one exception is cargo install which only loads user-wide config and not directory-config.

e.g. `cargo install` ignores `.cargo/config.toml`, making packages publishable-but-unbuildable, allthewhile they work when built normally · Issue #14001 · rust-lang/cargo · GitHub

Most commands are likely to invoke rustc at some point (e.g. cargo metadata fails if rustc not in the path · Issue #8219 · rust-lang/cargo · GitHub ) and the rustc binary can be controlled by config.

So there are two parts to this

2 Likes