-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: add a RequiredRSASize for checking RSA key length in
ssh(1). User authentication keys that fall beneath this limit will be ignored. If a host presents a host key beneath this limit then the connection will be terminated (unfortunately there are no fallbacks in the protocol for host authentication). feedback deraadt, Dmitry Belyavskiy; ok markus@ OpenBSD-Commit-ID: 430e339b2a79fa9ecc63f2837b06fdd88a7da13a
- Loading branch information
Showing
6 changed files
with
67 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: readconf.c,v 1.368 2022/06/03 04:30:47 djm Exp $ */ | ||
/* $OpenBSD: readconf.c,v 1.369 2022/09/17 10:33:18 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -174,7 +174,7 @@ typedef enum { | |
oStreamLocalBindMask, oStreamLocalBindUnlink, oRevokedHostKeys, | ||
oFingerprintHash, oUpdateHostkeys, oHostbasedAcceptedAlgorithms, | ||
oPubkeyAcceptedAlgorithms, oCASignatureAlgorithms, oProxyJump, | ||
oSecurityKeyProvider, oKnownHostsCommand, | ||
oSecurityKeyProvider, oKnownHostsCommand, oRequiredRSASize, | ||
oIgnore, oIgnoredUnknownOption, oDeprecated, oUnsupported | ||
} OpCodes; | ||
|
||
|
@@ -320,6 +320,7 @@ static struct { | |
{ "proxyjump", oProxyJump }, | ||
{ "securitykeyprovider", oSecurityKeyProvider }, | ||
{ "knownhostscommand", oKnownHostsCommand }, | ||
{ "requiredrsasize", oRequiredRSASize }, | ||
|
||
{ NULL, oBadOption } | ||
}; | ||
|
@@ -2176,6 +2177,10 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host, | |
*charptr = xstrdup(arg); | ||
break; | ||
|
||
case oRequiredRSASize: | ||
intptr = &options->required_rsa_size; | ||
goto parse_int; | ||
|
||
case oDeprecated: | ||
debug("%s line %d: Deprecated option \"%s\"", | ||
filename, linenum, keyword); | ||
|
@@ -2423,6 +2428,7 @@ initialize_options(Options * options) | |
options->hostbased_accepted_algos = NULL; | ||
options->pubkey_accepted_algos = NULL; | ||
options->known_hosts_command = NULL; | ||
options->required_rsa_size = -1; | ||
} | ||
|
||
/* | ||
|
@@ -2619,6 +2625,8 @@ fill_default_options(Options * options) | |
if (options->sk_provider == NULL) | ||
options->sk_provider = xstrdup("$SSH_SK_PROVIDER"); | ||
#endif | ||
if (options->required_rsa_size == -1) | ||
options->required_rsa_size = SSH_RSA_MINIMUM_MODULUS_SIZE; | ||
|
||
/* Expand KEX name lists */ | ||
all_cipher = cipher_alg_list(',', 0); | ||
|
@@ -3308,6 +3316,7 @@ dump_client_config(Options *o, const char *host) | |
dump_cfg_int(oNumberOfPasswordPrompts, o->number_of_password_prompts); | ||
dump_cfg_int(oServerAliveCountMax, o->server_alive_count_max); | ||
dump_cfg_int(oServerAliveInterval, o->server_alive_interval); | ||
dump_cfg_int(oRequiredRSASize, o->required_rsa_size); | ||
|
||
/* String options */ | ||
dump_cfg_string(oBindAddress, o->bind_address); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: readconf.h,v 1.147 2022/06/03 04:30:47 djm Exp $ */ | ||
/* $OpenBSD: readconf.h,v 1.148 2022/09/17 10:33:18 djm Exp $ */ | ||
|
||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
|
@@ -176,6 +176,8 @@ typedef struct { | |
|
||
char *known_hosts_command; | ||
|
||
int required_rsa_size; /* minimum size of RSA keys */ | ||
|
||
char *ignored_unknown; /* Pattern list of unknown tokens to ignore */ | ||
} Options; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: ssh.c,v 1.575 2022/07/01 00:36:30 djm Exp $ */ | ||
/* $OpenBSD: ssh.c,v 1.576 2022/09/17 10:33:18 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -516,14 +516,22 @@ resolve_canonicalize(char **hostp, int port) | |
} | ||
|
||
/* | ||
* Check the result of hostkey loading, ignoring some errors and | ||
* fatal()ing for others. | ||
* Check the result of hostkey loading, ignoring some errors and either | ||
* discarding the key or fatal()ing for others. | ||
*/ | ||
static void | ||
check_load(int r, const char *path, const char *message) | ||
check_load(int r, struct sshkey **k, const char *path, const char *message) | ||
{ | ||
switch (r) { | ||
case 0: | ||
/* Check RSA keys size and discard if undersized */ | ||
if (k != NULL && *k != NULL && | ||
(r = sshkey_check_rsa_length(*k, | ||
options.required_rsa_size)) != 0) { | ||
error_r(r, "load %s \"%s\"", message, path); | ||
free(*k); | ||
*k = NULL; | ||
} | ||
break; | ||
case SSH_ERR_INTERNAL_ERROR: | ||
case SSH_ERR_ALLOC_FAIL: | ||
|
@@ -1578,15 +1586,16 @@ main(int ac, char **av) | |
if ((o) >= sensitive_data.nkeys) \ | ||
fatal_f("pubkey out of array bounds"); \ | ||
check_load(sshkey_load_public(p, &(sensitive_data.keys[o]), NULL), \ | ||
p, "pubkey"); \ | ||
&(sensitive_data.keys[o]), p, "pubkey"); \ | ||
if (sensitive_data.keys[o] != NULL) \ | ||
debug2("hostbased key %d: %s key from \"%s\"", o, \ | ||
sshkey_ssh_name(sensitive_data.keys[o]), p); \ | ||
} while (0) | ||
#define L_CERT(p,o) do { \ | ||
if ((o) >= sensitive_data.nkeys) \ | ||
fatal_f("cert out of array bounds"); \ | ||
check_load(sshkey_load_cert(p, &(sensitive_data.keys[o])), p, "cert"); \ | ||
check_load(sshkey_load_cert(p, &(sensitive_data.keys[o])), \ | ||
&(sensitive_data.keys[o]), p, "cert"); \ | ||
if (sensitive_data.keys[o] != NULL) \ | ||
debug2("hostbased key %d: %s cert from \"%s\"", o, \ | ||
sshkey_ssh_name(sensitive_data.keys[o]), p); \ | ||
|
@@ -2265,7 +2274,7 @@ load_public_identity_files(const struct ssh_conn_info *cinfo) | |
filename = default_client_percent_dollar_expand(cp, cinfo); | ||
free(cp); | ||
check_load(sshkey_load_public(filename, &public, NULL), | ||
filename, "pubkey"); | ||
&public, filename, "pubkey"); | ||
debug("identity file %s type %d", filename, | ||
public ? public->type : -1); | ||
free(options.identity_files[i]); | ||
|
@@ -2284,7 +2293,7 @@ load_public_identity_files(const struct ssh_conn_info *cinfo) | |
continue; | ||
xasprintf(&cp, "%s-cert", filename); | ||
check_load(sshkey_load_public(cp, &public, NULL), | ||
filename, "pubkey"); | ||
&public, filename, "pubkey"); | ||
debug("identity file %s type %d", cp, | ||
public ? public->type : -1); | ||
if (public == NULL) { | ||
|
@@ -2315,7 +2324,7 @@ load_public_identity_files(const struct ssh_conn_info *cinfo) | |
free(cp); | ||
|
||
check_load(sshkey_load_public(filename, &public, NULL), | ||
filename, "certificate"); | ||
&public, filename, "certificate"); | ||
debug("certificate file %s type %d", filename, | ||
public ? public->type : -1); | ||
free(options.certificate_files[i]); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters