From nobody Thu Feb 16 18:01:58 2023 X-Original-To: dev-commits-src-all@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 4PHjSk219Hz3rF42; Thu, 16 Feb 2023 18:01:58 +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 4PHjSk1TVJz4Jfm; Thu, 16 Feb 2023 18:01:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676570518; 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=Vlsoxi0UaxLDKEbq4YseQh8AQp4czMp3SfY2dDUZaEg=; b=TivmDYZ/PCS/N0jYOfGVCx1UNbYns7mEvPxVikGNWMOQZB3GrK2GO7g2CmKCupSfSBn33s Poe28ZQXZOSgH1t/ly1iajS70akvosXGlq/vt2QNajgwhjsm25aXUW/G/yFXVNNxKEJfxs ljJ7aqRv9+jg09HR97ZijAFbnfcMYF8/RMXhssMCpl2n/Huh5gHhZhIJ2XVfioA0XOT/LS qW0JvVljNaXppFCOtRAa4Runu2rASi4df7URQr+sKuRdXPtrEAjoC3vG+2BfgypQxPXkrC 0okHs006PL5WEmT+XH3wXcOXF6/3lV+dMrC3x3765dma9CsQlsnJ5U1gP2ffuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676570518; 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=Vlsoxi0UaxLDKEbq4YseQh8AQp4czMp3SfY2dDUZaEg=; b=VmiIj3hkMneeBFlyeE3lHmV0PkfMvoy6h+v5MoqINy7kpWTgPzFOg++uWVXe4f88z05kSZ nzi+whhRKJI4MnXiw8MA8TJ9rH+dp5G3iO7sPVajaEckx1f4aqPB7P87htQ6c4+GqEpKqS YIBuElVHugh4qAcdheyoB2PGUa1JT1IeTG3sjVh9I5z/FRS23dK8UkH5g5Kv88O0j89QXM bwPpjJHeKKxKSmo24bHUI+WSioReE2zrmXgGSWNYPzhYFfZKQc1rvmDN0Y2N+MsmTHq1rj a+oyWPuaa8Ulfgam9plckgXNuKecglM42sjMiiE9xSRH13Gha7Wskx0m71o1Nw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676570518; a=rsa-sha256; cv=none; b=bNpianYJTmcU8InI+VLHMrFGpfgGpMGFK7XToKFIXiP4MPYSYTZiAcfWFcoyUxcM+MWUBj 2RBcePDSPtsBTXxpzRj+6HpMWoaU1P2YDignkUdaR9syx+ohVRaNQTe6JCf0nljFhEWGxQ 5jl5PoeMu3VaR0nfcpmabI8wXTXxPAq5iq/RY5yg6KqDnpIbcJvXX8oS1J9dKB58m+C44b fE1IAEbWQbzL4v6niE6kUBFw4VQ6WNe/vLBUkQuITinYjaPlJlJ+wjMOVSGFt68GCMfO7O kcDs0pdyBIdklpyNWi/FV8+VY+2Qpd+A8aiLGiyiUbMSKVlNKJSU5DBCA94zCQ== 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 4PHjSk0Ymjz1CN0; Thu, 16 Feb 2023 18:01:58 +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 31GI1wXC085223; Thu, 16 Feb 2023 18:01:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GI1wir085222; Thu, 16 Feb 2023 18:01:58 GMT (envelope-from git) Date: Thu, 16 Feb 2023 18:01:58 GMT Message-Id: <202302161801.31GI1wir085222@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: e87e8c20e647 - releng/12.4 - ssh: fix double-free caused by compat_kex_proposal() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.4 X-Git-Reftype: branch X-Git-Commit: e87e8c20e64753a25743d546e2a8b8619efd83c6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/12.4 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=e87e8c20e64753a25743d546e2a8b8619efd83c6 commit e87e8c20e64753a25743d546e2a8b8619efd83c6 Author: Ed Maste AuthorDate: 2023-02-06 16:26:08 +0000 Commit: Gordon Tetlow CommitDate: 2023-02-16 17:12:39 +0000 ssh: fix double-free caused by compat_kex_proposal() Approved by: so Security: FreeBSD-SA-23:02.openssh Security: CVE-2023-25136 Obtained from: OpenSSH-portable commit 12da78233364 Sponsored by: The FreeBSD Foundation (cherry picked from commit fe1371e8f3d7336748d291a7360b2aacce943fb1) (cherry picked from commit 296ec8eae0c834088a491643a937d881bfb4b5dd) (cherry picked from commit 2caac96a666ce99703b16e4d59a417bab8f91d3c) --- 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; }