RT4304: Look for plaintext HTTP
authorRainer Jung <rainer.jung@kippdata.de>
Sat, 13 Feb 2016 13:03:23 +0000 (08:03 -0500)
committerRich Salz <rsalz@openssl.org>
Sat, 13 Feb 2016 19:29:26 +0000 (14:29 -0500)
Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/record/ssl3_record.c

index 60e8042f1d196eddd3934cc779793f937c4ad8ab..919202a46e41aece3fc56f3087f95aaa3ed98afe 100644 (file)
@@ -274,6 +274,21 @@ int ssl3_get_record(SSL *s)
             }
 
             if ((version >> 8) != SSL3_VERSION_MAJOR) {
             }
 
             if ((version >> 8) != SSL3_VERSION_MAJOR) {
+                if (s->first_packet) {
+                    /* Go back to start of packet, look at the five bytes
+                     * that we have. */
+                    p = RECORD_LAYER_get_packet(&s->rlayer);
+                    if (strncmp((char *)p, "GET ", 4) == 0 ||
+                        strncmp((char *)p, "POST ", 5) == 0 ||
+                        strncmp((char *)p, "HEAD ", 5) == 0 ||
+                        strncmp((char *)p, "PUT ", 4) == 0) {
+                        SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_HTTP_REQUEST);
+                        goto err;
+                    } else if (strncmp((char *)p, "CONNE", 5) == 0) {
+                        SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_HTTPS_PROXY_REQUEST);
+                        goto err;
+                    }
+                }
                 SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER);
                 goto err;
             }
                 SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_WRONG_VERSION_NUMBER);
                 goto err;
             }