Skip to content
Crypto Write-up Intermediate

CVE-2022-46176: Cargo does not check SSH host keys

Cargo did not verify SSH host keys when cloning indexes and dependencies over SSH, so it never detected a changed server key. An attacker positioned in the network could therefore perform a man-in-the-middle attack against Cargo users.

seclists.org

Published on seclists.org

The Rust Security Response WG was notified that Cargo did not perform SSH host key verification when cloning indexes and dependencies via SSH. An attacker could exploit this to perform man-in-the-middle (MITM) attacks.

The author, on seclists.org

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Cargo never implemented SSH host key verification, so it performed no validation of the server's public key.

Impact

Cargo users could be subjected to man-in-the-middle attacks, including those who only reach crates.io over SSH through a git url.insteadOf configuration.

What the attacker needed

Attacker in the network path; Cargo before 1.66.1; SSH used for index or dependencies

The fix

Rust 1.66.1 was released to make Cargo check the SSH host key and abort the connection when the server's key is not already trusted.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When your computer connects to a server over SSH, it should remember the server's identity (its public key) and warn you if that identity changes, because a change can mean someone is intercepting the connection. Cargo, the tool that downloads Rust code packages, skipped this check entirely. That meant an attacker sitting between you and the server could pretend to be the server and feed you malicious code.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.