Cleanse the SSLv3 MAC secret when we clean up the read record layer
authorMatt Caswell <matt@openssl.org>
Fri, 22 Jul 2022 13:16:33 +0000 (14:16 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 18 Aug 2022 15:38:13 +0000 (16:38 +0100)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18132)

ssl/record/methods/tls_common.c

index 0f56db5881c8da2c02c80e66246dfaab19185883..8b541061ba18f9fbf27f58d21e30eeca48cafa75 100644 (file)
@@ -1198,7 +1198,6 @@ tls_new_record_layer(OSSL_LIB_CTX *libctx, const char *propq, int vers,
 
 static void tls_int_free(OSSL_RECORD_LAYER *rl)
 {
-    /* TODO(RECLAYER): Cleanse sensitive fields */
     BIO_free(rl->prev);
     BIO_free(rl->bio);
     BIO_free(rl->next);
@@ -1210,6 +1209,9 @@ static void tls_int_free(OSSL_RECORD_LAYER *rl)
     COMP_CTX_free(rl->expand);
 #endif
 
+    if (rl->version == SSL3_VERSION)
+        OPENSSL_cleanse(rl->mac_secret, sizeof(rl->mac_secret));
+
     OPENSSL_free(rl);
 }