Skip to content

Commit 82662d5

Browse files
committed
upstream: ssh-agent implemented an all-or-nothing allow-list of
FIDO application IDs for security key-backed keys, to prevent web key handles from being used remotely as this would likely lead to unpleasant surprises. By default, only application IDs that start with "ssh:*" are allowed. This adds a -Owebsafe-allow=... argument that can override the default list with a more or less restrictive one. The default remains unchanged. ok markus@ OpenBSD-Commit-ID: 957c1ed92a8d7c87453b9341f70cb3f4e6b23e8d
1 parent 593a0b6 commit 82662d5

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

ssh-agent.1

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" $OpenBSD: ssh-agent.1,v 1.80 2024/10/24 03:15:47 djm Exp $
1+
.\" $OpenBSD: ssh-agent.1,v 1.81 2024/11/06 22:51:26 djm Exp $
22
.\"
33
.\" Author: Tatu Ylonen <[email protected]>
44
.\" Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
@@ -34,7 +34,7 @@
3434
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3535
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
.\"
37-
.Dd $Mdocdate: October 24 2024 $
37+
.Dd $Mdocdate: November 6 2024 $
3838
.Dt SSH-AGENT 1
3939
.Os
4040
.Sh NAME
@@ -107,10 +107,11 @@ environment variable).
107107
.It Fl O Ar option
108108
Specify an option when starting
109109
.Nm .
110-
Currently two options are supported:
111-
.Cm allow-remote-pkcs11
110+
The supported options are:
111+
.Cm allow-remote-pkcs11 ,
112+
.Cm no-restrict-websafe
112113
and
113-
.Cm no-restrict-websafe .
114+
.Cm websafe-allow .
114115
.Pp
115116
The
116117
.Cm allow-remote-pkcs11
@@ -143,6 +144,16 @@ user authentication request or a
143144
signature.
144145
The default behaviour prevents forwarded access to a FIDO key from also
145146
implicitly forwarding the ability to authenticate to websites.
147+
.Pp
148+
Alternately the
149+
.Cm websafe-allow
150+
option allows specifying a pattern-list of key application strings to
151+
replace the default application allow-list, for example:
152+
.Dq websafe-allow=ssh:*,example.org,*.example.com
153+
.Pp
154+
See PATTERNS in
155+
.Xr ssh_config 5
156+
for a description of pattern-list syntax.
146157
.It Fl P Ar allowed_providers
147158
Specify a pattern-list of acceptable paths for PKCS#11 provider and FIDO
148159
authenticator middleware shared libraries that may be used with the
@@ -152,11 +163,12 @@ or
152163
options to
153164
.Xr ssh-add 1 .
154165
Libraries that do not match the pattern list will be refused.
166+
The default list is
167+
.Dq usr/lib*/*,/usr/local/lib*/* .
168+
.Pp
155169
See PATTERNS in
156170
.Xr ssh_config 5
157171
for a description of pattern-list syntax.
158-
The default list is
159-
.Dq usr/lib*/*,/usr/local/lib*/* .
160172
.It Fl s
161173
Generate Bourne shell commands on
162174
.Dv stdout .

ssh-agent.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: ssh-agent.c,v 1.308 2024/10/24 03:15:47 djm Exp $ */
1+
/* $OpenBSD: ssh-agent.c,v 1.309 2024/11/06 22:51:26 djm Exp $ */
22
/*
33
* Author: Tatu Ylonen <[email protected]>
44
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
@@ -94,6 +94,9 @@
9494
#ifndef DEFAULT_ALLOWED_PROVIDERS
9595
# define DEFAULT_ALLOWED_PROVIDERS "/usr/lib*/*,/usr/local/lib*/*"
9696
#endif
97+
#ifndef DEFAULT_WEBSAFE_ALLOWLIST
98+
# define DEFAULT_WEBSAFE_ALLOWLIST "ssh:*"
99+
#endif
97100

98101
/* Maximum accepted message length */
99102
#define AGENT_MAX_LEN (256*1024)
@@ -198,6 +201,7 @@ static int fingerprint_hash = SSH_FP_HASH_DEFAULT;
198201

199202
/* Refuse signing of non-SSH messages for web-origin FIDO keys */
200203
static int restrict_websafe = 1;
204+
static char *websafe_allowlist;
201205

202206
static void
203207
close_socket(SocketEntry *e)
@@ -925,7 +929,8 @@ process_sign_request2(SocketEntry *e)
925929
}
926930
if (sshkey_is_sk(id->key)) {
927931
if (restrict_websafe &&
928-
strncmp(id->key->sk_application, "ssh:", 4) != 0 &&
932+
match_pattern_list(id->key->sk_application,
933+
websafe_allowlist, 0) != 1 &&
929934
!check_websafe_message_contents(key, data)) {
930935
/* error already logged */
931936
goto send;
@@ -2212,6 +2217,7 @@ main(int ac, char **av)
22122217
int c_flag = 0, d_flag = 0, D_flag = 0, k_flag = 0, s_flag = 0;
22132218
int sock, ch, result, saved_errno;
22142219
char *shell, *format, *pidstr, *agentsocket = NULL;
2220+
const char *ccp;
22152221
#ifdef HAVE_SETRLIMIT
22162222
struct rlimit rlim;
22172223
#endif
@@ -2264,7 +2270,12 @@ main(int ac, char **av)
22642270
restrict_websafe = 0;
22652271
else if (strcmp(optarg, "allow-remote-pkcs11") == 0)
22662272
remote_add_provider = 1;
2267-
else
2273+
else if ((ccp = strprefix(optarg,
2274+
"websafe-allow=", 0)) != NULL) {
2275+
if (websafe_allowlist != NULL)
2276+
fatal("websafe-allow already set");
2277+
websafe_allowlist = xstrdup(ccp);
2278+
} else
22682279
fatal("Unknown -O option");
22692280
break;
22702281
case 'P':
@@ -2308,6 +2319,8 @@ main(int ac, char **av)
23082319

23092320
if (allowed_providers == NULL)
23102321
allowed_providers = xstrdup(DEFAULT_ALLOWED_PROVIDERS);
2322+
if (websafe_allowlist == NULL)
2323+
websafe_allowlist = xstrdup(DEFAULT_WEBSAFE_ALLOWLIST);
23112324

23122325
if (ac == 0 && !c_flag && !s_flag) {
23132326
shell = getenv("SHELL");

0 commit comments

Comments
 (0)