Tolerate DTLS alerts with an incorrect version number
authorMatt Caswell <matt@openssl.org>
Fri, 5 Jan 2018 10:12:29 +0000 (10:12 +0000)
committerMatt Caswell <matt@openssl.org>
Tue, 9 Jan 2018 22:00:53 +0000 (22:00 +0000)
In the case of a protocol version alert being sent by a peer the record
version number may not be what we are expecting. In DTLS records with an
unexpected version number are silently discarded. This probably isn't
appropriate for alerts, so we tolerate a mismatch in the minor version
number.

This resolves an issue reported on openssl-users where an OpenSSL server
chose DTLS1.0 but the client was DTLS1.2 only and sent a protocol_version
alert with a 1.2 record number. This was silently ignored by the server.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5018)

ssl/record/ssl3_record.c

index 28ee2cc00587aa4d6af6371b24d777fbcb13394b..a08230da4b125b7a38cc8a162fd14a968b6905b5 100644 (file)
@@ -1875,8 +1875,11 @@ int dtls1_get_record(SSL *s)
 
         n2s(p, rr->length);
 
 
         n2s(p, rr->length);
 
-        /* Lets check version */
-        if (!s->first_packet) {
+        /*
+         * Lets check the version. We tolerate alerts that don't have the exact
+         * version number (e.g. because of protocol version errors)
+         */
+        if (!s->first_packet && rr->type != SSL3_RT_ALERT) {
             if (version != s->version) {
                 /* unexpected version, silently discard */
                 rr->length = 0;
             if (version != s->version) {
                 /* unexpected version, silently discard */
                 rr->length = 0;