diff options
| -rw-r--r-- | meta/recipes-connectivity/openssh/openssh/CVE-2020-14145.patch | 90 | ||||
| -rw-r--r-- | meta/recipes-connectivity/openssh/openssh_8.3p1.bb | 1 |
2 files changed, 91 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssh/openssh/CVE-2020-14145.patch b/meta/recipes-connectivity/openssh/openssh/CVE-2020-14145.patch new file mode 100644 index 0000000000..0046ee1a51 --- /dev/null +++ b/meta/recipes-connectivity/openssh/openssh/CVE-2020-14145.patch | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | From b3855ff053f5078ec3d3c653cdaedefaa5fc362d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "djm@openbsd.org" <djm@openbsd.org> | ||
| 3 | Date: Fri, 18 Sep 2020 05:23:03 +0000 | ||
| 4 | Subject: [PATCH] upstream: tweak the client hostkey preference ordering | ||
| 5 | algorithm to | ||
| 6 | |||
| 7 | prefer the default ordering if the user has a key that matches the | ||
| 8 | best-preference default algorithm. | ||
| 9 | |||
| 10 | feedback and ok markus@ | ||
| 11 | |||
| 12 | OpenBSD-Commit-ID: a92dd7d7520ddd95c0a16786a7519e6d0167d35f | ||
| 13 | |||
| 14 | Upstream-Status: Backport | ||
| 15 | [https://github.com/openssh/openssh-portable/commit/b3855ff053f5078ec3d3c653cdaedefaa5fc362d] | ||
| 16 | CVE: CVE-2020-14145 | ||
| 17 | Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com> | ||
| 18 | |||
| 19 | --- | ||
| 20 | sshconnect2.c | 41 ++++++++++++++++++++++++++++++++++++++--- | ||
| 21 | 1 file changed, 37 insertions(+), 2 deletions(-) | ||
| 22 | |||
| 23 | diff --git a/sshconnect2.c b/sshconnect2.c | ||
| 24 | index 347e348c60..f64aae66af 100644 | ||
| 25 | --- a/sshconnect2.c | ||
| 26 | +++ b/sshconnect2.c | ||
| 27 | @@ -102,12 +102,25 @@ verify_host_key_callback(struct sshkey *hostkey, struct ssh *ssh) | ||
| 28 | return 0; | ||
| 29 | } | ||
| 30 | |||
| 31 | +/* Returns the first item from a comma-separated algorithm list */ | ||
| 32 | +static char * | ||
| 33 | +first_alg(const char *algs) | ||
| 34 | +{ | ||
| 35 | + char *ret, *cp; | ||
| 36 | + | ||
| 37 | + ret = xstrdup(algs); | ||
| 38 | + if ((cp = strchr(ret, ',')) != NULL) | ||
| 39 | + *cp = '\0'; | ||
| 40 | + return ret; | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | static char * | ||
| 44 | order_hostkeyalgs(char *host, struct sockaddr *hostaddr, u_short port) | ||
| 45 | { | ||
| 46 | - char *oavail, *avail, *first, *last, *alg, *hostname, *ret; | ||
| 47 | + char *oavail = NULL, *avail = NULL, *first = NULL, *last = NULL; | ||
| 48 | + char *alg = NULL, *hostname = NULL, *ret = NULL, *best = NULL; | ||
| 49 | size_t maxlen; | ||
| 50 | - struct hostkeys *hostkeys; | ||
| 51 | + struct hostkeys *hostkeys = NULL; | ||
| 52 | int ktype; | ||
| 53 | u_int i; | ||
| 54 | |||
| 55 | @@ -119,6 +132,26 @@ order_hostkeyalgs(char *host, struct sockaddr *hostaddr, u_short port) | ||
| 56 | for (i = 0; i < options.num_system_hostfiles; i++) | ||
| 57 | load_hostkeys(hostkeys, hostname, options.system_hostfiles[i]); | ||
| 58 | |||
| 59 | + /* | ||
| 60 | + * If a plain public key exists that matches the type of the best | ||
| 61 | + * preference HostkeyAlgorithms, then use the whole list as is. | ||
| 62 | + * Note that we ignore whether the best preference algorithm is a | ||
| 63 | + * certificate type, as sshconnect.c will downgrade certs to | ||
| 64 | + * plain keys if necessary. | ||
| 65 | + */ | ||
| 66 | + best = first_alg(options.hostkeyalgorithms); | ||
| 67 | + if (lookup_key_in_hostkeys_by_type(hostkeys, | ||
| 68 | + sshkey_type_plain(sshkey_type_from_name(best)), NULL)) { | ||
| 69 | + debug3("%s: have matching best-preference key type %s, " | ||
| 70 | + "using HostkeyAlgorithms verbatim", __func__, best); | ||
| 71 | + ret = xstrdup(options.hostkeyalgorithms); | ||
| 72 | + goto out; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /* | ||
| 76 | + * Otherwise, prefer the host key algorithms that match known keys | ||
| 77 | + * while keeping the ordering of HostkeyAlgorithms as much as possible. | ||
| 78 | + */ | ||
| 79 | oavail = avail = xstrdup(options.hostkeyalgorithms); | ||
| 80 | maxlen = strlen(avail) + 1; | ||
| 81 | first = xmalloc(maxlen); | ||
| 82 | @@ -159,6 +192,8 @@ order_hostkeyalgs(char *host, struct sockaddr *hostaddr, u_short port) | ||
| 83 | if (*first != '\0') | ||
| 84 | debug3("%s: prefer hostkeyalgs: %s", __func__, first); | ||
| 85 | |||
| 86 | + out: | ||
| 87 | + free(best); | ||
| 88 | free(first); | ||
| 89 | free(last); | ||
| 90 | free(hostname); | ||
diff --git a/meta/recipes-connectivity/openssh/openssh_8.3p1.bb b/meta/recipes-connectivity/openssh/openssh_8.3p1.bb index 3061ed2975..a1e34a9379 100644 --- a/meta/recipes-connectivity/openssh/openssh_8.3p1.bb +++ b/meta/recipes-connectivity/openssh/openssh_8.3p1.bb | |||
| @@ -25,6 +25,7 @@ SRC_URI = "http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar | |||
| 25 | file://sshd_check_keys \ | 25 | file://sshd_check_keys \ |
| 26 | file://add-test-support-for-busybox.patch \ | 26 | file://add-test-support-for-busybox.patch \ |
| 27 | file://0f90440ca70abab947acbd77795e9f130967956c.patch \ | 27 | file://0f90440ca70abab947acbd77795e9f130967956c.patch \ |
| 28 | file://CVE-2020-14145.patch \ | ||
| 28 | " | 29 | " |
| 29 | SRC_URI[sha256sum] = "f2befbe0472fe7eb75d23340eb17531cb6b3aac24075e2066b41f814e12387b2" | 30 | SRC_URI[sha256sum] = "f2befbe0472fe7eb75d23340eb17531cb6b3aac24075e2066b41f814e12387b2" |
| 30 | 31 | ||
