]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: security keys typically need to be tapped/touched in
authordjm@openbsd.org <djm@openbsd.org>
Tue, 12 Nov 2019 22:36:44 +0000 (22:36 +0000)
committerDamien Miller <djm@mindrot.org>
Tue, 12 Nov 2019 23:15:47 +0000 (10:15 +1100)
order to perform a signature operation. Notify the user when this is expected
via the TTY (if available) or $SSH_ASKPASS if we can.

ok markus@

OpenBSD-Commit-ID: 0ef90a99a85d4a2a07217a58efb4df8444818609

ssh-agent.c
ssh-keygen.c
sshconnect2.c

index dd9f85ae700dd84b782198aa2bde583e72419310..eb17b18b25fca435456e4a0436163a50deb7a2c1 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.240 2019/11/12 19:33:08 markus Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.241 2019/11/12 22:36:44 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -289,9 +289,10 @@ provider_sign(const char *provider, struct sshkey *key,
 {
        int status, pair[2], r = SSH_ERR_INTERNAL_ERROR;
        pid_t pid;
-       char *helper, *verbosity = NULL;
+       char *helper, *verbosity = NULL, *fp = NULL;
        struct sshbuf *kbuf, *req, *resp;
        u_char version;
+       struct notifier_ctx *notifier = NULL;
 
        debug3("%s: start for provider %s", __func__, provider);
 
@@ -344,10 +345,17 @@ provider_sign(const char *provider, struct sshkey *key,
                error("%s: send: %s", __func__, ssh_err(r));
                goto out;
        }
+       if ((fp = sshkey_fingerprint(key, SSH_FP_HASH_DEFAULT,
+           SSH_FP_DEFAULT)) == NULL)
+               fatal("%s: sshkey_fingerprint failed", __func__);
+       notifier = notify_start(0,
+           "Confirm user presence for key %s %s", sshkey_type(key), fp);
        if ((r = ssh_msg_recv(pair[0], resp)) != 0) {
                error("%s: receive: %s", __func__, ssh_err(r));
                goto out;
        }
+       notify_complete(notifier);
+       notifier = NULL;
        if ((r = sshbuf_get_u8(resp, &version)) != 0) {
                error("%s: parse version: %s", __func__, ssh_err(r));
                goto out;
@@ -375,6 +383,7 @@ provider_sign(const char *provider, struct sshkey *key,
                if (errno != EINTR)
                        fatal("%s: waitpid: %s", __func__, ssh_err(r));
        }
+       notify_complete(notifier);
        if (!WIFEXITED(status)) {
                error("%s: helper %s exited abnormally", __func__, helper);
                if (r == 0)
index 7b8dce7d8ae96c99975c71ea89774d466ba27d61..46d642e17fff031c3182cb383d25d3b1b039626f 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.362 2019/11/12 19:33:08 markus Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.363 2019/11/12 22:36:44 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2506,8 +2506,7 @@ sign_one(struct sshkey *signkey, const char *filename, int fd,
 {
        struct sshbuf *sigbuf = NULL, *abuf = NULL;
        int r = SSH_ERR_INTERNAL_ERROR, wfd = -1, oerrno;
-       char *wfile = NULL;
-       char *asig = NULL;
+       char *wfile = NULL, *asig = NULL, *fp = NULL;
 
        if (!quiet) {
                if (fd == STDIN_FILENO)
@@ -2515,6 +2514,15 @@ sign_one(struct sshkey *signkey, const char *filename, int fd,
                else
                        fprintf(stderr, "Signing file %s\n", filename);
        }
+       if (signer == NULL && sshkey_is_sk(signkey) &&
+           (signkey->sk_flags & SSH_SK_USER_PRESENCE_REQD)) {
+               if ((fp = sshkey_fingerprint(signkey, fingerprint_hash,
+                   SSH_FP_DEFAULT)) == NULL)
+                       fatal("%s: sshkey_fingerprint failed", __func__);
+               fprintf(stderr, "Confirm user presence for key %s %s\n",
+                   sshkey_type(signkey), fp);
+               free(fp);
+       }
        if ((r = sshsig_sign_fd(signkey, NULL, sk_provider, fd, sig_namespace,
            &sigbuf, signer, signer_ctx)) != 0) {
                error("Signing %s failed: %s", filename, ssh_err(r));
index 4e5cddf1403e56a93dd60b41918deedb9e53ac03..c8db626dfc6200aca4c1b25b82100f9e8fbd45b1 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshconnect2.c,v 1.311 2019/11/12 19:33:08 markus Exp $ */
+/* $OpenBSD: sshconnect2.c,v 1.312 2019/11/12 22:36:44 djm Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  * Copyright (c) 2008 Damien Miller.  All rights reserved.
@@ -73,6 +73,7 @@
 #include "ssherr.h"
 #include "utf8.h"
 #include "ssh-sk.h"
+#include "sk-api.h"
 
 #ifdef GSSAPI
 #include "ssh-gss.h"
@@ -1149,6 +1150,8 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
 {
        struct sshkey *sign_key = NULL, *prv = NULL;
        int r = SSH_ERR_INTERNAL_ERROR;
+       struct notifier_ctx *notifier = NULL;
+       char *fp = NULL;
 
        *sigp = NULL;
        *lenp = 0;
@@ -1177,12 +1180,24 @@ identity_sign(struct identity *id, u_char **sigp, size_t *lenp,
                        goto out;
                }
                sign_key = prv;
+               if (sshkey_is_sk(sign_key) &&
+                   (sign_key->sk_flags & SSH_SK_USER_PRESENCE_REQD)) {
+                       /* XXX match batch mode should just skip these keys? */
+                       if ((fp = sshkey_fingerprint(sign_key,
+                           options.fingerprint_hash, SSH_FP_DEFAULT)) == NULL)
+                               fatal("%s: sshkey_fingerprint", __func__);
+                       notifier = notify_start(options.batch_mode,
+                           "Confirm user presence for key %s %s",
+                           sshkey_type(sign_key), fp);
+                       free(fp);
+               }
        }
        if ((r = sshkey_sign(sign_key, sigp, lenp, data, datalen,
            alg, options.sk_provider, compat)) != 0) {
                debug("%s: sshkey_sign: %s", __func__, ssh_err(r));
                goto out;
        }
+       notify_complete(notifier);
        /*
         * PKCS#11 tokens may not support all signature algorithms,
         * so check what we get back.