From patchwork Sat Jul 25 13:51:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1338 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id oOuXO8XFHF+EQQAAIUCqbw for ; Sat, 25 Jul 2020 19:52:38 -0400 Received: from proxy18.mail.iad3b.rsapps.net ([172.31.255.6]) by director7.mail.ord1d.rsapps.net with LMTP id OJw3OsXFHF/POwAAovjBpQ (envelope-from ) for ; Sat, 25 Jul 2020 19:52:37 -0400 Received: from smtp15.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy18.mail.iad3b.rsapps.net with LMTP id oGfjMsXFHF+yYQAA3NpJmQ ; Sat, 25 Jul 2020 19:52:37 -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; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: ea8f9f5e-ced1-11ea-9c75-5254003d6d3a-1-1 Received: from [216.105.38.7] ([216.105.38.7:44436] 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 5D/6C-22537-5C5CC1F5; Sat, 25 Jul 2020 19:52:37 -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 1jzTxI-0003Bb-Cg; Sat, 25 Jul 2020 23:51:52 +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 1jzTxG-0003BQ-Ud for openvpn-devel@lists.sourceforge.net; Sat, 25 Jul 2020 23:51:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding: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=7KUn/5KhPCMuJfIP/EuWuE8IkzEjHNPhPYb21KY+m2s=; b=QaK8aHEmcH7BtunwVoUtkH0Pto bu1FrUcQarYSfO8ax/TVqYH/fEDCfbj3pZmoj2ruZ78AJeOz2p4RmxFWU6b1m+xibSaUGJhNSnP8o ORv0P3WzE9uf8YGb3D3pD+dzQYrA9uQWqUYBN4Rb6+ieyULGT4iLqMo1qErlbg+vI16E=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding: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=7KUn/5KhPCMuJfIP/EuWuE8IkzEjHNPhPYb21KY+m2s=; b=HcoHbP3/Te9tK439Ex8q8E3m3+ RLebMn+PtQwAZrz8lqbdgUZoW8bilrv4lzD0Fmk6fGrP1YUjVdtqnBgd2xWv64+/lvhKoXki0iuum ch8Pp+NznLYig1HM69Q10Hs6urX+Fxq5FFt3WQAhTYBIBZe8fPdpORUu9srXVpUHHMBg=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jzTxF-0097OZ-P7 for openvpn-devel@lists.sourceforge.net; Sat, 25 Jul 2020 23:51:50 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1jzTx9-0006tn-CX for openvpn-devel@lists.sourceforge.net; Sun, 26 Jul 2020 01:51:43 +0200 Received: (nullmailer pid 22781 invoked by uid 10006); Sat, 25 Jul 2020 23:51:43 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Sun, 26 Jul 2020 01:51:43 +0200 Message-Id: <20200725235143.22736-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 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: rfc2549.org] 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 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.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1jzTxF-0097OZ-P7 Subject: [Openvpn-devel] [PATCH] Refuse PUSH_REQUEST as client/refactor process_incoming_push_request 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox When a server sends a client a push request, the client will reply with a push reply. The reply is bogus and almost empty since almost all the options that are normally set (remote ip etc) are unset. I checked 2.4 and master and this does not have any security implications or other bugs but it is still better to refuse this. This code also refactors the method to get rid of the ret variable to make the code flow easier to understand. Signed-off-by: Arne Schwabe --- src/openvpn/push.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 1c4f2033..84193afe 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -733,13 +733,19 @@ push_remove_option(struct options *o, const char *p) int process_incoming_push_request(struct context *c) { - int ret = PUSH_MSG_ERROR; + /* if we receive a message a client we do not want to reply to it + * so limit this to multi server */ + if (c->options.mode != MODE_SERVER) + { + return PUSH_MSG_ERROR; + } + if (tls_authentication_status(c->c2.tls_multi, 0) == TLS_AUTHENTICATION_FAILED || c->c2.context_auth == CAS_FAILED) { const char *client_reason = tls_client_reason(c->c2.tls_multi); send_auth_failed(c, client_reason); - ret = PUSH_MSG_AUTH_FAILURE; + return PUSH_MSG_AUTH_FAILURE; } else if (c->c2.context_auth == CAS_SUCCEEDED) { @@ -748,29 +754,27 @@ process_incoming_push_request(struct context *c) openvpn_time(&now); if (c->c2.sent_push_reply_expiry > now) { - ret = PUSH_MSG_ALREADY_REPLIED; + return PUSH_MSG_ALREADY_REPLIED; } - else - { - /* per-client push options - peer-id, cipher, ifconfig, ipv6-ifconfig */ - struct push_list push_list = { 0 }; - struct gc_arena gc = gc_new(); - if (prepare_push_reply(c, &gc, &push_list) - && send_push_reply(c, &push_list)) - { - ret = PUSH_MSG_REQUEST; - c->c2.sent_push_reply_expiry = now + 30; - } - gc_free(&gc); + int ret = PUSH_MSG_ERROR; + /* per-client push options - peer-id, cipher, ifconfig, ipv6-ifconfig */ + struct push_list push_list = { 0 }; + struct gc_arena gc = gc_new(); + + if (prepare_push_reply(c, &gc, &push_list) + && send_push_reply(c, &push_list)) + { + ret = PUSH_MSG_REQUEST; + c->c2.sent_push_reply_expiry = now + 30; } + gc_free(&gc); + return ret; } else { - ret = PUSH_MSG_REQUEST_DEFERRED; + return PUSH_MSG_REQUEST_DEFERRED; } - - return ret; } static void