From 56d250321ea9dfa66ea9afa599f12c83a4147c86 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Tue, 23 Jun 2015 16:20:13 -0700 Subject: Fixes for CVE-2015-1791. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a NewSessionTicket is received by a multi-threaded client when attempting to reuse a previous ticket then a race condition can occur potentially leading to a double free of the ticket data. This change cherry-picks the following BoringSSL changes: b31040d0 – Get rid of CERT_PKEY slots in SESS_CERT. fd67aa8c – Add SSL_SESSION_from_bytes. 95d31825 – Duplicate SSL_SESSIONs when renewing them. d65bb78c – Add SSL_initial_handshake_complete. 680ca961 – Preserve session->sess_cert on ticket renewal. Change-Id: I474065330842e4ab0066b2485c1489a50e4dfd5b --- src/ssl/ssl_lib.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ssl/ssl_lib.c') diff --git a/src/ssl/ssl_lib.c b/src/ssl/ssl_lib.c index e95226f..9e1e308 100644 --- a/src/ssl/ssl_lib.c +++ b/src/ssl/ssl_lib.c @@ -1975,8 +1975,16 @@ void ssl_update_cache(SSL *s, int mode) { return; } + int has_new_session = !s->hit; + if (!s->server && s->tlsext_ticket_expected) { + /* A client may see new sessions on abbreviated handshakes if the server + * decides to renew the ticket. Once the handshake is completed, it should + * be inserted into the cache. */ + has_new_session = 1; + } + SSL_CTX *ctx = s->initial_ctx; - if ((ctx->session_cache_mode & mode) == mode && !s->hit && + if ((ctx->session_cache_mode & mode) == mode && has_new_session && ((ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_STORE) || SSL_CTX_add_session(ctx, s->session)) && ctx->new_session_cb != NULL) { @@ -2960,6 +2968,10 @@ err: return 0; } +int SSL_initial_handshake_complete(const SSL *ssl) { + return ssl->s3->initial_handshake_complete; +} + int SSL_CTX_sess_connect(const SSL_CTX *ctx) { return 0; } int SSL_CTX_sess_connect_good(const SSL_CTX *ctx) { return 0; } int SSL_CTX_sess_connect_renegotiate(const SSL_CTX *ctx) { return 0; } -- cgit v1.1