From f66f8a4491f5c2207ed054fc35eb6a479ab8ecdc Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 8 May 2017 13:10:26 +0100 Subject: [PATCH] Reject unknown warning alerts in TLSv1.3 Reviewed-by: Tim Hudson (Merged from https://github.com/openssl/openssl/pull/3436) --- ssl/record/rec_layer_s3.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 60bfd3c798..8d0a97be98 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -1488,6 +1488,15 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, s->shutdown |= SSL_RECEIVED_SHUTDOWN; return 0; } + /* + * Apart from close_notify the only other warning alert in TLSv1.3 + * is user_cancelled - which we just ignore. + */ + if (SSL_IS_TLS13(s) && alert_descr != SSL_AD_USER_CANCELLED) { + al = SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNKNOWN_ALERT_TYPE); + goto f_err; + } /* * This is a warning but we receive it if we requested * renegotiation and the peer denied it. Terminate with a fatal @@ -1496,7 +1505,7 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, * future we might have a renegotiation where we don't care if * the peer refused it where we carry on. */ - else if (alert_descr == SSL_AD_NO_RENEGOTIATION) { + if (alert_descr == SSL_AD_NO_RENEGOTIATION) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_NO_RENEGOTIATION); goto f_err;