From nobody Wed Feb 08 21:05:51 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PBswb32Hhz3pK2b; Wed, 8 Feb 2023 21:05:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PBswb2YPHz3jlH; Wed, 8 Feb 2023 21:05:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675890351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KmqsrnINmO0aUpj+SI8DLRhzAUEt7Zr+zYTOYJWjVEE=; b=HxxYkTzDBi/fIUwh/jLSpkK5vAQV0hkzn/4p7PEs4nh7F9fM1QmpUkw6nJeKH5dX0AVzeV PslNH0Humn2g+UgjKs7nZdEzEhg6vbQx74unaXt/qJsa72o4NvEXUVZwQuj2chX5Kjjas3 3roNJQQI4Gg0zF/gtpq54wUKrofpZwiGaV5r17uuyAO8Eg+JjEuP8oTHoXfUY1/JVCelZ4 MKbeG3p6DHOhwKyb5zgDFphhzCE+wFSjnnK75TV7PTDn/bWMIlNdZADyTWb/mt7XSQCPk9 vptsZRSDqp6zbeWleR16p/OdgePfq9NVR/S7Y4X9rb+ZxyQau9Bryvqe8vLZFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675890351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KmqsrnINmO0aUpj+SI8DLRhzAUEt7Zr+zYTOYJWjVEE=; b=MnCzwd49hYsESwB1tsZZGNLPWlksmJ7VyPl3XSuGUXawttFJrAKRV6CotupMMhskZ8S039 mEKMIaQvXqhK4DU26/Kc2GTew608Xt6L2Fak+qz3hdN/N9B2qr6iIFnuiS3bgdeI6nOK6B CA/b7yRiLtewC7/xDJJ4aQeZLkiCYFsCdwYJnRNEXUGzD5PeiRNRj+/pS7Aaqr6auSl1I1 iwAtPJdm40l0TAnCcYZVHJHgp9A3FGIN802kDY9zRDazxuS3ZtyDF8L8xNPUfLKnegKu+2 49gz5fJyMypIdNtumYxLHEh86VSXAWq1Qfs2gQLSzS+DhIxXxf6ntQgGX01PTg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675890351; a=rsa-sha256; cv=none; b=pO6WVFgCJD8EqO4n+1DbhEYcw+7sMOAhrZu9g7VIYxMviu31I4laU1isb3XBSwSrOJENI0 9pq4LTWq2tRVScU1eTJNDk5mnSHugfbQPSx0ekdU/Ldg832cgSkFTmPF07zHAHRIOEe6Ny aPu8QxwIx4IhkkxgYbxCMJnPo273V4QTEhUp+MDYqDFqtUq3kxLeRbjjiiRYLLVJdX814e K+zOiSrZNTDZWe1HAMqA8LZjMDfEOb/YQi/75X9dFWd0jMCmdVuvZaLKB7ZDLDf6fX8lL0 0akLtW3M531lN8dIJxZcQpVw9TGS9KqCymoI0VcF3gp1snO5fIZptFbCtIvgKA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PBswb1cVSz1BDY; Wed, 8 Feb 2023 21:05:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 318L5pjF067819; Wed, 8 Feb 2023 21:05:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 318L5pfk067818; Wed, 8 Feb 2023 21:05:51 GMT (envelope-from git) Date: Wed, 8 Feb 2023 21:05:51 GMT Message-Id: <202302082105.318L5pfk067818@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 296ec8eae0c8 - stable/13 - ssh: fix double-free caused by compat_kex_proposal() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 296ec8eae0c834088a491643a937d881bfb4b5dd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=296ec8eae0c834088a491643a937d881bfb4b5dd commit 296ec8eae0c834088a491643a937d881bfb4b5dd Author: Ed Maste AuthorDate: 2023-02-06 16:26:08 +0000 Commit: Ed Maste CommitDate: 2023-02-08 21:04:36 +0000 ssh: fix double-free caused by compat_kex_proposal() Security: CVE-2023-25136 Obtained from: OpenSSH-portable commit 12da78233364 Sponsored by: The FreeBSD Foundation (cherry picked from commit fe1371e8f3d7336748d291a7360b2aacce943fb1) --- crypto/openssh/compat.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crypto/openssh/compat.c b/crypto/openssh/compat.c index 46dfe3a9c2e7..478a9403eeaa 100644 --- a/crypto/openssh/compat.c +++ b/crypto/openssh/compat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat.c,v 1.120 2022/07/01 03:35:45 dtucker Exp $ */ +/* $OpenBSD: compat.c,v 1.121 2023/02/02 12:10:05 djm Exp $ */ /* * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. * @@ -190,26 +190,26 @@ compat_pkalg_proposal(struct ssh *ssh, char *pkalg_prop) char * compat_kex_proposal(struct ssh *ssh, char *p) { - char *cp = NULL; + char *cp = NULL, *cp2 = NULL; if ((ssh->compat & (SSH_BUG_CURVE25519PAD|SSH_OLD_DHGEX)) == 0) return xstrdup(p); debug2_f("original KEX proposal: %s", p); if ((ssh->compat & SSH_BUG_CURVE25519PAD) != 0) - if ((p = match_filter_denylist(p, + if ((cp = match_filter_denylist(p, "curve25519-sha256@libssh.org")) == NULL) fatal("match_filter_denylist failed"); if ((ssh->compat & SSH_OLD_DHGEX) != 0) { - cp = p; - if ((p = match_filter_denylist(p, + if ((cp2 = match_filter_denylist(cp ? cp : p, "diffie-hellman-group-exchange-sha256," "diffie-hellman-group-exchange-sha1")) == NULL) fatal("match_filter_denylist failed"); free(cp); + cp = cp2; } - debug2_f("compat KEX proposal: %s", p); - if (*p == '\0') + if (cp == NULL || *cp == '\0') fatal("No supported key exchange algorithms found"); - return p; + debug2_f("compat KEX proposal: %s", cp); + return cp; }