[Openvpn-devel,v2] Wipe auth token and PEM key copies before freeing them
Commit Message
From: Razvan Cojocaru <razvanc@mailbox.org>
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 <razvanc@mailbox.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
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 <frank@lichtenheld.com>
@@ -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);
}
@@ -1150,6 +1150,7 @@
}
mbedtls_pem_free(&ctx);
+ buf_clear(&input);
gc_free(&gc);
return ret;
}