From: "cron2 (Code Review)" Date: Sun, 8 Sep 2024 13:06:03 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <5c908f95843ca8ce386288f9b4df400227ede977-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="XrPeDK8fNPk="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: proxy.c: Clear sensitive data after use List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: selvanair Cc: flichtenheld , plaisthos , openvpn-devel --XrPeDK8fNPk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/72= 7?usp=3Demail ) Change subject: proxy.c: Clear sensitive data after use ...................................................................... proxy.c: Clear sensitive data after use Usage of credentials is a bit odd in this file. Actually the copy of "struct user_pass" kept in p->up is not required at all. It just defeats the purpose of auth-nocahe as it never gets cleared. Removing it is beyond the scope of this patch -- we just ensure it's purged after use. Change-Id: Ic6d63a319d272a56ac0e278f1356bc5241b56a34 Signed-off-by: Selva Nair Acked-by: Frank Lichtenheld Message-Id: <20240905100724.4105-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 061.html Signed-off-by: Gert Doering --- M src/openvpn/proxy.c 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/openvpn/proxy.c b/src/openvpn/proxy.c index 5de0da4..eddacc9 100644 --- a/src/openvpn/proxy.c +++ b/src/openvpn/proxy.c @@ -247,7 +247,9 @@ struct buffer out =3D alloc_buf_gc(strlen(p->up.username) + strlen(p->= up.password) + 2, gc); ASSERT(strlen(p->up.username) > 0); buf_printf(&out, "%s:%s", p->up.username, p->up.password); - return (const char *)make_base64_string((const uint8_t *)BSTR(&out), g= c); + char *ret =3D (char *)make_base64_string((const uint8_t *)BSTR(&out), = gc); + secure_memzero(BSTR(&out), out.len); + return ret; } static void @@ -736,6 +738,9 @@ ASSERT(0); } + /* clear any sensitive content in buf */ + secure_memzero(buf, sizeof(buf)); + /* send empty CR, LF */ if (!send_crlf(sd)) { @@ -983,6 +988,8 @@ { goto error; } + /* clear any sensitive content in buf */ + secure_memzero(buf, sizeof(buf)); /* receive reply from proxy */ if (!recv_line(sd, buf, sizeof(buf), get_server_poll_remai= ning_time(server_poll_timeout), true, NULL, signal_received)) @@ -1086,10 +1093,12 @@ #endif done: + purge_user_pass(&p->up, true); gc_free(&gc); return ret; error: + purge_user_pass(&p->up, true); register_signal(sig_info, SIGUSR1, "HTTP proxy error"); /* SOFT-SIGUSR= 1 -- HTTP proxy error */ gc_free(&gc); return ret; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/727?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ic6d63a319d272a56ac0e278f1356bc5241b56a34 Gerrit-Change-Number: 727 Gerrit-PatchSet: 2 Gerrit-Owner: selvanair Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --XrPeDK8fNPk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

proxy.c: Clear sensitive data after use
Usage of credentials is a bit odd in this file.
Actually the copy of &= quot;struct user_pass" kept in p->up is not
required at all. It = just defeats the purpose of auth-nocahe
as it never gets cleared.
Removing it is beyond the scope of this patch -- we just ensure
it'= s purged after use.

Change-Id: Ic6d63a319d272a56ac0e278f1356bc5241b5= 6a34
Signed-off-by: Selva Nair <selva.nair@...277...>
Acked-by:= Frank Lichtenheld <frank@...2641...>
Message-Id: <202409051007= 24.4105-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-= devel@lists.sourceforge.net/msg29061.html
Signed-off-by: Gert Doering &l= t;gert@...1296...>
---
M src/openvpn/proxy.c
1 file changed, 10= insertions(+), 1 deletion(-)

diff --git a/src/openvpn/proxy.c b/src/openvpn/proxy.c
i= ndex 5de0da4..eddacc9 100644
--- a/src/openvpn/proxy.c
+++ b/src/openvpn/proxy.c
@@ -247,7 +247,9 @@
struct buffer out =3D alloc_buf_gc(strlen(p->up.user= name) + strlen(p->up.password) + 2, gc);
ASSERT(str= len(p->up.username) > 0);
buf_printf(&out, &= quot;%s:%s", p->up.username, p->up.password);
- return (const char *)make_base64_str= ing((const uint8_t *)BSTR(&out), gc);
+ char *ret =3D (char *)make_base64_string((const u= int8_t *)BSTR(&out), gc);
+ secure_memzero(BSTR(&out), out.len);
+ return ret;
}

static void
@@ -736,6 +738,9 = @@
ASSERT(0);
}

+ = /* clear any sensitive content in buf */
+ secure_memzero(buf, sizeof(buf));<= br>+
/= * send empty CR, LF */
if (!send_crlf(sd))<= br> {
@@ -983,6 +988,8 @@
= {
goto error;
= }
+ /* clear any sensitive content in buf */
+ secure_memzero(bu= f, sizeof(buf));


/* rece= ive reply from proxy */
if (!recv_line(sd,= buf, sizeof(buf), get_server_poll_remaining_time(server_poll_timeout), tru= e, NULL, signal_received))
@@ -1086,10 +1093,12 @@ #endif

done:
+ purge_user_pass(&p->up, tru= e);
gc_free(&gc);
return ret;=

error:
+ purge_user_pass(&p->up, true);
= register_signal(sig_info, SIGUSR1, "HTTP proxy error")= ; /* SOFT-SIGUSR1 -- HTTP proxy error */
gc_free(&= gc);
return ret;

T= o view, visit change 727. To unsubscribe, or for help writing mail filters, visi= t settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic6d63a319d272a56ac0e278f135= 6bc5241b56a34
Gerrit-Change-Number: 727
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <selva.nair@...1354...= ..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--XrPeDK8fNPk=--