Skip to content

Commit

Permalink
Fix a mem leak in NPN handling
Browse files Browse the repository at this point in the history
If a server sent multiple NPN extensions in a single ClientHello then a
mem leak can occur. This will only happen where the client has requested
NPN in the first place. It does not occur during renegotiation. Therefore
the maximum that could be leaked in a single connection with a malicious
server is 64k (the maximum size of the ServerHello extensions section). As
this is client side, only occurs if NPN has been requested and does not
occur during renegotiation this is unlikely to be exploitable.

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
  • Loading branch information
mattcaswell committed Sep 22, 2016
1 parent f6a7505 commit 6d32c2a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ssl/t1_lib.c
Expand Up @@ -2405,6 +2405,11 @@ static int ssl_scan_serverhello_tlsext(SSL *s, PACKET *pkt, int *al)
*al = TLS1_AD_INTERNAL_ERROR;
return 0;
}
/*
* Could be non-NULL if server has sent multiple NPN extensions in
* a single Serverhello
*/
OPENSSL_free(s->next_proto_negotiated);
s->next_proto_negotiated = OPENSSL_malloc(selected_len);
if (s->next_proto_negotiated == NULL) {
*al = TLS1_AD_INTERNAL_ERROR;
Expand Down

0 comments on commit 6d32c2a

Please sign in to comment.