-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aliases should not be able to shadow external subcommands #10049
Comments
In #9768 (comment) , we did agree that we want to do this. This would be a transition, since people might have such aliases today. So if someone wants to implement this, it would need to start with a warning, then a transition period, and then become an error. |
As per rust-lang#10049, we start by emitting a warning when an alias shadows an existing external subcommand. After a transition period (duration not specified), we will make this a hard error.
…ing, r=ehuss Warn when alias shadows external subcommand As per #10049, we start by emitting a warning when an alias shadows an existing external subcommand. After a transition period (duration not specified), we will make this a hard error. Should the warning mention that this will become a hard error?
I'm those people - I've been abusing shadowing external subcommands a lot. I have two main use cases:
(TL;DR: I can adapt, and I don't have a better alternative to recommend, but I at least want to complain 🤣) |
Maybe it should only apply to shadowing that exists in repos? Basically, introduce a distinction between "trusted config" and "untrusted config". Anything in $HOME/.cargo/config.toml is trusted. If you can write there, you can presumably write to .bashrc, and you're screwed if someone can do that. But don't trust any file that was..... loaded from a git repo? You'd also want a way to explicitly trust configuration / commands. Maybe a [trusted-configs]
"/home/$USER/src/some_project/project/.cargo/config" = "f52fbd32b2b3b86ff88ef6c490628285f482af15ddcb29541f94bcf526a3f6c7" (or maybe the hashing is too much of a source of complexity, and just say "if you trust it once, you trust everything that can be written into that path) And then a config is trusted if it is listed in a trusted configuration (that is loaded), and then whatever hard coded paths for the config (.cargo/config, /etc/cargo/config maybe idk if that exists) is then whatever starts out as trusted. This would be a big change, but it would perhaps be useful to gate some more dangerous functionality under? Though as I said above, you are running code, so there's not too much you can do that isn't instant ACE from a hostile codebase. |
FWIW, the security concern might be mitigated a bit after #10736 got merged. |
I see that #13629 proposes to turn this into a hard error. I don't know why now (it doesn't seem edition-dependent), but in any case: please don't do this before giving users a practical way to turn off this warning/error! Having to remove either the alias or the globally installed command is not very practical. I understand not trusting random checked out git repositories to shadow a command like
Keeping in mind the problem for tools like |
#2267 is our issue for running programs from your dependencies. That is blocked on the artifact-deps feature and needs design work. #12235 is our issue for user controlled lints. However, this is dependent on As for Editions, they cannot control the behavior of config unless we again find a way to re-frame things in terms of a workspace. We do allow changes outside of Editions under some circumstances. The justification for this was not given (unless I missed it) and I wasn't a part of the team at that time. However, we have been warning people about this for 3 years at this point (for context, this is longer than |
Problem
If Ihave a repo that has, in it's
.cargo/config.toml
,then running
cargo crev
in this crate will run repo-controlled code, which could be a security problem. Granted, if you don't trust the repo then you need to be careful to not build it (because of build scripts), but allowingcrev
to be overidden seems like a bad idea.Proposed Solution
Treat external subcommands (binaries with the name
cargo-<subcommand>
) the same as known subcommands for purposes of aliasing.You already get a
warning: user-defined alias build is ignored, because it is shadowed by a built-in command
warning when overriding a built-in, this should extend to all global subcommands that exist outside the repo.Notes
No response
The text was updated successfully, but these errors were encountered: