diff --git a/src/tls13.c b/src/tls13.c index ecfd5946dd..518d7e4aa1 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -5452,7 +5452,6 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, if (args->pv.major != ssl->version.major || args->pv.minor != tls12minor) { - SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version); WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); return VERSION_ERROR; } @@ -5557,14 +5556,14 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, #endif ssl->options.haveEMS = 0; if (args->pv.minor < ssl->options.minDowngrade) { - SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version); + WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); return VERSION_ERROR; } #ifndef WOLFSSL_NO_TLS12 ssl->options.tls1_3 = 0; return DoServerHello(ssl, input, inOutIdx, helloSz); #else - SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version); + WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); return VERSION_ERROR; #endif } @@ -5586,10 +5585,24 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, return ret; } if (!foundVersion) { + /* RFC 8446 4.1.4: "The server's extensions MUST contain + * 'supported_versions'." (also 9.2: "supported_versions" is + * REQUIRED for all ... HelloRetryRequest messages). The HRR random + * unambiguously identifies a TLS 1.3 server, so its absence is not + * a downgrade attempt but a missing mandatory extension, which per + * the "missing_extension" alert definition must be reported as + * such. Return INCOMPLETE_DATA (which maps to a missing_extension + * alert) and let the caller emit the alert via + * TranslateErrorToAlert(). */ + if (*extMsgType == hello_retry_request) { + WOLFSSL_MSG("HelloRetryRequest missing supported_versions " + "extension"); + WOLFSSL_ERROR_VERBOSE(INCOMPLETE_DATA); + return INCOMPLETE_DATA; + } if (!ssl->options.downgrade) { WOLFSSL_MSG("Server trying to downgrade to version less than " "TLS v1.3"); - SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version); WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); return VERSION_ERROR; } @@ -5608,14 +5621,12 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, if (!ssl->options.dtls && args->pv.minor < ssl->options.minDowngrade) { - SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version); WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); return VERSION_ERROR; } if (ssl->options.dtls && args->pv.minor > ssl->options.minDowngrade) { - SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version); WOLFSSL_ERROR_VERBOSE(VERSION_ERROR); return VERSION_ERROR; }