Skip to content

Commit d002ceb

Browse files
committed
Auto merge of #11889 - est31:revoke_old_github, r=ehuss
Add the old github keys as revoked The patch to update the bundled ssh github host key did not change anything for users who already had connected to github one time before via ssh: if the attacker had access to the old key, they'd be vulnerable to MITM attacks as their known_hosts file would list the old github key. Only if they connected again to github without attacker access, or if they saw the announcement of the key rotation, they would update their key. There is sadly no other way to distribute revocations of old host keys to clients other than to bundle them with client software. cc #11883
2 parents 7a598bf + cd654c7 commit d002ceb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/cargo/sources/git/known_hosts.rs

+24
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ static BUNDLED_KEYS: &[(&str, &str, &str)] = &[
4646
("github.com", "ssh-rsa", "AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk="),
4747
];
4848

49+
/// List of keys that public hosts have rotated away from.
50+
///
51+
/// We explicitly distrust these keys as users with the old key in their
52+
/// local configuration will otherwise be vulnerable to MITM attacks if the
53+
/// attacker has access to the old key. As there is no other way to distribute
54+
/// revocations of ssh host keys, we need to bundle them with the client.
55+
///
56+
/// Unlike [`BUNDLED_KEYS`], these revocations will not be ignored if the user
57+
/// has their own entries: we *know* that these keys are bad.
58+
static BUNDLED_REVOCATIONS: &[(&str, &str, &str)] = &[
59+
// Used until March 24, 2023: https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/
60+
("github.com", "ssh-rsa", "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="),
61+
];
62+
4963
enum KnownHostError {
5064
/// Some general error happened while validating the known hosts.
5165
CheckError(anyhow::Error),
@@ -357,6 +371,16 @@ fn check_ssh_known_hosts(
357371
});
358372
}
359373
}
374+
for (patterns, key_type, key) in BUNDLED_REVOCATIONS {
375+
let key = STANDARD.decode(key).unwrap();
376+
known_hosts.push(KnownHost {
377+
location: KnownHostLocation::Bundled,
378+
patterns: patterns.to_string(),
379+
key_type: key_type.to_string(),
380+
key,
381+
line_type: KnownHostLineType::Revoked,
382+
});
383+
}
360384
check_ssh_known_hosts_loaded(&known_hosts, host, remote_key_type, remote_host_key)
361385
}
362386

0 commit comments

Comments
 (0)