From nobody Wed Feb 08 21:06:31 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 4PBsxQ07qlz3pKDW; Wed, 8 Feb 2023 21:06:34 +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 4PBsxM3Lsyz3ksc; Wed, 8 Feb 2023 21:06:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675890391; 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=/Djh90TjvIl1T1o7ZLzG0M30g6crLHy1HbZb78W3tb0=; b=txhW0pV9gQw1DdoJps2Q+ilaxQMsI04PlGnUtDTDLc2+CeXe6Mdf9Avbm3utOmgWw4GOu6 rOs5mLrDIjP60fGRKtzjgM/R1Q9lBtKNPlVmoQMu03tlODllz7WqHm2cVXhoZ69H1Zhbnm DtukF/uNqxePGm6tOUkDQoORNmBL1XmgVy3v7QIn2KZhJ7HuD8hFttFItq1fd4nS0Uugkm 51FJgliS1AyGlbjKYZtBjH8I1SbdVYQEP1K5fF1VU6MlbhizK62joPeBclXOCJfaQz5ybQ 8FnXKGbf9YQjiuNTIvdA7qszABMDYuew6zQhR+EWitywju5kU5G5CILmAmLT2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675890391; 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=/Djh90TjvIl1T1o7ZLzG0M30g6crLHy1HbZb78W3tb0=; b=UhG9j91I95trUMimjsR8xgfB3C0HhXyS+2UwLa15v9Itbs6LcaMvTShXD7yTGhlHO8brbx APfHa5cixvS2FzFsptWQ3w2b7ruUsi9fdAl1GuTILeHWF9ZoC+kNxVFgzklju1mtwxnoSa 7GhYEGBRBZyk142Is3GivGDstBu0rU5m6UOBholjN5wiOqSv3eEN8Ic6p78GzgW46qAI0I EW6dk/8oEikx7VU9FXsPYSgnwxEAbiptROF6027GTCTydBa9DKlKJ06Ob9PYmM2DCjGXTy 6sE55yGP5KuFsTZj/sclX75y1g291cuOEZ2qo2zFeSVnoWzNmfEHwlnj3z3AAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675890391; a=rsa-sha256; cv=none; b=xeWG1mWknZEJJL/1ep4NP/uHKMC2DyxP64rG2cbCgF7vDifknQgl0CtcPKlUUBqI/RRHc1 42BrUppg7yE2pC4APFCBrk1tgYWjYXu5rYzT44m4B066AWNzfZ+L+BTHeQPEj5aDvCBR3l dSICzbC0IP3PslR6P8iMQpYexgD3yt0+heoqUdLz9vAiM6u21IxWa++KdIjyPZ1qF9b4xI OZBHgXwOJMNeOoDP8v1HossdQeipyYtKWwJ2AW9NogRMvvRoOF8m5bh4CYiQYqdcrF00Io vd5bJSrtIjNXyeF5MO2QGJv3iAOWVC8sK2AC/vR+oEQP0+oQNsWYlMlMs9I63A== 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 4PBsxM2Srwz1BDb; Wed, 8 Feb 2023 21:06:31 +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 318L6VLI068062; Wed, 8 Feb 2023 21:06:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 318L6VYh068061; Wed, 8 Feb 2023 21:06:31 GMT (envelope-from git) Date: Wed, 8 Feb 2023 21:06:31 GMT Message-Id: <202302082106.318L6VYh068061@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: 2caac96a666c - stable/12 - 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2caac96a666ce99703b16e4d59a417bab8f91d3c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=2caac96a666ce99703b16e4d59a417bab8f91d3c commit 2caac96a666ce99703b16e4d59a417bab8f91d3c Author: Ed Maste AuthorDate: 2023-02-06 16:26:08 +0000 Commit: Ed Maste CommitDate: 2023-02-08 21:06:22 +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) (cherry picked from commit 296ec8eae0c834088a491643a937d881bfb4b5dd) --- 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; }