Sanity check the ticket length before using key name/IV
authorMatt Caswell <matt@openssl.org>
Tue, 20 Feb 2018 10:20:20 +0000 (10:20 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 21 Feb 2018 11:26:25 +0000 (11:26 +0000)
This could in theory result in an overread - but due to the over allocation
of the underlying buffer does not represent a security issue.

Thanks to Fedor Indutny for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5417)

ssl/t1_lib.c

index 82ad601924e5d83936249f8e5430b977770ead1f..a1866235054447c434adc1872a992e008f6feece 100644 (file)
@@ -3505,6 +3505,10 @@ static int tls_decrypt_ticket(SSL *s, const unsigned char *etick,
     EVP_CIPHER_CTX ctx;
     SSL_CTX *tctx = s->initial_ctx;
 
+    /* Need at least keyname + iv */
+    if (eticklen < 16 + EVP_MAX_IV_LENGTH)
+        return 2;
+
     /* Initialize session ticket encryption and HMAC contexts */
     HMAC_CTX_init(&hctx);
     EVP_CIPHER_CTX_init(&ctx);