From patchwork Mon May 22 10:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 3236 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:7b9a:b0:c3:1364:a2a2 with SMTP id j26csp1476719dyk; Mon, 22 May 2023 03:12:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ518El2NE9HpT1C1R9mY7Qp4Om1R83XRfvZ5rD/BCrZ65NnsxPAvZB++v9uMHBGnOFjwgd1 X-Received: by 2002:a92:bf06:0:b0:33a:2863:2c57 with SMTP id z6-20020a92bf06000000b0033a28632c57mr707650ilh.9.1684750328144; Mon, 22 May 2023 03:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684750328; cv=none; d=google.com; s=arc-20160816; b=RxuD4EKRm61WFZX2ztKcVVDvKumdbCZfIUgQT16xih13e9LgCHM8JzZudIj8m0+0dd L66xzqDm8tba+L0ePGbf51f4ozSjvEyootqMJsFCqTJTUJ5p4s67V9UNdElbjOqoBClz Z10oIlOzJ0GTXVQVup1axd6jXBAEBWo7lgJo758jRldUQ7C2HRPMp48nw9xxKxJGniqX Fu3/NnftKPjmUFOy1GoaWHJfOKoqu2uNQBJDTcld/vAxVaIdChBa5/rC4JXHMiaHZUK0 VV84/Y7ou6I7NOoJ86qISuTQ2ov9O5c5h0qAoCBCwzrIoRMpT3KuQBCJM8lQv7+gaRmZ 2auA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=klG6Om0s0/qXiD9Y+qgHWgPLaI3y/Z6Qwvx17kM5Nr8=; b=XWVyUBvkNymar24qNBFk3Phk3DQNYxdQulldNSQOpp7Hnyd2Eb9taZWYMaVgbQOzqd 4DYoIvmP5cgYS1f9nuWluJlf8q77nRTk0jg38Eld0wTTFa2NHoAMGCqMP6EOyVrR5SZo sf26n09gV+kBxXTzli5NP4sENCUcqGlXx7oczvCKOKyJ3GesJKNQTAmZR/IWLDSziKXi Eq8tjabSPEkiPLAsHPtZzbTm3Qzb9iks2/txMdmK3o7EBGSUCucFuxuUQ88YV8o/VitD 87r/fk82EV6UrMJzpISn2iQmvKgnNue6GQgh6sb/XjoeVjRALtKg/C9VQ/I4jyGkkGvL K6Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="jq/TTIE4"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=WX1vR82T; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id c17-20020a92cf51000000b00338589975e4si3072937ilr.74.2023.05.22.03.12.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2023 03:12:08 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="jq/TTIE4"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=WX1vR82T; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1q12W7-0005VY-IE; Mon, 22 May 2023 10:11:51 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q12W6-0005VR-JD for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 10:11:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EeaUIXZf7kPl873DRfzi/v4g0MT+VU+dRpAjCXCbT4A=; b=jq/TTIE4j6JMMe3f7cbErw27Dj BAjuNjCb0SgyUpud1gm6UIOSPqCQa1BdSoowcpjRI9nKB07flBYB8t+pzwQgsuxxJ4yGJ7QxEcOF+ 7v/1xNJhsrvq5MVRQkuRfTuCHfSLFfQUMBmwY6zcx75pD7U8zQwebm1Mme6oVpNVTnRI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=EeaUIXZf7kPl873DRfzi/v4g0MT+VU+dRpAjCXCbT4A=; b=WX1vR82TJk7z4VQhEo2IHgKOYv Um+MmdHwT2KIpts6lRdya3N+R74Uh2jUKUzYxleFeyXIAgIoGHRCYSJifbRuDU28yu1k/79fhYlEX nW6aApRhz+4tFCS8Rgq7nT5WjHVlzfNVsjx3wVPA4Hvbhi/RolFfKGLpdlX4QjT5jGNM=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1q12W5-0004Xy-TU for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 10:11:50 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1q12Vu-000MwI-6F for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 12:11:38 +0200 Received: (nullmailer pid 2842427 invoked by uid 10006); Mon, 22 May 2023 10:11:38 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 22 May 2023 12:11:38 +0200 Message-Id: <20230522101138.2842378-2-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230522101138.2842378-1-arne@rfc2549.org> References: <20230517110230.2234266-1-arne@rfc2549.org> <20230522101138.2842378-1-arne@rfc2549.org> MIME-Version: 1.0 X-Spam-Score: 0.3 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: the management interface expects the management key id instead of the openvpn key id. In the past they often were the same for low ids which hid the bug quite well. Also do not pick uninitialised keystates (management key_id is not valid in these). Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-Headers-End: 1q12W5-0004Xy-TU Subject: [Openvpn-devel] [PATCH v2 2/2] Fix CR_RESPONSE mangaement message using wrong key_id X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1766138990735137506?= X-GMAIL-MSGID: =?utf-8?q?1766588759981837197?= the management interface expects the management key id instead of the openvpn key id. In the past they often were the same for low ids which hid the bug quite well. Also do not pick uninitialised keystates (management key_id is not valid in these). Patch v2: do not add logging Change-Id: If9fa1165a0e886b570b3738546ed810a32367cbe Signed-off-by: Arne Schwabe --- src/openvpn/push.c | 4 ++-- src/openvpn/ssl_common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 8e9627199..8f0a534ac 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -267,9 +267,9 @@ receive_cr_response(struct context *c, const struct buffer *buffer) struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE]; struct man_def_auth_context *mda = session->opt->mda_context; struct env_set *es = session->opt->es; - int key_id = get_primary_key(c->c2.tls_multi)->key_id; + unsigned int mda_key_id = get_primary_key(c->c2.tls_multi)->mda_key_id; - management_notify_client_cr_response(key_id, mda, es, m); + management_notify_client_cr_response(mda_key_id, mda, es, m); #endif #if ENABLE_PLUGIN verify_crresponse_plugin(c->c2.tls_multi, m); diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index ebfd25432..be0f18746 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -733,7 +733,7 @@ get_key_by_management_key_id(struct tls_multi *multi, unsigned int mda_key_id) for (int i = 0; i < KEY_SCAN_SIZE; ++i) { struct key_state *ks = get_key_scan(multi, i); - if (ks->mda_key_id == mda_key_id) + if (ks->mda_key_id == mda_key_id && ks->state > S_UNDEF) { return ks; }