From 4edf2a08cc581fb8cd74fca026f8ca840b709e5b Mon Sep 17 00:00:00 2001 From: tomcruiseqi <10762123+tomcruiseqi@user.noreply.gitee.com> Date: Fri, 18 Apr 2025 16:58:01 +0800 Subject: [PATCH] [CVE] FIX CVE-2025-26465 to #20482 add patch to fix CVE-2025-26465 Project: TC2024080204 Signed-off-by: tomcruiseqi <10762123+tomcruiseqi@user.noreply.gitee.com> --- bugfix-for-cve-2025-26465.patch | 138 ++++++++++++++++++++++++++++++++ openssh.spec | 17 +++- 2 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 bugfix-for-cve-2025-26465.patch diff --git a/bugfix-for-cve-2025-26465.patch b/bugfix-for-cve-2025-26465.patch new file mode 100644 index 0000000..5c40fdc --- /dev/null +++ b/bugfix-for-cve-2025-26465.patch @@ -0,0 +1,138 @@ +From 0832aac79517611dd4de93ad0a83577994d9c907 Mon Sep 17 00:00:00 2001 +From: "djm@openbsd.org" +Date: Tue, 18 Feb 2025 08:02:48 +0000 +Subject: upstream: Fix cases where error codes were not correctly set + +Reported by the Qualys Security Advisory team. ok markus@ + +OpenBSD-Commit-ID: 7bcd4ffe0fa1e27ff98d451fb9c22f5fae6e610d +Conflict:NA +Reference:https://anongit.mindrot.org/openssh.git/commit/?id=0832aac79517611dd4de93ad0a83577994d9c907 +--- + krl.c | 2 ++ + ssh-agent.c | 3 +++ + ssh-sk-client.c | 2 ++ + sshconnect2.c | 5 ++++- + sshsig.c | 1 + + 5 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/krl.c b/krl.c +index f4fc547..cec61a8 100644 +--- a/krl.c ++++ b/krl.c +@@ -676,6 +676,7 @@ revoked_certs_generate(struct revoked_certs *rc, struct sshbuf *buf) + break; + case KRL_SECTION_CERT_SERIAL_BITMAP: + if (rs->lo - bitmap_start > INT_MAX) { ++ r = SSH_ERR_INVALID_FORMAT; + error_f("insane bitmap gap"); + goto out; + } +@@ -1009,6 +1009,7 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp) + goto out; + + if ((krl = ssh_krl_init()) == NULL) { ++ r = SSH_ERR_ALLOC_FAIL; + error_f("alloc failed"); + goto out; + } +diff --git a/ssh-agent.c b/ssh-agent.c +index 5956438..f0ec3db 100644 +--- a/ssh-agent.c ++++ b/ssh-agent.c +@@ -1094,6 +1094,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp, + "restrict-destination-v00@openssh.com") == 0) { + if (*dcsp != NULL) { + error_f("%s already set", ext_name); ++ r = SSH_ERR_INVALID_FORMAT; + goto out; + } + if ((r = sshbuf_froms(m, &b)) != 0) { +@@ -1103,6 +1104,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp, + while (sshbuf_len(b) != 0) { + if (*ndcsp >= AGENT_MAX_DEST_CONSTRAINTS) { + error_f("too many %s constraints", ext_name); ++ r = SSH_ERR_INVALID_FORMAT; + goto out; + } + *dcsp = xrecallocarray(*dcsp, *ndcsp, *ndcsp + 1, +@@ -1616,6 +1618,7 @@ process_ext_session_bind(SocketEntry *e) + /* record new key/sid */ + if (e->nsession_ids >= AGENT_MAX_SESSION_IDS) { + error_f("too many session IDs recorded"); ++ r = -1; + goto out; + } + e->session_ids = xrecallocarray(e->session_ids, e->nsession_ids, +diff --git a/ssh-sk-client.c b/ssh-sk-client.c +index 321fe53..750accb 100644 +--- a/ssh-sk-client.c ++++ b/ssh-sk-client.c +@@ -439,6 +439,7 @@ sshsk_load_resident(const char *provider_path, const char *device, + } + if ((srk = calloc(1, sizeof(*srk))) == NULL) { + error_f("calloc failed"); ++ r = SSH_ERR_ALLOC_FAIL; + goto out; + } + srk->key = key; +@@ -450,6 +451,7 @@ sshsk_load_resident(const char *provider_path, const char *device, + if ((tmp = recallocarray(srks, nsrks, nsrks + 1, + sizeof(*srks))) == NULL) { + error_f("recallocarray keys failed"); ++ r = SSH_ERR_ALLOC_FAIL; + goto out; + } + debug_f("srks[%zu]: %s %s uidlen %zu", nsrks, +diff --git a/sshconnect2.c b/sshconnect2.c +index 0157595..69cf0c4 100644 +--- a/sshconnect2.c ++++ b/sshconnect2.c +@@ -101,7 +101,7 @@ verify_host_key_callback(struct sshkey *hostkey, struct ssh *ssh) + options.required_rsa_size)) != 0) + fatal_r(r, "Bad server host key"); + if (verify_host_key(xxx_host, xxx_hostaddr, hostkey, +- xxx_conn_info) == -1) ++ xxx_conn_info) != 0) + fatal("Host key verification failed."); + return 0; + } +@@ -805,6 +805,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh) + + if ((pktype = sshkey_type_from_name(pkalg)) == KEY_UNSPEC) { + debug_f("server sent unknown pkalg %s", pkalg); ++ r = SSH_ERR_INVALID_FORMAT; + goto done; + } + if ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) { +@@ -815,6 +816,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh) + error("input_userauth_pk_ok: type mismatch " + "for decoded key (received %d, expected %d)", + key->type, pktype); ++ r = SSH_ERR_INVALID_FORMAT; + goto done; + } + +@@ -834,6 +836,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh) + SSH_FP_DEFAULT); + error_f("server replied with unknown key: %s %s", + sshkey_type(key), fp == NULL ? "" : fp); ++ r = SSH_ERR_INVALID_FORMAT; + goto done; + } + ident = format_identity(id); +diff --git a/sshsig.c b/sshsig.c +index d50d65f..1b7f40d 100644 +--- a/sshsig.c ++++ b/sshsig.c +@@ -874,6 +874,7 @@ cert_filter_principals(const char *path, u_long linenum, + } + if ((principals = sshbuf_dup_string(nprincipals)) == NULL) { + error_f("buffer error"); ++ r = SSH_ERR_ALLOC_FAIL; + goto out; + } + /* success */ +-- +2.33.0 + diff --git a/openssh.spec b/openssh.spec index c48d2da..8038a29 100644 --- a/openssh.spec +++ b/openssh.spec @@ -1,4 +1,4 @@ -%define anolis_release 2 +%define anolis_release 3 %global WITH_SELINUX 1 @@ -219,8 +219,16 @@ Patch1014: openssh-8.7p1-nohostsha1proof.patch Patch1016: openssh-9.3p1-openssl-compat.patch # for loongarch Patch1017: add-loongarch64-support-for-openssh.patch + +# CVE patches +# CVE-2025-32728 #upstream fc86875e6acb36401dfc1dfb6b628a9d1460f367 Patch1018: 0001-upstream-Fix-logic-error-in-DisableForwarding-option.patch + +# CVE-2025-26465 +# https://anongit.mindrot.org/openssh.git/commit/?id=0832aac79517611dd4de93ad0a83577994d9c907 +Patch1019: bugfix-for-cve-2025-26465.patch + License: BSD-3-Clause AND BSD-2-Clause AND ISC AND SSH-OpenSSH AND ssh-keyscan AND sprintf AND LicenseRef-Fedora-Public-Domain AND X11-distribute-modifications-variant Requires: /sbin/nologin @@ -436,8 +444,8 @@ popd #patch for loongarch %patch -P 1017 -p1 -# patch for CVE-2025-32728 %patch -P 1018 -p1 +%patch -P 1019 -p1 autoreconf pushd pam_ssh_agent_auth-pam_ssh_agent_auth-%{pam_ssh_agent_ver} @@ -749,7 +757,10 @@ test -f %{sysconfig_anaconda} && \ %endif %changelog -* Sat Apr 12 2025 yangjinlin01 - 9.3p2-2 +* Fri Apr 18 2025 tomcruiseqi <10762123+tomcruiseqi@user.noreply.gitee.com> - 9.3p2-3 +- Fix CVE-2025-26465 + +* Sat Apr 12 2025 yangjinlin01 - 9.3p2-2 - Fix CVE-2025-32728 * Fri Mar 22 2024 mgb01105731 - 9.3p2-1 -- Gitee