From: Matt Caswell Date: Thu, 8 May 2025 13:54:35 +0000 (+0100) Subject: Stop a TLSv1.3 server emitting an unsolicited PSK extension X-Git-Tag: openssl-3.0.17~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=440b362cac581658090c05c929afaf8f4aa0055a;p=thirdparty%2Fopenssl.git Stop a TLSv1.3 server emitting an unsolicited PSK extension If we attempt to accept a connection on an SSL object, and the application has set an SSL_SESSION on that SSL object then we can mistakenly believe that we are resuming and emit an unsolicited PSK extension back to the client. This can especially happen when using SSL_clear() which leaves any SSL_SESSION associated with the SSL object. See https://github.com/openssl/openssl/discussions/27563#discussioncomment-13049352 and https://github.com/openssl/openssl/discussions/24567 Reviewed-by: Todd Short Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27584) (cherry picked from commit aa8bca2e81030560d690cb68bbcbe8b7d00d1d29) --- diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index ec937a321c3..0a24c484150 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -612,6 +612,8 @@ int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello) SSL_TICKET_STATUS r; if (SSL_IS_TLS13(s)) { + SSL_SESSION_free(s->session); + s->session = NULL; /* * By default we will send a new ticket. This can be overridden in the * ticket processing. @@ -624,6 +626,7 @@ int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello) hello->pre_proc_exts, NULL, 0)) return -1; + /* If we resumed, s->session will now be set */ ret = s->session; } else { /* sets s->ext.ticket_expected */