]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
disallow remote addition of FIDO/PKCS11 keys
authorDamien Miller <djm@mindrot.org>
Fri, 7 Jul 2023 03:30:15 +0000 (13:30 +1000)
committerDamien Miller <djm@mindrot.org>
Wed, 19 Jul 2023 06:24:00 +0000 (16:24 +1000)
Depends on the local client performing the session-bind@openssh.com
operation, so non-OpenSSH local client may circumvent this.

ssh-agent.1
ssh-agent.c

index b0bf65da88ef0c551ca1589839ad363923d379be..97f4cab04d2bafee71e20d25b371564dde79133b 100644 (file)
@@ -107,9 +107,27 @@ environment variable).
 .It Fl O Ar option
 Specify an option when starting
 .Nm .
-Currently only one option is supported:
+Currently two options are supported:
+.Cm allow-remote-pkcs11
+and
 .Cm no-restrict-websafe .
-This instructs
+.Pp
+The
+.Cm allow-remote-pkcs11
+option allows clients of a forwarded
+.Nm
+to load PKCS#11 or FIDO provider libraries.
+By default only local clients may perform this operation.
+Note that signalling that a
+.Nm
+client remote is performed by
+.Xr ssh 1 ,
+and use of other tools to forward access to the agent socket may circumvent
+this restriction.
+.Pp
+The
+.Cm no-restrict-websafe ,
+instructs
 .Nm
 to permit signatures using FIDO keys that might be web authentication
 requests.
index 618bb198190e712f32598624eb4b0272476e8678..8ea831f48166e0f3a16e8552590425f7a6fe8939 100644 (file)
@@ -169,6 +169,12 @@ char socket_dir[PATH_MAX];
 /* Pattern-list of allowed PKCS#11/Security key paths */
 static char *allowed_providers;
 
+/*
+ * Allows PKCS11 providers or SK keys that use non-internal providers to
+ * be added over a remote connection (identified by session-bind@openssh.com).
+ */
+static int remote_add_provider;
+
 /* locking */
 #define LOCK_SIZE      32
 #define LOCK_SALT_SIZE 16
@@ -1228,6 +1234,12 @@ process_add_identity(SocketEntry *e)
                if (strcasecmp(sk_provider, "internal") == 0) {
                        debug_f("internal provider");
                } else {
+                       if (e->nsession_ids != 0 && !remote_add_provider) {
+                               verbose("failed add of SK provider \"%.100s\": "
+                                   "remote addition of providers is disabled",
+                                   sk_provider);
+                               goto out;
+                       }
                        if (realpath(sk_provider, canonical_provider) == NULL) {
                                verbose("failed provider \"%.100s\": "
                                    "realpath: %s", sk_provider,
@@ -1391,6 +1403,11 @@ process_add_smartcard_key(SocketEntry *e)
                error_f("failed to parse constraints");
                goto send;
        }
+       if (e->nsession_ids != 0 && !remote_add_provider) {
+               verbose("failed PKCS#11 add of \"%.100s\": remote addition of "
+                   "providers is disabled", provider);
+               goto send;
+       }
        if (realpath(provider, canonical_provider) == NULL) {
                verbose("failed PKCS#11 add of \"%.100s\": realpath: %s",
                    provider, strerror(errno));
@@ -2050,7 +2067,9 @@ main(int ac, char **av)
                        break;
                case 'O':
                        if (strcmp(optarg, "no-restrict-websafe") == 0)
-                               restrict_websafe  = 0;
+                               restrict_websafe = 0;
+                       else if (strcmp(optarg, "allow-remote-pkcs11") == 0)
+                               remote_add_provider = 1;
                        else
                                fatal("Unknown -O option");
                        break;