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"); }