Skip to content

Commit d7790cd

Browse files
committed
disallow remote addition of FIDO/PKCS11 keys
Depends on the local client performing the [email protected] operation, so non-OpenSSH local client may circumvent this.
1 parent b23fe83 commit d7790cd

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

ssh-agent.1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,27 @@ environment variable).
107107
.It Fl O Ar option
108108
Specify an option when starting
109109
.Nm .
110-
Currently only one option is supported:
110+
Currently two options are supported:
111+
.Cm allow-remote-pkcs11
112+
and
111113
.Cm no-restrict-websafe .
112-
This instructs
114+
.Pp
115+
The
116+
.Cm allow-remote-pkcs11
117+
option allows clients of a forwarded
118+
.Nm
119+
to load PKCS#11 or FIDO provider libraries.
120+
By default only local clients may perform this operation.
121+
Note that signalling that a
122+
.Nm
123+
client remote is performed by
124+
.Xr ssh 1 ,
125+
and use of other tools to forward access to the agent socket may circumvent
126+
this restriction.
127+
.Pp
128+
The
129+
.Cm no-restrict-websafe ,
130+
instructs
113131
.Nm
114132
to permit signatures using FIDO keys that might be web authentication
115133
requests.

ssh-agent.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ char socket_dir[PATH_MAX];
169169
/* Pattern-list of allowed PKCS#11/Security key paths */
170170
static char *allowed_providers;
171171

172+
/*
173+
* Allows PKCS11 providers or SK keys that use non-internal providers to
174+
* be added over a remote connection (identified by [email protected]).
175+
*/
176+
static int remote_add_provider;
177+
172178
/* locking */
173179
#define LOCK_SIZE 32
174180
#define LOCK_SALT_SIZE 16
@@ -1228,6 +1234,12 @@ process_add_identity(SocketEntry *e)
12281234
if (strcasecmp(sk_provider, "internal") == 0) {
12291235
debug_f("internal provider");
12301236
} else {
1237+
if (e->nsession_ids != 0 && !remote_add_provider) {
1238+
verbose("failed add of SK provider \"%.100s\": "
1239+
"remote addition of providers is disabled",
1240+
sk_provider);
1241+
goto out;
1242+
}
12311243
if (realpath(sk_provider, canonical_provider) == NULL) {
12321244
verbose("failed provider \"%.100s\": "
12331245
"realpath: %s", sk_provider,
@@ -1391,6 +1403,11 @@ process_add_smartcard_key(SocketEntry *e)
13911403
error_f("failed to parse constraints");
13921404
goto send;
13931405
}
1406+
if (e->nsession_ids != 0 && !remote_add_provider) {
1407+
verbose("failed PKCS#11 add of \"%.100s\": remote addition of "
1408+
"providers is disabled", provider);
1409+
goto send;
1410+
}
13941411
if (realpath(provider, canonical_provider) == NULL) {
13951412
verbose("failed PKCS#11 add of \"%.100s\": realpath: %s",
13961413
provider, strerror(errno));
@@ -2050,7 +2067,9 @@ main(int ac, char **av)
20502067
break;
20512068
case 'O':
20522069
if (strcmp(optarg, "no-restrict-websafe") == 0)
2053-
restrict_websafe = 0;
2070+
restrict_websafe = 0;
2071+
else if (strcmp(optarg, "allow-remote-pkcs11") == 0)
2072+
remote_add_provider = 1;
20542073
else
20552074
fatal("Unknown -O option");
20562075
break;

0 commit comments

Comments
 (0)