Skip to content

test(git): Explicitly test for git injection attacks#17253

Merged
weihanglo merged 1 commit into
rust-lang:masterfrom
epage:cli-injection
Jul 22, 2026
Merged

test(git): Explicitly test for git injection attacks#17253
weihanglo merged 1 commit into
rust-lang:masterfrom
epage:cli-injection

Conversation

@epage

@epage epage commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

See https://nesbitt.io/2026/07/21/end-of-options.html

While Cargo does support using the git cli, we are not subject to this because

  • we require URLs to be used in the Cargo.toml, .cargo/config.toml parser for git sources
  • we always prefix branches, revs, and tags or don't use them

Tests are added to demonstrate this.
I wasn't exhaustive (patch, tag, more rev kinds) but figured this was approriate based on source code inspection.

There aren't any other user controlled parameters to git. It would be good to harden this with --end-of-options but we would then need to set a minimum git version so figured I'd pass for now as the needed versions aren't as universally available yet.

How to test and review this PR?

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 21, 2026
@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @epage, @weihanglo
  • @epage, @weihanglo expanded to epage, weihanglo

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a good read. Thanks.

View changes since this review

Comment thread tests/testsuite/git.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There aren't any other user controlled parameters to git. It would be good to harden this with --end-of-options but we would then need to set a minimum git version so figured I'd pass for now as the needed versions aren't as universally available yet.

This reminds me: What is the minimal supported Git version we have?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not aware of us specifying it or what it would be.

@weihanglo
weihanglo enabled auto-merge July 22, 2026 02:40
@rustbot

This comment has been minimized.

See https://nesbitt.io/2026/07/21/end-of-options.html

While Cargo does support using the git cli, we are not subject to this
because
- we require URLs to be used in the `Cargo.toml`, `.cargo/config.toml`
  parser for git sources
- we always prefix branches, revs, and tags or don't use them

Tests are added to demonstrate this.
I wasn't exhaustive (`patch`, `tag`, more `rev` kinds) but figured this
was approriate based on source code inspection.

There aren't any other user controlled parameters to git.
It would be good to harden this with `--end-of-options` but we would
then need to set a minimum git version so figured I'd pass for now as
the needed versions aren't as universally available yet.
@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@weihanglo
weihanglo disabled auto-merge July 22, 2026 13:53
@weihanglo
weihanglo enabled auto-merge July 22, 2026 13:53
@weihanglo
weihanglo added this pull request to the merge queue Jul 22, 2026
Merged via the queue into rust-lang:master with commit 2b63a6a Jul 22, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 22, 2026
@epage
epage deleted the cli-injection branch July 22, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants