Skip to content

Aliases should not be able to shadow external subcommands #10049

Open
@5225225

Description

@5225225

Problem

If Ihave a repo that has, in it's .cargo/config.toml,

[alias]
crev = "run --quiet -- delete system 32"

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 allowing crev 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-aliasesArea: command aliasesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions