|
Dmitry Belyavskiy |
c3494f |
diff --git a/ssh-agent.c b/ssh-agent.c
|
|
Dmitry Belyavskiy |
c3494f |
index 618bb198..8ea831f4 100644
|
|
Dmitry Belyavskiy |
c3494f |
diff -up openssh-9.3p1/ssh-agent.c.cve openssh-9.3p1/ssh-agent.c
|
|
Dmitry Belyavskiy |
c3494f |
--- openssh-9.3p1/ssh-agent.c.cve 2023-07-21 15:38:13.237276580 +0200
|
|
Dmitry Belyavskiy |
c3494f |
+++ openssh-9.3p1/ssh-agent.c 2023-07-21 15:41:30.269943569 +0200
|
|
Dmitry Belyavskiy |
c3494f |
@@ -169,6 +169,12 @@ char socket_dir[PATH_MAX];
|
|
Dmitry Belyavskiy |
c3494f |
/* Pattern-list of allowed PKCS#11/Security key paths */
|
|
Dmitry Belyavskiy |
c3494f |
static char *allowed_providers;
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
+/*
|
|
Dmitry Belyavskiy |
c3494f |
+ * Allows PKCS11 providers or SK keys that use non-internal providers to
|
|
Dmitry Belyavskiy |
c3494f |
+ * be added over a remote connection (identified by session-bind@openssh.com).
|
|
Dmitry Belyavskiy |
c3494f |
+ */
|
|
Dmitry Belyavskiy |
c3494f |
+static int remote_add_provider;
|
|
Dmitry Belyavskiy |
c3494f |
+
|
|
Dmitry Belyavskiy |
c3494f |
/* locking */
|
|
Dmitry Belyavskiy |
c3494f |
#define LOCK_SIZE 32
|
|
Dmitry Belyavskiy |
c3494f |
#define LOCK_SALT_SIZE 16
|
|
Dmitry Belyavskiy |
c3494f |
@@ -1228,6 +1234,12 @@ process_add_identity(SocketEntry *e)
|
|
Dmitry Belyavskiy |
c3494f |
if (strcasecmp(sk_provider, "internal") == 0) {
|
|
Dmitry Belyavskiy |
c3494f |
debug_f("internal provider");
|
|
Dmitry Belyavskiy |
c3494f |
} else {
|
|
Dmitry Belyavskiy |
c3494f |
+ if (e->nsession_ids != 0 && !remote_add_provider) {
|
|
Dmitry Belyavskiy |
c3494f |
+ verbose("failed add of SK provider \"%.100s\": "
|
|
Dmitry Belyavskiy |
c3494f |
+ "remote addition of providers is disabled",
|
|
Dmitry Belyavskiy |
c3494f |
+ sk_provider);
|
|
Dmitry Belyavskiy |
c3494f |
+ goto out;
|
|
Dmitry Belyavskiy |
c3494f |
+ }
|
|
Dmitry Belyavskiy |
c3494f |
if (realpath(sk_provider, canonical_provider) == NULL) {
|
|
Dmitry Belyavskiy |
c3494f |
verbose("failed provider \"%.100s\": "
|
|
Dmitry Belyavskiy |
c3494f |
"realpath: %s", sk_provider,
|
|
Dmitry Belyavskiy |
c3494f |
@@ -1368,7 +1380,7 @@ no_identities(SocketEntry *e)
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
#ifdef ENABLE_PKCS11
|
|
Dmitry Belyavskiy |
c3494f |
static char *
|
|
Dmitry Belyavskiy |
c3494f |
-sanitize_pkcs11_provider(const char *provider)
|
|
Dmitry Belyavskiy |
c3494f |
+sanitize_pkcs11_provider(SocketEntry *e, const char *provider)
|
|
Dmitry Belyavskiy |
c3494f |
{
|
|
Dmitry Belyavskiy |
c3494f |
struct pkcs11_uri *uri = NULL;
|
|
Dmitry Belyavskiy |
c3494f |
char *sane_uri, *module_path = NULL; /* default path */
|
|
Dmitry Belyavskiy |
c3494f |
@@ -1399,6 +1411,11 @@ sanitize_pkcs11_provider(const char *pro
|
|
Dmitry Belyavskiy |
c3494f |
module_path = strdup(provider); /* simple path */
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
if (module_path != NULL) { /* do not validate default NULL path in URI */
|
|
Dmitry Belyavskiy |
c3494f |
+ if (e->nsession_ids != 0 && !remote_add_provider) {
|
|
Dmitry Belyavskiy |
c3494f |
+ verbose("failed PKCS#11 add of \"%.100s\": remote addition of "
|
|
Dmitry Belyavskiy |
c3494f |
+ "providers is disabled", provider);
|
|
Dmitry Belyavskiy |
c3494f |
+ return NULL;
|
|
Dmitry Belyavskiy |
c3494f |
+ }
|
|
Dmitry Belyavskiy |
c3494f |
if (realpath(module_path, canonical_provider) == NULL) {
|
|
Dmitry Belyavskiy |
c3494f |
verbose("failed PKCS#11 provider \"%.100s\": realpath: %s",
|
|
Dmitry Belyavskiy |
c3494f |
module_path, strerror(errno));
|
|
Dmitry Belyavskiy |
c3494f |
@@ -1455,7 +1472,7 @@ process_add_smartcard_key(SocketEntry *e
|
|
Dmitry Belyavskiy |
c3494f |
goto send;
|
|
Dmitry Belyavskiy |
c3494f |
}
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
- sane_uri = sanitize_pkcs11_provider(provider);
|
|
Dmitry Belyavskiy |
c3494f |
+ sane_uri = sanitize_pkcs11_provider(e, provider);
|
|
Dmitry Belyavskiy |
c3494f |
if (sane_uri == NULL)
|
|
Dmitry Belyavskiy |
c3494f |
goto send;
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
@@ -1516,7 +1533,7 @@ process_remove_smartcard_key(SocketEntry
|
|
Dmitry Belyavskiy |
c3494f |
}
|
|
Dmitry Belyavskiy |
c3494f |
free(pin);
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
- sane_uri = sanitize_pkcs11_provider(provider);
|
|
Dmitry Belyavskiy |
c3494f |
+ sane_uri = sanitize_pkcs11_provider(e, provider);
|
|
Dmitry Belyavskiy |
c3494f |
if (sane_uri == NULL)
|
|
Dmitry Belyavskiy |
c3494f |
goto send;
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
@@ -2108,7 +2125,9 @@ main(int ac, char **av)
|
|
Dmitry Belyavskiy |
c3494f |
break;
|
|
Dmitry Belyavskiy |
c3494f |
case 'O':
|
|
Dmitry Belyavskiy |
c3494f |
if (strcmp(optarg, "no-restrict-websafe") == 0)
|
|
Dmitry Belyavskiy |
c3494f |
- restrict_websafe = 0;
|
|
Dmitry Belyavskiy |
c3494f |
+ restrict_websafe = 0;
|
|
Dmitry Belyavskiy |
c3494f |
+ else if (strcmp(optarg, "allow-remote-pkcs11") == 0)
|
|
Dmitry Belyavskiy |
c3494f |
+ remote_add_provider = 1;
|
|
Dmitry Belyavskiy |
c3494f |
else
|
|
Dmitry Belyavskiy |
c3494f |
fatal("Unknown -O option");
|
|
Dmitry Belyavskiy |
c3494f |
break;
|
|
Dmitry Belyavskiy |
c3494f |
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c
|
|
Dmitry Belyavskiy |
c3494f |
index 6be647ec..ebddf6c3 100644
|
|
Dmitry Belyavskiy |
c3494f |
--- a/ssh-pkcs11.c
|
|
Dmitry Belyavskiy |
c3494f |
+++ b/ssh-pkcs11.c
|
|
Dmitry Belyavskiy |
c3494f |
@@ -1537,10 +1537,8 @@ pkcs11_register_provider(char *provider_id, char *pin,
|
|
Dmitry Belyavskiy |
c3494f |
error("dlopen %s failed: %s", provider_module, dlerror());
|
|
Dmitry Belyavskiy |
c3494f |
goto fail;
|
|
Dmitry Belyavskiy |
c3494f |
}
|
|
Dmitry Belyavskiy |
c3494f |
- if ((getfunctionlist = dlsym(handle, "C_GetFunctionList")) == NULL) {
|
|
Dmitry Belyavskiy |
c3494f |
- error("dlsym(C_GetFunctionList) failed: %s", dlerror());
|
|
Dmitry Belyavskiy |
c3494f |
- goto fail;
|
|
Dmitry Belyavskiy |
c3494f |
- }
|
|
Dmitry Belyavskiy |
c3494f |
+ if ((getfunctionlist = dlsym(handle, "C_GetFunctionList")) == NULL)
|
|
Dmitry Belyavskiy |
c3494f |
+ fatal("dlsym(C_GetFunctionList) failed: %s", dlerror());
|
|
Dmitry Belyavskiy |
c3494f |
|
|
Dmitry Belyavskiy |
c3494f |
p->module->handle = handle;
|
|
Dmitry Belyavskiy |
c3494f |
/* setup the pkcs11 callbacks */
|
|
Dmitry Belyavskiy |
c3494f |
--- a/ssh-agent.1 2023-03-15 22:28:19.000000000 +0100
|
|
Dmitry Belyavskiy |
c3494f |
+++ b/ssh-agent.1 2023-07-19 21:39:17.981406432 +0200
|
|
Dmitry Belyavskiy |
c3494f |
@@ -107,9 +107,27 @@
|
|
Dmitry Belyavskiy |
c3494f |
.It Fl O Ar option
|
|
Dmitry Belyavskiy |
c3494f |
Specify an option when starting
|
|
Dmitry Belyavskiy |
c3494f |
.Nm .
|
|
Dmitry Belyavskiy |
c3494f |
-Currently only one option is supported:
|
|
Dmitry Belyavskiy |
c3494f |
+Currently two options are supported:
|
|
Dmitry Belyavskiy |
c3494f |
+.Cm allow-remote-pkcs11
|
|
Dmitry Belyavskiy |
c3494f |
+and
|
|
Dmitry Belyavskiy |
c3494f |
.Cm no-restrict-websafe .
|
|
Dmitry Belyavskiy |
c3494f |
-This instructs
|
|
Dmitry Belyavskiy |
c3494f |
+.Pp
|
|
Dmitry Belyavskiy |
c3494f |
+The
|
|
Dmitry Belyavskiy |
c3494f |
+.Cm allow-remote-pkcs11
|
|
Dmitry Belyavskiy |
c3494f |
+option allows clients of a forwarded
|
|
Dmitry Belyavskiy |
c3494f |
+.Nm
|
|
Dmitry Belyavskiy |
c3494f |
+to load PKCS#11 or FIDO provider libraries.
|
|
Dmitry Belyavskiy |
c3494f |
+By default only local clients may perform this operation.
|
|
Dmitry Belyavskiy |
c3494f |
+Note that signalling that a
|
|
Dmitry Belyavskiy |
c3494f |
+.Nm
|
|
Dmitry Belyavskiy |
c3494f |
+client remote is performed by
|
|
Dmitry Belyavskiy |
c3494f |
+.Xr ssh 1 ,
|
|
Dmitry Belyavskiy |
c3494f |
+and use of other tools to forward access to the agent socket may circumvent
|
|
Dmitry Belyavskiy |
c3494f |
+this restriction.
|
|
Dmitry Belyavskiy |
c3494f |
+.Pp
|
|
Dmitry Belyavskiy |
c3494f |
+The
|
|
Dmitry Belyavskiy |
c3494f |
+.Cm no-restrict-websafe ,
|
|
Dmitry Belyavskiy |
c3494f |
+instructs
|
|
Dmitry Belyavskiy |
c3494f |
.Nm
|
|
Dmitry Belyavskiy |
c3494f |
to permit signatures using FIDO keys that might be web authentication
|
|
Dmitry Belyavskiy |
c3494f |
requests.
|