-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Cargo built-in Git/SSH client doesn't support @cert-authority #11577
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-documenting-cargo-itselfArea: Cargo's documentationArea: Cargo's documentationA-gitArea: anything dealing with gitArea: anything dealing with gitA-networkingArea: networking issues, curl, etc.Area: networking issues, curl, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`E-mediumExperience: MediumExperience: MediumS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-documenting-cargo-itselfArea: Cargo's documentationArea: Cargo's documentationA-gitArea: anything dealing with gitArea: anything dealing with gitA-networkingArea: networking issues, curl, etc.Area: networking issues, curl, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`E-mediumExperience: MediumExperience: MediumS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Type
Fields
Give feedbackNo fields configured for issues without a type.
Edited: for remaining tasks, see #11577 (comment).
Problem
Cargo parses SSH known hosts file. From the Cargo book (https://doc.rust-lang.org/cargo/appendix/git-authentication.html#ssh-known-hosts):
However, there are some additional markers supported by at least some SSH clients (e.g. OpenSSH) to handle more complex cases than verifying a host via a single algorithm/key. The known ones are:
@cert-authority@revokedThe Cargo SSH client doesn't support these directives. It is quite explicit about this in the code:
cargo/src/cargo/sources/git/known_hosts.rs
Lines 490 to 493 in 1cd6d38
With the release of Rust 1.66.1 and the fix for CVE-2022-46176 (security advisory), Cargo is now performing host key checking, which will lead to more users needing this functionality because single host key verification may not be practical.
Proposed Solution
The solution to this issue would be to implement the missing support for the
@cert-authorityor@revokedmarkers.There is useful documentation on these markers from the OpenSSH project:
sshdSSH_KNOWN_HOSTS FILE FORMAT: https://man.openbsd.org/sshd#SSH_KNOWN_HOSTS_FILE_FORMAT (from @weihanglo's comment)This issue can be mitigated by telling cargo to use the command line Git client (
net.git-fetch-with-cli = true) as mentioned by @weihanglo on this Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Cargo.20SSH.20host.20key.20verification.20with.20.40cert-authority.20linesAs mentioned on that thread, a good mitigation step would be to add some text to the Cargo book section on SSH Known Hosts to suggest that users try
net.git-fetch-with-cli = trueif they find that Cargo's SSH behaviour is different to what they expect or different to how their command line Git client behaves.Notes
Some further useful resources that I found related to creating an SSH Certificate Authority (CA) and then specifying it in the SSH Known Hosts file: