mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-12 08:43:53 -05:00
Allow manually confirming and caching certified keys.
In the case where a server presents a host key signed by a different certificate from the one you've configured, it need not _always_ be evidence of wrongdoing. I can imagine situations in which two CAs cover overlapping sets of things, and you don't want to blanket-trust one of them, but you do want to connect to a specific host signed by that one. Accordingly, PuTTY's previous policy of unconditionally aborting the connection if certificate validation fails (which was always intended as a stopgap until I thought through what I wanted to replace it with) is now replaced by fallback handling: we present the host key fingerprint to the user and give them the option to accept and/or cache it based on the public key itself. This means that the certified key types have to have a representation in the host key cache. So I've assigned each one a type id, and generate the cache string itself by simply falling back to the base key. (Rationale for the latter: re-signing a public key with a different certificate doesn't change the _private_ key, or the set of valid signatures generated with it. So if you've been convinced for reasons other than the certificate that a particular private key is in the possession of $host, then proof of ownership of that private key should be enough to convince you you're talking to $host no matter what CA has signed the public half this week.) We now offer to receive a given certified host key type if _either_ we have at least one CA configured to trust that host, _or_ we have a certified key of that type cached. (So once you've decided manually that you trust a particular key, we can still receive that key and authenticate the host with it, even if you later delete the CA record that it didn't match anyway.) One change from normal (uncertified) host key handling is that for certified key types _all_ the host key prompts use the stronger language, with "WARNING - POTENTIAL SECURITY BREACH!" rather than the mild 'hmm, we haven't seen this host before'. Rationale: if you expected this CA key and got that one, it _could_ be a bold-as-brass MITM attempt in which someone hoped you'd accept their entire CA key. The mild wording is only for the case where we had no previous expectations _at all_ for the host to violate: not a CA _or_ a cached key.
This commit is contained in:
50
ssh/common.c
50
ssh/common.c
@ -855,8 +855,8 @@ bool ssh2_bpp_check_unimplemented(BinaryPacketProtocol *bpp, PktIn *pktin)
|
||||
SeatPromptResult verify_ssh_host_key(
|
||||
InteractionReadySeat iseat, Conf *conf, const char *host, int port,
|
||||
ssh_key *key, const char *keytype, char *keystr, const char *keydisp,
|
||||
char **fingerprints, void (*callback)(void *ctx, SeatPromptResult result),
|
||||
void *ctx)
|
||||
char **fingerprints, int ca_count,
|
||||
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
|
||||
{
|
||||
/*
|
||||
* First, check if the Conf includes a manual specification of the
|
||||
@ -934,7 +934,51 @@ SeatPromptResult verify_ssh_host_key(
|
||||
seat_dialog_text_append(
|
||||
text, SDT_TITLE, "%s Security Alert", appname);
|
||||
|
||||
if (storage_status == 1) {
|
||||
if (key && ssh_key_alg(key)->is_certificate) {
|
||||
seat_dialog_text_append(
|
||||
text, SDT_SCARY_HEADING, "WARNING - POTENTIAL SECURITY BREACH!");
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "This server presented a certified host key:");
|
||||
seat_dialog_text_append(
|
||||
text, SDT_DISPLAY, "%s (port %d)", host, port);
|
||||
if (ca_count) {
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "which was signed by a different "
|
||||
"certification authority from the %s %s is configured to "
|
||||
"trust for this server.", ca_count > 1 ? "ones" : "one",
|
||||
appname);
|
||||
if (storage_status == 2) {
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "ALSO, that key does not match the key "
|
||||
"%s had previously cached for this server.", appname);
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "This means that either another "
|
||||
"certification authority is operating in this realm AND "
|
||||
"the server administrator has changed the host key, or "
|
||||
"you have actually connected to another computer "
|
||||
"pretending to be the server.");
|
||||
} else {
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "This means that either another "
|
||||
"certification authority is operating in this realm, or "
|
||||
"you have actually connected to another computer "
|
||||
"pretending to be the server.");
|
||||
}
|
||||
} else {
|
||||
assert(storage_status == 2);
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "which does not match the certified key %s "
|
||||
"had previously cached for this server.", appname);
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "This means that either the server "
|
||||
"administrator has changed the host key, or you have actually "
|
||||
"connected to another computer pretending to be the server.");
|
||||
}
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "The new %s key fingerprint is:", keytype);
|
||||
seat_dialog_text_append(
|
||||
text, SDT_DISPLAY, "%s", fingerprints[fptype_default]);
|
||||
} else if (storage_status == 1) {
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "The host key is not cached for this server:");
|
||||
seat_dialog_text_append(
|
||||
|
Reference in New Issue
Block a user