Description
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):
When connecting to an SSH host, Cargo must verify the identity of the host using "known hosts", which are a list of host keys. Cargo can look for these known hosts in OpenSSH-style known_hosts files located in their standard locations ...
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
@revoked
The 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-authority
or @revoked
markers.
There is useful documentation on these markers from the OpenSSH project:
sshd
SSH_KNOWN_HOSTS FILE FORMAT: https://man.openbsd.org/sshd#SSH_KNOWN_HOSTS_FILE_FORMAT (from @weihanglo's comment)- Certificate format: https://cvsweb.openbsd.org/src/usr.bin/ssh/PROTOCOL.certkeys?annotate=HEAD (from @est31'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.20lines
As 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 = true
if 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: