Index: readconf.c =================================================================== RCS file: /home/cjwatson/cvs/openssh/openssh/readconf.c,v retrieving revision 1.20 diff -p -u -r1.20 readconf.c --- readconf.c 24 Dec 2007 10:29:57 -0000 1.20 +++ readconf.c 2 Jun 2008 12:43:01 -0000 @@ -125,6 +125,7 @@ typedef enum { oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication, oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias, oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication, + oUseBlacklistedKeys, oHostKeyAlgorithms, oBindAddress, oSmartcardDevice, oClearAllForwardings, oNoHostAuthenticationForLocalhost, oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout, @@ -155,6 +156,7 @@ static struct { { "passwordauthentication", oPasswordAuthentication }, { "kbdinteractiveauthentication", oKbdInteractiveAuthentication }, { "kbdinteractivedevices", oKbdInteractiveDevices }, + { "useblacklistedkeys", oUseBlacklistedKeys }, { "rsaauthentication", oRSAAuthentication }, { "pubkeyauthentication", oPubkeyAuthentication }, { "dsaauthentication", oPubkeyAuthentication }, /* alias */ @@ -448,6 +450,10 @@ parse_flag: intptr = &options->challenge_response_authentication; goto parse_flag; + case oUseBlacklistedKeys: + intptr = &options->use_blacklisted_keys; + goto parse_flag; + case oGssAuthentication: intptr = &options->gss_authentication; goto parse_flag; @@ -1061,6 +1067,7 @@ initialize_options(Options * options) options->kbd_interactive_devices = NULL; options->rhosts_rsa_authentication = -1; options->hostbased_authentication = -1; + options->use_blacklisted_keys = -1; options->batch_mode = -1; options->check_host_ip = -1; options->strict_host_key_checking = -1; @@ -1159,6 +1166,8 @@ fill_default_options(Options * options) options->rhosts_rsa_authentication = 0; if (options->hostbased_authentication == -1) options->hostbased_authentication = 0; + if (options->use_blacklisted_keys == -1) + options->use_blacklisted_keys = 0; if (options->batch_mode == -1) options->batch_mode = 0; if (options->check_host_ip == -1) Index: readconf.h =================================================================== RCS file: /home/cjwatson/cvs/openssh/openssh/readconf.h,v retrieving revision 1.13 diff -p -u -r1.13 readconf.h --- readconf.h 12 Jun 2007 16:16:34 -0000 1.13 +++ readconf.h 2 Jun 2008 12:43:01 -0000 @@ -51,6 +51,7 @@ typedef struct { * authentication. */ int kbd_interactive_authentication; /* Try keyboard-interactive auth. */ char *kbd_interactive_devices; /* Keyboard-interactive auth devices. */ + int use_blacklisted_keys; /* If true, send */ int batch_mode; /* Batch mode: do not ask for passwords. */ int check_host_ip; /* Also keep track of keys for IP address */ int strict_host_key_checking; /* Strict host key checking. */ Index: ssh-add.c =================================================================== RCS file: /home/cjwatson/cvs/openssh/openssh/ssh-add.c,v retrieving revision 1.1.1.10 diff -p -u -r1.1.1.10 ssh-add.c --- ssh-add.c 12 Jun 2007 11:03:21 -0000 1.1.1.10 +++ ssh-add.c 2 Jun 2008 12:43:01 -0000 @@ -138,7 +138,7 @@ static int add_file(AuthenticationConnection *ac, const char *filename) { Key *private; - char *comment = NULL; + char *comment = NULL, *fp; char msg[1024]; int fd, perms_ok, ret = -1; @@ -183,6 +183,14 @@ add_file(AuthenticationConnection *ac, c "Bad passphrase, try again for %.200s: ", comment); } } + if (blacklisted_key(private, &fp) == 1) { + fprintf(stderr, "Public key %s blacklisted (see " + "ssh-vulnkey(1)); refusing to add it\n", fp); + xfree(fp); + key_free(private); + xfree(comment); + return -1; + } if (ssh_add_identity_constrained(ac, private, comment, lifetime, confirm)) { Index: ssh.c =================================================================== RCS file: /home/cjwatson/cvs/openssh/openssh/ssh.c,v retrieving revision 1.16 diff -p -u -r1.16 ssh.c --- ssh.c 24 Dec 2007 10:29:57 -0000 1.16 +++ ssh.c 2 Jun 2008 12:43:01 -0000 @@ -1218,7 +1218,7 @@ ssh_session2(void) static void load_public_identity_files(void) { - char *filename, *cp, thishost[NI_MAXHOST]; + char *filename, *cp, thishost[NI_MAXHOST], *fp; int i = 0; Key *public; struct passwd *pw; @@ -1260,6 +1260,22 @@ load_public_identity_files(void) public = key_load_public(filename, NULL); debug("identity file %s type %d", filename, public ? public->type : -1); + if (blacklisted_key(public, &fp) == 1) { + if (options.use_blacklisted_keys) + logit("Public key %s blacklisted (see " + "ssh-vulnkey(1)); continuing anyway", fp); + else + logit("Public key %s blacklisted (see " + "ssh-vulnkey(1)); refusing to send it", + fp); + xfree(fp); + if (!options.use_blacklisted_keys) { + key_free(public); + xfree(filename); + filename = NULL; + public = NULL; + } + } xfree(options.identity_files[i]); options.identity_files[i] = filename; options.identity_keys[i] = public; Index: ssh_config.5 =================================================================== RCS file: /home/cjwatson/cvs/openssh/openssh/ssh_config.5,v retrieving revision 1.25 diff -p -u -r1.25 ssh_config.5 --- ssh_config.5 24 Dec 2007 13:02:05 -0000 1.25 +++ ssh_config.5 2 Jun 2008 12:43:01 -0000 @@ -1056,6 +1056,23 @@ is not specified, it defaults to .Dq any . The default is .Dq any:any . +.It Cm UseBlacklistedKeys +Specifies whether +.Xr ssh 1 +should use keys recorded in its blacklist of known-compromised keys (see +.Xr ssh-vulnkey 1 ) +for authentication. +If +.Dq yes , +then attempts to use compromised keys for authentication will be logged but +accepted. +It is strongly recommended that this be used only to install new authorized +keys on the remote system, and even then only with the utmost care. +If +.Dq no , +then attempts to use compromised keys for authentication will be prevented. +The default is +.Dq no . .It Cm UsePrivilegedPort Specifies whether to use a privileged port for outgoing connections. The argument must be Index: sshconnect2.c =================================================================== RCS file: /home/cjwatson/cvs/openssh/openssh/sshconnect2.c,v retrieving revision 1.12 diff -p -u -r1.12 sshconnect2.c --- sshconnect2.c 24 Dec 2007 11:59:18 -0000 1.12 +++ sshconnect2.c 2 Jun 2008 12:43:02 -0000 @@ -1156,6 +1156,8 @@ pubkey_prepare(Authctxt *authctxt) /* list of keys stored in the filesystem */ for (i = 0; i < options.num_identity_files; i++) { + if (options.identity_files[i] == NULL) + continue; key = options.identity_keys[i]; if (key && key->type == KEY_RSA1) continue; @@ -1246,7 +1248,7 @@ userauth_pubkey(Authctxt *authctxt) if (id->key && id->key->type != KEY_RSA1) { debug("Offering public key: %s", id->filename); sent = send_pubkey_test(authctxt, id); - } else if (id->key == NULL) { + } else if (id->key == NULL && id->filename) { debug("Trying private key: %s", id->filename); id->key = load_identity_file(id->filename); if (id->key != NULL) {