From patchwork Wed Aug 12 21:29:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Thorpe X-Patchwork-Id: 1384 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id +LV6DqjwNF9hPgAAIUCqbw for ; Thu, 13 Aug 2020 03:50:00 -0400 Received: from proxy14.mail.iad3b.rsapps.net ([172.31.255.6]) by director8.mail.ord1d.rsapps.net with LMTP id uNYiDajwNF8GHgAAfY0hYg (envelope-from ) for ; Thu, 13 Aug 2020 03:50:00 -0400 Received: from smtp36.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy14.mail.iad3b.rsapps.net with LMTP id KFupBajwNF8UNAAA+7ETDg ; Thu, 13 Aug 2020 03:50:00 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp36.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=sparklabs.com; dmarc=none (p=nil; dis=none) header.from=sparklabs.com X-Suspicious-Flag: YES X-Classification-ID: 9629f420-dd39-11ea-ab05-5254003a7283-1-1 Received: from [216.105.38.7] ([216.105.38.7:38772] helo=lists.sourceforge.net) by smtp36.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 43/79-21127-7A0F43F5; Thu, 13 Aug 2020 03:49:59 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1k67zG-0001xW-0X; Thu, 13 Aug 2020 07:49:22 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k67zE-0001wo-0h for openvpn-devel@lists.sourceforge.net; Thu, 13 Aug 2020 07:49:20 +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:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8GEtkygHZlOhqD2/9V0ZWM5uOBwxVu0uot9yxazEWlA=; b=Hszxo9wni2JpAf9JN8ulzV2zk2 elQKusP/8D8bGEso1HxDXXPgDG3qHoc9zbh0OxwJAViIP8AZe37dk+EHnEcOJUpycrx6lVA8zM/9y Yg99LqgVpX2/oeut241Kvb8/rfiEcty3lxWxzsAtkr25lZvo6K9l1jDq45LTuZVWGPfs=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=8GEtkygHZlOhqD2/9V0ZWM5uOBwxVu0uot9yxazEWlA=; b=F vqmgCAVS19WUqPm9LPJ7gOoEPfB3UYFDF+asZKqaUllst2VBYIC9YkGXTuKeXMlXSr1Kdny+56Sro EzoS0WaeiPOUixP9X1SobXmevwIgthIPT7C2PqVbFvMOq5tS2p5AH4pZ8SeKYsYLgy3DFQ5Gu22MV DSuAufXopNBFS2bQ=; Received: from silicon.sparklabs.com ([66.185.22.121]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1k67zA-00BlYp-Qp for openvpn-devel@lists.sourceforge.net; Thu, 13 Aug 2020 07:49:19 +0000 Received: from silicon.sparklabs.com (localhost [127.0.0.1]) by silicon.sparklabs.com (Postfix) with ESMTP id 4BRyrD5gczzPv6d for ; Thu, 13 Aug 2020 07:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sparklabs.com; h= content-transfer-encoding:mime-version:x-mailer:message-id:date :date:subject:subject:to:from:from; s=dkim; t=1597303772; x= 1599895773; bh=1vyqw5ID+rK5EymQrVtfgyxEr/ZiqJIJqwGv70K6f2U=; b=W GZL8MfjliNPzrUZ6vFzM5FB+aF77GO/hxnHDmTJiBFxlfqFc/OM5S50SsHrUJZ4l LAd81PGHPaffyoFNbRtO6wcsvqQB9PwaPgzUgq6L56bZKALvtqJoLptDf6jaxgy5 tbTamfIhFs/36QI5jFqCklrHM6xvSMFZ39gpw6LsM4= Received: from silicon.sparklabs.com ([127.0.0.1]) by silicon.sparklabs.com (silicon.sparklabs.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vx4APzfRsytW for ; Thu, 13 Aug 2020 07:29:32 +0000 (UTC) Received: from ubuntu20.localdomain (pa49-195-187-138.pa.nsw.optusnet.com.au [49.195.187.138]) by silicon.sparklabs.com (Postfix) with ESMTPSA id 4BRyrC40ppzPsgF; Thu, 13 Aug 2020 07:29:31 +0000 (UTC) From: Eric Thorpe To: openvpn-devel@lists.sourceforge.net Date: Thu, 13 Aug 2020 00:29:22 -0700 Message-Id: <20200813072923.24385-1-eric@sparklabs.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: sparklabs.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1k67zA-00BlYp-Qp Subject: [Openvpn-devel] [PATCH 1/2] Send auth-fail messages to clients on renegotiation failures via auth-token or user-pass expiry 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 Signed-off-by: Eric Thorpe --- src/openvpn/multi.c | 2 ++ src/openvpn/push.c | 30 ++++++++++++++++++++++++++++++ src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify.c | 7 +++++++ 4 files changed, 40 insertions(+) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 13738180..288680c9 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -2689,6 +2689,8 @@ multi_connection_established(struct multi_context *m, struct multi_instance *mi) mi->context.c2.context_auth = CAS_FAILED; } + /* Set connection established for reneg handling */ + mi->context.c2.tls_multi->connection_established = true; /* increment number of current authenticated clients */ ++m->n_clients; diff --git a/src/openvpn/push.c b/src/openvpn/push.c index e0d2eeaf..3567b22d 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -311,6 +311,36 @@ send_auth_pending_messages(struct context *c, const char *extra) return true; } +/* +* Send auth failed message from server to client without scheduling. +* Main use for queuing a message during renegotiation +*/ +void +send_push_reply_auth_failed(struct tls_multi *multi, const char *client_reason) +{ + struct gc_arena gc = gc_new(); + static const char auth_failed[] = "AUTH_FAILED"; + size_t len; + + len = (client_reason ? strlen(client_reason)+1 : 0) + sizeof(auth_failed); + if (len > PUSH_BUNDLE_SIZE) + { + len = PUSH_BUNDLE_SIZE; + } + + { + struct buffer buf = alloc_buf_gc(len, &gc); + buf_printf(&buf, auth_failed); + if (client_reason) + { + buf_printf(&buf, ",%s", client_reason); + } + send_control_channel_string_dowork(multi, BSTR(&buf), D_PUSH); + } + + gc_free(&gc); +} + /* * Send restart message from server to client. */ diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index 96897e48..b5cc9dc9 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -576,6 +576,7 @@ struct tls_multi char *remote_ciphername; /**< cipher specified in peer's config file */ + bool connection_established; /** Notifies future auth calls this is a reneg */ /* * Our session objects. */ diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 97ccb93b..8d8531c7 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -1318,6 +1318,7 @@ verify_user_pass(struct user_pass *up, struct tls_multi *multi, } else { + send_push_reply_auth_failed(multi, "SESSION:Auth-token expired"); wipe_auth_token(multi); ks->authenticated = KS_AUTH_FALSE; msg(M_WARN, "TLS: Username/auth-token authentication " @@ -1432,6 +1433,12 @@ verify_user_pass(struct user_pass *up, struct tls_multi *multi, } else { + if (multi->connection_established) + { + /* Notify the client */ + send_push_reply_auth_failed(multi, "SESSION:Auth failed"); + + } ks->authenticated = KS_AUTH_FALSE; msg(D_TLS_ERRORS, "TLS Auth Error: Auth Username/Password verification failed for peer"); } From patchwork Wed Aug 12 21:29:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Thorpe X-Patchwork-Id: 1383 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id iJDiBKfwNF/SOgAAIUCqbw for ; Thu, 13 Aug 2020 03:49:59 -0400 Received: from proxy12.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net with LMTP id 0I6TA6fwNF8FXgAApN4f7A (envelope-from ) for ; Thu, 13 Aug 2020 03:49:59 -0400 Received: from smtp15.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.iad3b.rsapps.net with LMTP id WBLqN6bwNF8ZOAAAEsW3lA ; Thu, 13 Aug 2020 03:49:58 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp15.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=sparklabs.com; dmarc=none (p=nil; dis=none) header.from=sparklabs.com X-Suspicious-Flag: YES X-Classification-ID: 958e1dca-dd39-11ea-844d-5254003d6d3a-1-1 Received: from [216.105.38.7] ([216.105.38.7:38764] helo=lists.sourceforge.net) by smtp15.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 90/5C-05486-6A0F43F5; Thu, 13 Aug 2020 03:49:58 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1k67z6-0001uz-QU; Thu, 13 Aug 2020 07:49:12 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k67z4-0001uq-SL for openvpn-devel@lists.sourceforge.net; Thu, 13 Aug 2020 07:49:10 +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:Cc:To:From:Sender:Reply-To: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=6wI+x0+entPrq0nsnwl2vIYgXWOTNjTr5HhICNWQOZM=; b=EW2AQuVRrQm50Wqw+QXHB58uVR cRJED/k8yIDjkbMaUo/mkWk2id3jk2AXS9eSe7jKLlW8+UnVOWALQRYGiS0GxVRp3lTpyVcnXcUny znesVh7EHPVWSHd28CqPEqjq8/7Mp2naXn/6STlZbwVw6IbAJFPKOv0Z2Rx/u4DG6I9Y=; 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:Cc:To:From:Sender:Reply-To: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=6wI+x0+entPrq0nsnwl2vIYgXWOTNjTr5HhICNWQOZM=; b=kkyvi0R1nZuvvA2NsrZkxs2zSq YEajNm6vINK2At6m7UlzsYIqv7jZ4b8egV323Y00cds4tk5qtS8EiUflWjv+1AgGFBnvXR6QKL6WX zQ8Rs6iOmKqzeK552WyNtU2VsdSnAaL9PMGGcFFBGBud3jx6phLydq27k3k6vRvUPAdU=; Received: from silicon.sparklabs.com ([66.185.22.121]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1k67z0-008v7P-SO for openvpn-devel@lists.sourceforge.net; Thu, 13 Aug 2020 07:49:10 +0000 Received: from silicon.sparklabs.com (localhost [127.0.0.1]) by silicon.sparklabs.com (Postfix) with ESMTP id 4BRyrG2GmhzPv6n for ; Thu, 13 Aug 2020 07:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sparklabs.com; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:to:from:from; s= dkim; t=1597303774; x=1599895775; bh=/+ud/qK4um3huYrkWGQwzQa3kCH er6vj8iw9vo3iTj8=; b=Jf635LtHk1PKJBlBVCLKJzGGlAOGqCU7Upd302U1i1U B2tFXJK8sx19npcMk52mG3PivdvVEjFVgSoPrdoSUcE9ftlQQxdCIVOlkR2MbHHb amiya03czM7SpOXwtAL4P3qtkjhtYy4ctTSPNZzBZtrXlLVGiaccc8VtWZLNrJqo = Received: from silicon.sparklabs.com ([127.0.0.1]) by silicon.sparklabs.com (silicon.sparklabs.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3u_VOkhZl8BL for ; Thu, 13 Aug 2020 07:29:34 +0000 (UTC) Received: from ubuntu20.localdomain (pa49-195-187-138.pa.nsw.optusnet.com.au [49.195.187.138]) by silicon.sparklabs.com (Postfix) with ESMTPSA id 4BRyrF0fydzPsgF; Thu, 13 Aug 2020 07:29:32 +0000 (UTC) From: Eric Thorpe To: openvpn-devel@lists.sourceforge.net Date: Thu, 13 Aug 2020 00:29:23 -0700 Message-Id: <20200813072923.24385-2-eric@sparklabs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200813072923.24385-1-eric@sparklabs.com> References: <20200813072923.24385-1-eric@sparklabs.com> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: sparklabs.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1k67z0-008v7P-SO Subject: [Openvpn-devel] [PATCH 2/2] Allows a plugin to provide a client_reason for authentication failure 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 Signed-off-by: Eric Thorpe --- src/openvpn/ssl_verify.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 8d8531c7..356b30fd 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -1157,6 +1157,9 @@ verify_user_pass_plugin(struct tls_session *session, struct tls_multi *multi, /* Is username defined? */ if ((session->opt->ssl_flags & SSLF_AUTH_USER_PASS_OPTIONAL) || strlen(up->username)) { + struct plugin_return pr, prfetch; + plugin_return_init(&pr); + /* set username/password in private env space */ setenv_str(session->opt->es, "username", up->username); setenv_str(session->opt->es, "password", up->password); @@ -1180,7 +1183,23 @@ verify_user_pass_plugin(struct tls_session *session, struct tls_multi *multi, #endif /* call command */ - retval = plugin_call(session->opt->plugins, OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY, NULL, NULL, session->opt->es); + retval = plugin_call(session->opt->plugins, OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY, NULL, &pr, session->opt->es); + + /* Fetch client reason */ + plugin_return_get_column(&pr, &prfetch, "client_reason"); + if (plugin_return_defined(&prfetch)) + { + int i; + for (i = 0; i < prfetch.n; ++i) + { + if (prfetch.list[i] && prfetch.list[i]->value) + { + auth_set_client_reason(multi, prfetch.list[i]->value); + } + } + } + + plugin_return_free(&pr); #ifdef PLUGIN_DEF_AUTH /* purge auth control filename (and file itself) for non-deferred returns */ @@ -1436,8 +1455,16 @@ verify_user_pass(struct user_pass *up, struct tls_multi *multi, if (multi->connection_established) { /* Notify the client */ - send_push_reply_auth_failed(multi, "SESSION:Auth failed"); - + const char *client_reason; + if (multi->client_reason != NULL) + { + client_reason = multi->client_reason; + } + else + { + client_reason = "SESSION:Auth failed"; + } + send_push_reply_auth_failed(multi, client_reason); } ks->authenticated = KS_AUTH_FALSE; msg(D_TLS_ERRORS, "TLS Auth Error: Auth Username/Password verification failed for peer");