From b0d3fc6ef1e4a1549661544315c1c5a96fd835d3 Mon Sep 17 00:00:00 2001 From: Zoltan Fridrich Date: Mon, 13 Apr 2026 16:18:29 +0200 Subject: [PATCH] Fix CVE-2026-35387 Fix incomplete application of PubkeyAcceptedAlgorithms and HostbasedAcceptedAlgorithms with regard to ECDSA keys Resolves: RHEL-166224 Signed-off-by: Zoltan Fridrich --- ...h-8.0p1-ecdsa-incomplete-application.patch | 99 +++++++++++++++++++ openssh.spec | 6 ++ 2 files changed, 105 insertions(+) create mode 100644 openssh-8.0p1-ecdsa-incomplete-application.patch diff --git a/openssh-8.0p1-ecdsa-incomplete-application.patch b/openssh-8.0p1-ecdsa-incomplete-application.patch new file mode 100644 index 0000000..d9055dd --- /dev/null +++ b/openssh-8.0p1-ecdsa-incomplete-application.patch @@ -0,0 +1,99 @@ +diff --color -ruNp a/auth2-hostbased.c b/auth2-hostbased.c +--- a/auth2-hostbased.c 2026-04-15 12:41:41.506985043 +0200 ++++ b/auth2-hostbased.c 2026-04-15 12:55:55.039916421 +0200 +@@ -96,9 +96,10 @@ userauth_hostbased(struct ssh *ssh) + error("%s: cannot decode key: %s", __func__, pkalg); + goto done; + } +- if (key->type != pktype) { +- error("%s: type mismatch for decoded key " +- "(received %d, expected %d)", __func__, key->type, pktype); ++ if (key->type != pktype || (sshkey_type_plain(pktype) == KEY_ECDSA && ++ sshkey_ecdsa_nid_from_name(pkalg) != key->ecdsa_nid)) { ++ error("%s: key type mismatch for decoded key " ++ "(received %s, expected %s)", __func__, sshkey_ssh_name(key), pkalg); + goto done; + } + if (sshkey_type_plain(key->type) == KEY_RSA && +diff --color -ruNp a/auth2-pubkey.c b/auth2-pubkey.c +--- a/auth2-pubkey.c 2026-04-15 12:41:41.507225986 +0200 ++++ b/auth2-pubkey.c 2026-04-15 12:55:06.559875789 +0200 +@@ -136,9 +136,10 @@ userauth_pubkey(struct ssh *ssh) + error("%s: cannot decode key: %s", __func__, pkalg); + goto done; + } +- if (key->type != pktype) { +- error("%s: type mismatch for decoded key " +- "(received %d, expected %d)", __func__, key->type, pktype); ++ if (key->type != pktype || (sshkey_type_plain(pktype) == KEY_ECDSA && ++ sshkey_ecdsa_nid_from_name(pkalg) != key->ecdsa_nid)) { ++ error("%s: key type mismatch for decoded key " ++ "(received %s, expected %s)", __func__, sshkey_ssh_name(key), pkalg); + goto done; + } + if (sshkey_type_plain(key->type) == KEY_RSA && +diff --color -ruNp a/sshconnect2.c b/sshconnect2.c +--- a/sshconnect2.c 2026-04-15 12:41:41.546573648 +0200 ++++ b/sshconnect2.c 2026-04-15 12:47:56.862867930 +0200 +@@ -91,10 +91,15 @@ u_int session_id2_len = 0; + + char *xxx_host; + struct sockaddr *xxx_hostaddr; ++static int key_type_allowed(struct sshkey *, const char *); + + static int + verify_host_key_callback(struct sshkey *hostkey, struct ssh *ssh) + { ++ if (!key_type_allowed(hostkey, options.hostkeyalgorithms)) { ++ fatal("Server host key %s not in HostKeyAlgorithms", ++ sshkey_ssh_name(hostkey)); ++ } + if (verify_host_key(xxx_host, xxx_hostaddr, hostkey) != 0) + fatal("Host key verification failed."); + return 0; +@@ -1662,34 +1667,36 @@ load_identity_file(Identity *id) + } + + static int +-key_type_allowed_by_config(struct sshkey *key) ++key_type_allowed(struct sshkey *key, const char *allowlist) + { +- if (match_pattern_list(sshkey_ssh_name(key), +- options.pubkey_key_types, 0) == 1) ++ if (match_pattern_list(sshkey_ssh_name(key), allowlist, 0) == 1) + return 1; + + /* RSA keys/certs might be allowed by alternate signature types */ + switch (key->type) { + case KEY_RSA: +- if (match_pattern_list("rsa-sha2-512", +- options.pubkey_key_types, 0) == 1) ++ if (match_pattern_list("rsa-sha2-512", allowlist, 0) == 1) + return 1; +- if (match_pattern_list("rsa-sha2-256", +- options.pubkey_key_types, 0) == 1) ++ if (match_pattern_list("rsa-sha2-256", allowlist, 0) == 1) + return 1; + break; + case KEY_RSA_CERT: + if (match_pattern_list("rsa-sha2-512-cert-v01@openssh.com", +- options.pubkey_key_types, 0) == 1) ++ allowlist, 0) == 1) + return 1; + if (match_pattern_list("rsa-sha2-256-cert-v01@openssh.com", +- options.pubkey_key_types, 0) == 1) ++ allowlist, 0) == 1) + return 1; + break; + } + return 0; + } + ++static int ++key_type_allowed_by_config(struct sshkey *key) ++{ ++ return key_type_allowed(key, options.pubkey_key_types); ++} + + /* + * try keys in the following order: diff --git a/openssh.spec b/openssh.spec index 28e8a31..00f8d2d 100644 --- a/openssh.spec +++ b/openssh.spec @@ -304,6 +304,8 @@ Patch1024: openssh-8.7p1-reject-null-char-in-url-string.patch Patch1025: openssh-9.9p1-scp-clear-setuid.patch # upstream c805b97b67c774e0bf922ffb29dfbcda9d7b5add Patch1026: openssh-8.0p1-mux-askpass-check.patch +# upstream fd1c7e131f331942d20f42f31e79912d570081fa +Patch1027: openssh-8.0p1-ecdsa-incomplete-application.patch License: BSD Group: Applications/Internet @@ -557,6 +559,7 @@ popd %patch1024 -p1 -b .reject-null-char-in-url-string %patch1025 -p1 -b .scp-clear-setuid %patch1026 -p1 -b .mux-askpass-check +%patch1027 -p1 -b .ecdsa-incomplete-application autoreconf pushd pam_ssh_agent_auth-%{pam_ssh_agent_ver} @@ -849,6 +852,9 @@ getent passwd sshd >/dev/null || \ - CVE-2026-35388: Add connection multiplexing confirmation for proxy-mode multiplexing sessions Resolves: RHEL-166240 +- CVE-2026-35387: Fix incomplete application of PubkeyAcceptedAlgorithms + and HostbasedAcceptedAlgorithms with regard to ECDSA keys + Resolves: RHEL-166224 * Mon Mar 16 2026 Zoltan Fridrich - 8.0p1-28 - CVE-2026-3497: Fix information disclosure or denial of service due