svn commit: r295060 - stable/9/crypto/openssl/ssl

Xin LI delphij at FreeBSD.org
Sat Jan 30 06:09:40 UTC 2016


Author: delphij
Date: Sat Jan 30 06:09:38 2016
New Revision: 295060
URL: https://svnweb.freebsd.org/changeset/base/295060

Log:
  Fix OpenSSL SSLv2 ciphersuite downgrade vulnerability.
  
  Security:	CVE-2015-3197
  Security:	FreeBSD-SA-16:11.openssl

Modified:
  stable/9/crypto/openssl/ssl/s2_srvr.c

Modified: stable/9/crypto/openssl/ssl/s2_srvr.c
==============================================================================
--- stable/9/crypto/openssl/ssl/s2_srvr.c	Sat Jan 30 04:16:05 2016	(r295059)
+++ stable/9/crypto/openssl/ssl/s2_srvr.c	Sat Jan 30 06:09:38 2016	(r295060)
@@ -396,7 +396,7 @@ static int get_client_master_key(SSL *s)
         }
 
         cp = ssl2_get_cipher_by_char(p);
-        if (cp == NULL) {
+        if (cp == NULL || sk_SSL_CIPHER_find(s->session->ciphers, cp) < 0) {
             ssl2_return_error(s, SSL2_PE_NO_CIPHER);
             SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_NO_CIPHER_MATCH);
             return (-1);
@@ -687,8 +687,12 @@ static int get_client_hello(SSL *s)
             prio = cs;
             allow = cl;
         }
+
+        /* Generate list of SSLv2 ciphers shared between client and server */
         for (z = 0; z < sk_SSL_CIPHER_num(prio); z++) {
-            if (sk_SSL_CIPHER_find(allow, sk_SSL_CIPHER_value(prio, z)) < 0) {
+            const SSL_CIPHER *cp = sk_SSL_CIPHER_value(prio, z);
+            if ((cp->algorithms & SSL_SSLV2) == 0 ||
+                sk_SSL_CIPHER_find(allow, cp) < 0) {
                 (void)sk_SSL_CIPHER_delete(prio, z);
                 z--;
             }
@@ -697,6 +701,13 @@ static int get_client_hello(SSL *s)
             sk_SSL_CIPHER_free(s->session->ciphers);
             s->session->ciphers = prio;
         }
+
+        /* Make sure we have at least one cipher in common */
+        if (sk_SSL_CIPHER_num(s->session->ciphers) == 0) {
+            ssl2_return_error(s, SSL2_PE_NO_CIPHER);
+            SSLerr(SSL_F_GET_CLIENT_HELLO, SSL_R_NO_CIPHER_MATCH);
+            return -1;
+        }
         /*
          * s->session->ciphers should now have a list of ciphers that are on
          * both the client and server. This list is ordered by the order the


More information about the svn-src-all mailing list