Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2079?usp=email

to review the following change.


Change subject: tls_crypt: Wipe the tls-crypt-v2 client key copies
......................................................................

tls_crypt: Wipe the tls-crypt-v2 client key copies

tls_crypt_v2_init_client_key() reads the client key into a struct key2
on the stack, copies it to *original_key and returns without clearing
it, so every client start leaves the tls-crypt-v2 client key on the
stack. crypto_read_openvpn_key() does the same copy for tls-auth and
tls-crypt keys and clears its struct key2 afterwards; do the same here.

The --genkey tls-crypt-v2-client sanity check in
tls_crypt_v2_write_client_key_file() has two more copies:
- keydata, the struct key2 that tls_crypt_v2_init_client_key() fills;
  clear it after use.
- check_wrapped_client_key, the decoded key file buffer: the client key
  is still in front of the wrapped key when it is freed. Clear it with
  buf_clear() before free_buf(), as do_close_free_key_schedule() does
  for the client's tls_crypt_v2_wkc.

Assisted-by: Claude Code:claude-opus-5-5
Change-Id: I8e02b4cf39cc431f1f2c058db95997c8907557c0
Signed-off-by: Hansaem Wi <[email protected]>
---
M src/openvpn/tls_crypt.c
1 file changed, 3 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/79/2079/1

diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c
index 23c7975..ee4acdf 100644
--- a/src/openvpn/tls_crypt.c
+++ b/src/openvpn/tls_crypt.c
@@ -331,6 +331,7 @@

     tls_crypt_v2_load_client_key(key, &key2, false);
     *original_key = key2;
+    secure_memzero(&key2, sizeof(key2));

     *wkc_buf = client_key;
 }
@@ -783,6 +784,7 @@
     tls_crypt_v2_init_client_key(&check_client_key, &keydata, 
&check_wrapped_client_key, client_file,
                                  client_inline);
     free_key_ctx_bi(&check_client_key);
+    secure_memzero(&keydata, sizeof(keydata));

     /* Sanity check: unwrap and load client key (as "server") */
     struct buffer check_metadata = alloc_buf_gc(TLS_CRYPT_V2_MAX_METADATA_LEN, 
&gc);
@@ -793,6 +795,7 @@
     ASSERT(tls_crypt_v2_unwrap_client_key(&check_client_key2, &check_metadata,
                                           check_wrapped_client_key, 
&server_key));
     secure_memzero(&check_client_key2, sizeof(check_client_key2));
+    buf_clear(&check_wrapped_client_key);
     free_buf(&check_wrapped_client_key);

 cleanup:

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2079?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I8e02b4cf39cc431f1f2c058db95997c8907557c0
Gerrit-Change-Number: 2079
Gerrit-PatchSet: 1
Gerrit-Owner: Hansaem Wi <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to