From patchwork Wed Nov 25 21:30:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5790 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp6330377lad; Wed, 25 Nov 2026 13:30:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHHdQEfOJBa3yAaW8ZIMdZKqGNVYyvJWl6f0BV5FR212Ps0UwSd4UcgefCxCFbGWgZpfvuis70TAko=@openvpn.net X-Received: by 2002:a05:7301:6187:10b0:386:a193:7eeb with SMTP id 5a478bee46e88-386a1938b8dmr14497175eec.30.1795642230043; Wed, 25 Nov 2026 13:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795642230; cv=none; d=google.com; s=arc-20260327; b=D8xe3nKTdc/tENOh6GMTfKeKG1tckhSsJaSqJsffnURqvmgQucTONEuqB7Cbdb9Wi8 zZttKkqlFv4x9emyLSzP52Pxdy8y9ro0TKveD1iE6rG1KjSn15vezJpOTToLLjKvdqRd 5yVJLs8rZYik3Wtls4S5iTTR4KTxDUt4el4tn6LUh5uX2bqmbtQLj2Fto9IvYZX1SuwA DZyPY2QdjiamMUuUjD9DF4ROsWE2KKPbi0D8s23uYi5A0QMhtub3M58VukQ3vjowOM42 b5M6/F8U3HKUhK/VGXFXUjiYhsFydsR6gkQo6I7Vz4aMOhmV/sKtpWdsGeLHUi7L6ugU l9Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=6i5eLf+uu92xP8+/NQv0Rya4eQBCX8ugh2A0Y5rBJpY=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=Mrftg+mXs1jKfvsDRzymag5X34mWWy3fNpVPJ1Pq8nosdzRuTtcNgF7yQkOsDkv7WE 46zzVNLAtTEUvTr+z/UyJVJxuCHrhh1Gh0G/F9w14M1TUY/BH8dsUhC4r1kR81rK872y 9NkAlbPPbFaxhs6sc3sfo4KvQkgKQQPW5yW7lgQ4zV/fqtdN99sofZXDdzJNs1mlmYD2 GoWx+H0aeMmbtqFWtLBXkgHUHBEys3hvJ+j9SjdfXornTKit9y25mm5YxMe69c4LG/Wr sEWqA5VXH14P3VEbNSj+pByHsKdU7kV4+JsbT7ykzyFFWCFCsaFKDOKXQhOFNYaHhPEQ 7zLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="Huj/CsjR"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Rh0VHxFn; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Al5ptQAg; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-385682993dbsi45735210eec.59.2026.11.25.13.30.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Nov 2026 13:30:30 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="Huj/CsjR"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Rh0VHxFn; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Al5ptQAg; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=6i5eLf+uu92xP8+/NQv0Rya4eQBCX8ugh2A0Y5rBJpY=; b=Huj/CsjRXIacH6 MlcS6x/eN39grPwBX852RH1tJvFdOquezR+YDdryJK018f8ivgnXKfsJ/zfUrKxeJL4bHcc+uGFeB 19Z2xxuhH2ZPZzJRUz2Ueo9TdbVMv21PLAlV4abae7yI/2ZhPJehenjMWSYjUvWfKOCZk10O1VZIY HeA=; 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.100.1) (envelope-from ) id 1xWKZL-000000004ou-0h8r; Wed, 25 Nov 2026 21:30:23 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xWKZK-000000004oo-0sH4 for openvpn-devel@lists.sourceforge.net; Wed, 25 Nov 2026 21:30:22 +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:To:From:Sender:Reply-To:Cc: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-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wkkxzKblg6QHgtyha2Ak0F+pDre4J/Nf8P7EmaehV8Q=; b=Rh0VHxFnzRpz3w0KVmpbxGsNav hbZjE0TFybO3lxXLh8Euk/BdEn5l2sApALF2/Ap2LjHphcKvqMIYNMapsGlNYMVvSKQCM2yYxtuof tgQRzDCJeqoe4pkqOBSnm9CWRZdKZK1sSq+egGPm0spY+iB4hehE4EHvb8yCxHC2AN6o=; 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:To:From:Sender:Reply-To:Cc: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-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wkkxzKblg6QHgtyha2Ak0F+pDre4J/Nf8P7EmaehV8Q=; b=Al5ptQAg9fMn5OX8AWE16opUTO lOl2lCMVqjdpj5pk6lVpd09fJaSQTbMa+HAO5zY1wQLxgSsM8XL4EjOaE8R1qIeNk2tbG8izf6qyx 5IytfKYArefmrSOdCp4F6djxnsom8kFDGZdycKQcpSwwhuPqLnFhWXVbwhvOsMdbGt9o=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xWKZI-000000002JP-20y1 for openvpn-devel@lists.sourceforge.net; Wed, 25 Nov 2026 21:30:22 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6APLUDM9015814 for ; Wed, 25 Nov 2026 22:30:13 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6APLUDYV015813 for openvpn-devel@lists.sourceforge.net; Wed, 25 Nov 2026 22:30:13 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 25 Nov 2026 22:30:07 +0100 Message-ID: <20261125213012.15799-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Razvan Cojocaru generate_auth_token() freed the previous token and its intermediate copies without wiping them, unlike wipe_auth_token(). crypto_pem_decode() in the mbed TLS backend freed its copy of the PEM key text [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xWKZI-000000002JP-20y1 Subject: [Openvpn-devel] [PATCH v2] Wipe auth token and PEM key copies before freeing them 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 X-GMAIL-THRID: 1882867347115696536 X-GMAIL-MSGID: 1882867347115696536 From: Razvan Cojocaru generate_auth_token() freed the previous token and its intermediate copies without wiping them, unlike wipe_auth_token(). crypto_pem_decode() in the mbed TLS backend freed its copy of the PEM key text the same way. Change-Id: I9d9b658a00f95ffdcd0db9abd0d8907618925746 Signed-off-by: Razvan Cojocaru Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2206 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2206 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/auth_token.c b/src/openvpn/auth_token.c index 261c7c2..d8e599b 100644 --- a/src/openvpn/auth_token.c +++ b/src/openvpn/auth_token.c @@ -271,10 +271,15 @@ ASSERT(buf_write(&session_token, b64output, strlen(b64output))); ASSERT(buf_write_u8(&session_token, 0)); + secure_memzero(b64output, strlen(b64output)); free(b64output); /* free the auth-token if defined, we will replace it with a new one */ - free(multi->auth_token); + if (multi->auth_token) + { + secure_memzero(multi->auth_token, strlen(multi->auth_token)); + free(multi->auth_token); + } multi->auth_token = string_alloc((char *)BPTR(&session_token), NULL); dmsg(D_SHOW_KEYS, "Generated token for client: %s (%s)", multi->auth_token, up->username); @@ -288,6 +293,8 @@ multi->auth_token_initial = string_alloc(multi->auth_token, NULL); } + buf_clear(&token); + buf_clear(&session_token); gc_free(&gc); } diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index ceaaad4..58c1fd2 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -1150,6 +1150,7 @@ } mbedtls_pem_free(&ctx); + buf_clear(&input); gc_free(&gc); return ret; }