From 00f613f62d286dbbdb816b486314c0dff864ac6b Mon Sep 17 00:00:00 2001 From: David Cooper Date: Thu, 14 Nov 2019 16:41:19 -0500 Subject: [PATCH] WIP: Don't call s_client for unsupported protocol versions This PR fixes a couple of places where "$OPENSSL s_client" is called with "-ssl3" even if SSLv3 is not supported. The fix in ciphers_by_strength() is easy, as the issue only occurs if "$using_sockets" is true. If SSLv3 (or TLSv1.3) is not supported, then testing using "$OPENSSL s_client" is skipped and all of the supported ciphers are found using tls_sockets(). The fix for run_tls_fallback_scsv() is more complicated. While it is easy to avoid calling "$OPENSSL s_client" with "-ssl3" if SSLv3 is not supported, it is not easy to determine the correct message to present to the user if support for SSLv3 (and possibly also TLSv1.3) is unknown. For the case in which $high_proto cannot be set, I believe that I have covered all of the possibilities, but an not sure if the correct message/rating is used in every case. For the case in which it is not possible to determine whether SSLv3 is the $low_proto, more could be done. If $high_proto is TLS 1.1 or TLS 1, then this PR is okay, as it is possible that SSLv3 would be the fallback protocol, but there is no way to tell. However, it seems unlikely that a server would support TLS 1.2 and SSLv3, but not TLS 1.1 or TLS 1. So, perhaps if $high_proto is TLS 1.2 and the server does not support TLS 1.1 or TLS 1, it should just be assumed that SSLv3 is not supported, even if it cannot be tested. --- testssl.sh | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/testssl.sh b/testssl.sh index e682815..49bc19e 100755 --- a/testssl.sh +++ b/testssl.sh @@ -4083,14 +4083,16 @@ ciphers_by_strength() { fi else # no SSLv2 nr_ossl_ciphers=0 - for (( i=0; i < nr_ciphers; i++ )); do - if "${ossl_supported[i]}"; then - ciphers_found2[nr_ossl_ciphers]=false - ciph2[nr_ossl_ciphers]="${ciph[i]}" - index[nr_ossl_ciphers]=$i - nr_ossl_ciphers+=1 - fi - done + if ( "$HAS_SSL3" || [[ $proto != -ssl3 ]] ) && ( "$HAS_TLS13" || [[ $proto != -tls1_3 ]] ); then + for (( i=0; i < nr_ciphers; i++ )); do + if "${ossl_supported[i]}"; then + ciphers_found2[nr_ossl_ciphers]=false + ciph2[nr_ossl_ciphers]="${ciph[i]}" + index[nr_ossl_ciphers]=$i + nr_ossl_ciphers+=1 + fi + done + fi if [[ $nr_ossl_ciphers -eq 0 ]]; then num_bundles=0 else @@ -14785,6 +14787,7 @@ run_tls_fallback_scsv() { high_proto="$p" break fi + [[ "$p" == ssl3 ]] && ! "$HAS_SSL3" && continue $OPENSSL s_client $(s_client_options "-$p $STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI") >$TMPFILE 2>$ERRFILE