From patchwork Fri Jul 17 11:28:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1302 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id KJgeF9YgEl8uJwAAIUCqbw for ; Fri, 17 Jul 2020 18:06:14 -0400 Received: from proxy9.mail.ord1d.rsapps.net ([172.30.191.6]) by director8.mail.ord1d.rsapps.net with LMTP id mP/nFtYgEl8uNwAAfY0hYg ; Fri, 17 Jul 2020 18:06:14 -0400 Received: from smtp10.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy9.mail.ord1d.rsapps.net with LMTP id 4N6sFtYgEl/ENAAA7h+8OQ ; Fri, 17 Jul 2020 18:06:14 -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: smtp10.gate.ord1c.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: ba895128-c879-11ea-83ca-0026b954785f-1-1 Received: from [216.105.38.7] ([216.105.38.7:43292] helo=lists.sourceforge.net) by smtp10.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 0C/AB-02906-5D0221F5; Fri, 17 Jul 2020 18:06:14 -0400 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 1jwXvc-00067O-45; Fri, 17 Jul 2020 21:30:00 +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 1jwXva-00067H-Hv for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2020 21:29:58 +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=vouaMioZV2jaqbEGXUsccR5ZAIA2DrFpCzwEbQ3udV0=; b=UxQCFVk3O68SRtmQK6BKd+PKlZ 0KWxe95jxMXoteVuw6b1BYCm2gSGN1rBucwGK4GSKYfkeqAIMpFWTE+mvfwCGVDSKe3pVZG9opDhA Fl6BQGz9VBK1V02KopV70q3u6tPdtROZGOqtIdae17QUGT9/NIoZuja9mTWuudtXonbA=; 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=vouaMioZV2jaqbEGXUsccR5ZAIA2DrFpCzwEbQ3udV0=; b=l qIBUP2ScKEp5WFfsjiqNg6n9gUYAcOJi+Pi9k62/FVq9iD7F6TSofp0pgIbbDSVuZLz0i7rRs3HUe HDmbUStbW9UpCU+uBZnXNRYwAcPYrh6iqGHSiwuJbniKGifqvJSZfhL59vRUXBF/YFOnd/R0UE5p7 G0g9ERWE/Au+sg5o=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jwXvV-004uwQ-8x for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2020 21:29:58 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Fri, 17 Jul 2020 23:28:20 +0200 Message-Id: <20200717212820.8998-1-a@unstable.cc> 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: unstable.cc] -0.0 SPF_PASS SPF: sender matches 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: 1jwXvV-004uwQ-8x Subject: [Openvpn-devel] [PATCH] options: don't leak inline'd key material in logfile 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox With the conversion of the introduction of a bool variable to signal when a certain string is a filename or the actual (inline'd) key material, the SHOW_STR() macro is now leaking the inline'd material to the log file. This happens because SHOW_STR will just print the content of the passed argument without any check. With the new logic this should not happen anymore. A new macro SHOW_STR_INLINE() is therefore introduced which will check the appropriate bool member before deciding to print the actual string content or not. Trac: #1304 Reported-by: Richard Bonhomme Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- src/openvpn/options.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index b6b8d769..8e9d845a 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -973,6 +973,10 @@ pull_filter_type_name(int type) #define SHOW_PARM(name, value, format) msg(D_SHOW_PARMS, " " #name " = " format, (value)) #define SHOW_STR(var) SHOW_PARM(var, (o->var ? o->var : "[UNDEF]"), "'%s'") +#define SHOW_STR_INLINE(var) SHOW_PARM(var, \ + o->var ## _inline ? "[INLINE]" : \ + (o->var ? o->var : "[UNDEF]"), \ + "'%s'") #define SHOW_INT(var) SHOW_PARM(var, o->var, "%d") #define SHOW_UINT(var) SHOW_PARM(var, o->var, "%u") #define SHOW_UNSIGNED(var) SHOW_PARM(var, o->var, "0x%08x") @@ -1322,7 +1326,7 @@ show_p2mp_parms(const struct options *o) SHOW_BOOL(auth_user_pass_verify_script_via_file); SHOW_BOOL(auth_token_generate); SHOW_INT(auth_token_lifetime); - SHOW_STR(auth_token_secret_file); + SHOW_STR_INLINE(auth_token_secret_file); #if PORT_SHARE SHOW_STR(port_share_host); SHOW_STR(port_share_port); @@ -1494,11 +1498,11 @@ show_connection_entry(const struct connection_entry *o) SHOW_INT(explicit_exit_notification); #endif - SHOW_STR(tls_auth_file); + SHOW_STR_INLINE(tls_auth_file); SHOW_PARM(key_direction, keydirection2ascii(o->key_direction, false, true), "%s"); - SHOW_STR(tls_crypt_file); - SHOW_STR(tls_crypt_v2_file); + SHOW_STR_INLINE(tls_crypt_file); + SHOW_STR_INLINE(tls_crypt_v2_file); } @@ -1697,7 +1701,7 @@ show_settings(const struct options *o) } #endif - SHOW_STR(shared_secret_file); + SHOW_STR_INLINE(shared_secret_file); SHOW_PARM(key_direction, keydirection2ascii(o->key_direction, false, true), "%s"); SHOW_STR(ciphername); SHOW_BOOL(ncp_enabled); @@ -1722,7 +1726,7 @@ show_settings(const struct options *o) SHOW_BOOL(tls_server); SHOW_BOOL(tls_client); SHOW_INT(key_method); - SHOW_STR(ca_file); + SHOW_STR_INLINE(ca_file); SHOW_STR(ca_path); SHOW_STR(dh_file); #ifdef ENABLE_MANAGEMENT @@ -1732,8 +1736,8 @@ show_settings(const struct options *o) } else #endif - SHOW_STR(cert_file); - SHOW_STR(extra_certs_file); + SHOW_STR_INLINE(cert_file); + SHOW_STR_INLINE(extra_certs_file); #ifdef ENABLE_MANAGEMENT if ((o->management_flags & MF_EXTERNAL_KEY)) @@ -1742,9 +1746,9 @@ show_settings(const struct options *o) } else #endif - SHOW_STR(priv_key_file); + SHOW_STR_INLINE(priv_key_file); #ifndef ENABLE_CRYPTO_MBEDTLS - SHOW_STR(pkcs12_file); + SHOW_STR_INLINE(pkcs12_file); #endif #ifdef ENABLE_CRYPTOAPI SHOW_STR(cryptoapi_cert); @@ -1756,7 +1760,7 @@ show_settings(const struct options *o) SHOW_STR(tls_export_cert); SHOW_INT(verify_x509_type); SHOW_STR(verify_x509_name); - SHOW_STR(crl_file); + SHOW_STR_INLINE(crl_file); SHOW_INT(ns_cert_type); { int i;