|
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 $ */ |
2 | 2 | /*
|
3 | 3 | * Author: Tatu Ylonen <[email protected]>
|
4 | 4 | * Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
|
|
94 | 94 | #ifndef DEFAULT_ALLOWED_PROVIDERS
|
95 | 95 | # define DEFAULT_ALLOWED_PROVIDERS "/usr/lib*/*,/usr/local/lib*/*"
|
96 | 96 | #endif
|
| 97 | +#ifndef DEFAULT_WEBSAFE_ALLOWLIST |
| 98 | +# define DEFAULT_WEBSAFE_ALLOWLIST "ssh:*" |
| 99 | +#endif |
97 | 100 |
|
98 | 101 | /* Maximum accepted message length */
|
99 | 102 | #define AGENT_MAX_LEN (256*1024)
|
@@ -198,6 +201,7 @@ static int fingerprint_hash = SSH_FP_HASH_DEFAULT;
|
198 | 201 |
|
199 | 202 | /* Refuse signing of non-SSH messages for web-origin FIDO keys */
|
200 | 203 | static int restrict_websafe = 1;
|
| 204 | +static char *websafe_allowlist; |
201 | 205 |
|
202 | 206 | static void
|
203 | 207 | close_socket(SocketEntry *e)
|
@@ -925,7 +929,8 @@ process_sign_request2(SocketEntry *e)
|
925 | 929 | }
|
926 | 930 | if (sshkey_is_sk(id->key)) {
|
927 | 931 | 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 && |
929 | 934 | !check_websafe_message_contents(key, data)) {
|
930 | 935 | /* error already logged */
|
931 | 936 | goto send;
|
@@ -2212,6 +2217,7 @@ main(int ac, char **av)
|
2212 | 2217 | int c_flag = 0, d_flag = 0, D_flag = 0, k_flag = 0, s_flag = 0;
|
2213 | 2218 | int sock, ch, result, saved_errno;
|
2214 | 2219 | char *shell, *format, *pidstr, *agentsocket = NULL;
|
| 2220 | + const char *ccp; |
2215 | 2221 | #ifdef HAVE_SETRLIMIT
|
2216 | 2222 | struct rlimit rlim;
|
2217 | 2223 | #endif
|
@@ -2264,7 +2270,12 @@ main(int ac, char **av)
|
2264 | 2270 | restrict_websafe = 0;
|
2265 | 2271 | else if (strcmp(optarg, "allow-remote-pkcs11") == 0)
|
2266 | 2272 | 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 |
2268 | 2279 | fatal("Unknown -O option");
|
2269 | 2280 | break;
|
2270 | 2281 | case 'P':
|
@@ -2308,6 +2319,8 @@ main(int ac, char **av)
|
2308 | 2319 |
|
2309 | 2320 | if (allowed_providers == NULL)
|
2310 | 2321 | allowed_providers = xstrdup(DEFAULT_ALLOWED_PROVIDERS);
|
| 2322 | + if (websafe_allowlist == NULL) |
| 2323 | + websafe_allowlist = xstrdup(DEFAULT_WEBSAFE_ALLOWLIST); |
2311 | 2324 |
|
2312 | 2325 | if (ac == 0 && !c_flag && !s_flag) {
|
2313 | 2326 | shell = getenv("SHELL");
|
|
0 commit comments