From patchwork Fri Nov 20 05:04:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1530 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director14.mail.ord1d.rsapps.net ([172.30.191.6]) by backend41.mail.ord1d.rsapps.net with LMTP id 6DGTAk/pt1/6AQAAqwncew (envelope-from ) for ; Fri, 20 Nov 2020 11:05:35 -0500 Received: from proxy15.mail.ord1d.rsapps.net ([172.30.191.6]) by director14.mail.ord1d.rsapps.net with LMTP id oFdlAk/pt1+BQwAAeJ7fFg (envelope-from ) for ; Fri, 20 Nov 2020 11:05:35 -0500 Received: from smtp8.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.ord1d.rsapps.net with LMTPS id UA4nAk/pt18PLwAAAY1PeQ (envelope-from ) for ; Fri, 20 Nov 2020 11:05:35 -0500 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: smtp8.gate.ord1d.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: 37f3145e-2b4a-11eb-8812-5254001e5a60-1-1 Received: from [216.105.38.7] ([216.105.38.7:37510] helo=lists.sourceforge.net) by smtp8.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id F6/79-26568-D49E7BF5; Fri, 20 Nov 2020 11:05:34 -0500 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kg8u0-0006Vt-4Q; Fri, 20 Nov 2020 16:04:48 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kg8tx-0006VZ-Qo for openvpn-devel@lists.sourceforge.net; Fri, 20 Nov 2020 16:04:45 +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=ay4F2hoS3txfuFERAwrUwOmhomurPjubIMnl9GMfMa4=; b=Tp7hRJrVTResMFLo4Dc3rwyrbf UhEh1/CZezaVfeNeyJWyxoaZsjP2iPWwI+gwwz7EkehRlQN7knBV2bv+uHiuMKKUKXXXsRohKqIXI aPOCER5vMLWszX/+ULQA4Bech4OchTb+B+5Mxkkmy6uE4dx2eKzghPkrtPqepnozLiRo=; 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=ay4F2hoS3txfuFERAwrUwOmhomurPjubIMnl9GMfMa4=; b=Yry3a4FUyZiWF6l7HlJqWpVlgm NmL390KF6TAHpqCoYCJWuNEYFGztlJzLJDu6trmtpBkymKn8gBC7J5KBkKRxjkAEfzt7IpjAGUrqq LyDBKvFF3IaPLKrEUTxJdH+lv3l9dX0sJxsFjxNRxJLrb9ozlgXfvCAS5DZrn1cMf8dQ=; 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 1kg8tp-003Ixk-DL for openvpn-devel@lists.sourceforge.net; Fri, 20 Nov 2020 16:04:45 +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 1kg8tW-0004ka-Co for openvpn-devel@lists.sourceforge.net; Fri, 20 Nov 2020 17:04:18 +0100 Received: (nullmailer pid 17737 invoked by uid 10006); Fri, 20 Nov 2020 16:04:18 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 20 Nov 2020 17:04:18 +0100 Message-Id: <20201120160418.17690-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.2 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 X-Headers-End: 1kg8tp-003Ixk-DL Subject: [Openvpn-devel] [PATCH] Fix port-share option with TLS-Crypt v2 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 The port-share option assumed that all openvpn initial reset packets are between 14 and 255 bytes long. This is not true for tls-crypt-v2. --- src/openvpn/ps.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index 2089e6b9..cd00bc23 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -983,10 +983,36 @@ is_openvpn_protocol(const struct buffer *buf) const int len = BLEN(buf); if (len >= 3) { - return p[0] == 0 - && p[1] >= 14 - && (p[2] == (P_CONTROL_HARD_RESET_CLIENT_V2 << P_OPCODE_SHIFT) - || p[2] == (P_CONTROL_HARD_RESET_CLIENT_V3 << P_OPCODE_SHIFT)); + if (p[2] == (P_CONTROL_HARD_RESET_CLIENT_V3 << P_OPCODE_SHIFT)) + { + /* WKc is at least 306 byte (not including metadata): + * + * 16 bit len + 256 bit HMAC + 128 bit IV + 2048 bit Kc = 2448 bit + * + * This is increased by the normal length of client handshake + + * tls-crypt overhead (32) + * + * For metadata tls-crypt-v2.txt does not explicitly specify + * an upper limit but we also have TLS_CRYPT_V2_MAX_WKC_LEN + * as 1024 bytes. We err on the safe side with 255 extra overhead + * + * We don't do the 2 byte check for tls-crypt-v2 because it is very + * unrealistic to have only 2 bytes available. + */ + int plen = (p[0] << 8) | p[1]; + + return (plen >= 352 && plen < (1024 + 255)); + } + else + { + /* first two bytes are the size field. This is an openvpn packet + * between 14 bytes and 255 (otherwise p[1] would be 01 or larger. + * on the hard reset packet key_id is zero, so only the opcode + * part is non-null */ + return p[0] == 0 + && p[1] >= 14 + && (p[2] == (P_CONTROL_HARD_RESET_CLIENT_V2 << P_OPCODE_SHIFT)); + } } else if (len >= 2) {