Skip to content

Install cargo tools with locked dependencies - #161428

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
konstin:konsti/cargo-install-locked
Aug 22, 2026
Merged

Install cargo tools with locked dependencies#161428
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
konstin:konsti/cargo-install-locked

Conversation

@konstin

@konstin konstin commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Installing cargo tools (cargo install) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using cargo install --locked reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all rg "cargo install" hits in the repository and added --locked to all but explanatory examples (such as cargo's docs on cargo install itself). I validated that those tools publish functioning Cargo.locks with https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0.

Installing cargo tools (`cargo install`) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using `cargo install --locked` reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all `rg "cargo install"` hits in the repository and added `--locked` to all but explanatory examples. I validated that those tools publish functioning `Cargo.lock`s with https://gist.github.com/konstin/ef3412518e207bea6035a1bd01f3821b.
@rustbot

rustbot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

src/tools/x was changed. Bump version of Cargo.toml in src/tools/x so tidy will suggest installing the new version.

rustc-dev-guide is developed in its own repository. If possible, consider making this change to rust-lang/rustc-dev-guide instead.

cc @BoxyUwU, @tshepang

Some changes occurred in src/doc/rustc/src/platform-support

cc @Noratrieb

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

portable-simd is developed in its own repository. If possible, consider making this change to rust-lang/portable-simd instead.

cc @calebzulawski, @programmerjake

@rustbot

rustbot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @folkertdev (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Mark-Simulacrum, compiler
  • @Mark-Simulacrum, compiler expanded to 75 candidates
  • Random selection from 19 candidates

@rustbot rustbot added A-CI Area: Our Github Actions CI A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Aug 20, 2026
@konstin

konstin commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

I've pulled out the changes to rustc-dev-guide, rust-clippy, rust-analyzer, miri and portable-simd (and cargo which is a submodule anyway), but I'll hold off spamming PRs until I get an approval for this PR.

konstin added a commit to konstin/cargo that referenced this pull request Aug 20, 2026
Installing cargo tools (`cargo install`) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using `cargo install --locked` reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all `rg "cargo install"` hits in the rust-lang/rust and added `--locked` to all but explanatory examples (such as cargo's docs on `cargo install` itself). I validated that those tools publish functioning `Cargo.lock`s with https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0. These are the broken out changes for cargo.

rust-lang/rust#161428
konstin added a commit to konstin/cargo that referenced this pull request Aug 21, 2026
Installing cargo tools (`cargo install`) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using `cargo install --locked` reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all `rg "cargo install"` hits in the rust-lang/rust and added `--locked` to all but explanatory examples (such as cargo's docs on `cargo install` itself). I validated that those tools publish functioning `Cargo.lock`s with https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0. These are the broken out changes for cargo.

rust-lang/rust#161428
@blyxyas

blyxyas commented Aug 21, 2026

Copy link
Copy Markdown
Member

Can we remove those labels if the PR author removes the changes to the given subtrees?

@oli-obk oli-obk removed A-rustc-dev-guide Area: rustc-dev-guide T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. T-clippy Relevant to the Clippy team. labels Aug 21, 2026
@oli-obk

oli-obk commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Jup, done

weihanglo added a commit to weihanglo/cargo that referenced this pull request Aug 21, 2026
Installing cargo tools (`cargo install`) without locked dependencies
exposes users to supply-chain attacks to all the dependencies of the
tool
(https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/).
Using `cargo install --locked` reduces this risk to a compromise of the
tool itself, while using the locked and hashed version of the
dependencies.

I went through all `rg "cargo install"` hits in the rust-lang/rust and
added `--locked` to all but explanatory examples (such as cargo's docs
on `cargo install` itself). I validated that those tools publish
functioning `Cargo.lock`s with
https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0. These
are the broken out changes for cargo.

rust-lang/rust#161428
@tshepang

Copy link
Copy Markdown
Member

am happy for rustc-dev-guide to get changes such as these @konstin, even here

@folkertdev folkertdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7da027a has been approved by folkertdev

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2026
@RalfJung

Copy link
Copy Markdown
Member

I went through all rg "cargo install" hits in the repository and added --locked to all but explanatory examples

FWIW in Miri you only found 1/3 of those somehow, it seems.
I would accept a PR that adds --locked to all 3 of them. :)

rust-bors Bot pushed a commit that referenced this pull request Aug 22, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #161475 (Fix checking of LLVM prebuilt status)
 - #161269 (Remove `impl DebugWithContext for BorrowckDomain`)
 - #161419 (Doclink to `char::REPLACEMENT_CHARACTER` instead of `std::char::REPLACEMENT_CHARACTER`.)
 - #161428 (Install cargo tools with locked dependencies)
 - #161502 (Clean up a few `_inner` functions after `ensure_sufficient_stack`)
 - #161507 (Remove useless `!fields.is_empty()` check)
 - #161512 (enable next solver in Miri)
 - #161516 (Revert #161236 (Download auto jobs in citool in parallel))
 - #161518 (rename `T-libs-api` to `T-libs` in issue templates)
@rust-bors
rust-bors Bot merged commit 4b9f444 into rust-lang:main Aug 22, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 22, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 22, 2026
Rollup merge of #161428 - konstin:konsti/cargo-install-locked, r=folkertdev

Install cargo tools with locked dependencies

Installing cargo tools (`cargo install`) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using `cargo install --locked` reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all `rg "cargo install"` hits in the repository and added `--locked` to all but explanatory examples (such as cargo's docs on `cargo install` itself). I validated that those tools publish functioning `Cargo.lock`s with https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 23, 2026
…d, r=folkertdev

Install cargo tools with locked dependencies

Installing cargo tools (`cargo install`) without locked dependencies exposes users to supply-chain attacks to all the dependencies of the tool (https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/). Using `cargo install --locked` reduces this risk to a compromise of the tool itself, while using the locked and hashed version of the dependencies.

I went through all `rg "cargo install"` hits in the repository and added `--locked` to all but explanatory examples (such as cargo's docs on `cargo install` itself). I validated that those tools publish functioning `Cargo.lock`s with https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0.
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Aug 24, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#161475 (Fix checking of LLVM prebuilt status)
 - rust-lang/rust#161269 (Remove `impl DebugWithContext for BorrowckDomain`)
 - rust-lang/rust#161419 (Doclink to `char::REPLACEMENT_CHARACTER` instead of `std::char::REPLACEMENT_CHARACTER`.)
 - rust-lang/rust#161428 (Install cargo tools with locked dependencies)
 - rust-lang/rust#161502 (Clean up a few `_inner` functions after `ensure_sufficient_stack`)
 - rust-lang/rust#161507 (Remove useless `!fields.is_empty()` check)
 - rust-lang/rust#161512 (enable next solver in Miri)
 - rust-lang/rust#161516 (Revert rust-lang/rust#161236 (Download auto jobs in citool in parallel))
 - rust-lang/rust#161518 (rename `T-libs-api` to `T-libs` in issue templates)
yermakoffivan pushed a commit to yermakoffivan/rust-clippy that referenced this pull request Aug 30, 2026
Installing cargo tools (`cargo install`) without locked dependencies
exposes users to supply-chain attacks to all the dependencies of the
tool
(https://blog.rust-lang.org/2026/08/20/supply-chain-attack-on-arrayref/).
Using `cargo install --locked` reduces this risk to a compromise of the
tool itself, while using the locked and hashed version of the
dependencies.

I went through all `rg "cargo install"` hits in the repository and added
`--locked` to all but explanatory examples (such as cargo's docs on
`cargo install` itself). I validated that those tools publish
functioning `Cargo.lock`s with
https://gist.github.com/konstin/bcb1169c1c1120c259dca64e777a64d0.

See rust-lang/rust#161428.

changelog: none

<!-- homu-ignore:start -->
<!--
Please read our [LLM policy] before opening a PR,
If you used an LLM to generate any part of this PR, including the PR
description, please disclose that according to our
[guidelines][disclosure guidelines].
LLM contributions are not banned, but are held to a higher standard of
review and correctness.

[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html
[disclosure guidelines]:
https://rustc-dev-guide.rust-lang.org/llm-guidance/writing.html#disclosure-guidelines

If this PR is related to an unstable feature or an otherwise tracked
effort,
please link to the relevant tracking issue here. If you don't know of a
related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would
like
a specific user to review your work, you can assign it to them by using

    r? <reviewer name>

When merged, your PR's description becomes part of the commit message of
a merge commit.
If you do not want certain parts of it (such as your LLM disclosure) to
show up in the permanent git history,
surround them with a pair of HTML comments containing
`homu-ignore:start` and `homu-ignore:end`.
-->
<!-- homu-ignore:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants