Skip to content

Commit 8149c2d

Browse files
committed
CCS injection: better handling of TLS alert protocols
In certain situations while testting for CCS injection it could have happened that an error code was sent which was not interpreted properly by testssl.sh. (https://tools.ietf.org/html/rfc5246#section-7.2) This has now been fixed and thus addresses #906. Also it has been made sure that other error codes are reported appropiately. The case where this test failed before was a non-patched Ubuntu 12.04 with openssl/postfix on port 25.
1 parent 39647d1 commit 8149c2d

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

testssl.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12156,17 +12156,34 @@ run_ccs_injection(){
1215612156
else
1215712157
fileout "$jsonID" "OK" "not vulnerable" "$cve" "$cwe"
1215812158
fi
12159-
elif [[ "$byte6" == "15" ]] && [[ "${tls_hello_ascii:0:4}" == "1503" ]]; then
12160-
# decryption failed received
12161-
pr_svrty_critical "VULNERABLE (NOT ok)"
12162-
fileout "$jsonID" "CRITICAL" "VULNERABLE" "$cve" "$cwe" "$hint"
1216312159
elif [[ "${tls_hello_ascii:0:4}" == "1503" ]]; then
12164-
if [[ "$byte6" == "0A" ]] || [[ "$byte6" == "28" ]]; then
12160+
if [[ ! "${tls_hello_ascii:5:2}" =~ [03|02|01|00] ]]; then
12161+
pr_warning "test failed "
12162+
out "no proper TLS repy (debug info: protocol sent: 1503${tlshexcode#x03, x}, reply: ${tls_hello_ascii:0:14}"
12163+
fileout "$jsonID" "DEBUG" "test failed, around line $LINENO, debug info (${tls_hello_ascii:0:14})" "$cve" "$cwe" "$hint"
12164+
ret=1
12165+
elif [[ "$byte6" == "15" ]]; then
12166+
# decryption failed received
12167+
pr_svrty_critical "VULNERABLE (NOT ok)"
12168+
fileout "$jsonID" "CRITICAL" "VULNERABLE" "$cve" "$cwe" "$hint"
12169+
elif [[ "$byte6" == "0A" ]] || [[ "$byte6" == "28" ]]; then
1216512170
# Unexpected message / Handshake failure received
1216612171
pr_warning "likely "
1216712172
out "not vulnerable (OK)"
1216812173
out " - alert description type: $byte6"
1216912174
fileout "$jsonID" "WARN" "probably not vulnerable but received 0x${byte6} instead of 0x15" "$cve" "$cwe" "$hint"
12175+
elif [[ "$byte6" == "14" ]]; then
12176+
# bad_record_mac -- this is not "not vulnerable"
12177+
out "likely "
12178+
pr_svrty_critical "VULNERABLE (NOT ok)"
12179+
out ", suspicious \"bad_record_mac\" ($byte6)"
12180+
fileout "$jsonID" "CRITICAL" "likely VULNERABLE" "$cve" "$cwe" "$hint"
12181+
else
12182+
# other errors, see https://tools.ietf.org/html/rfc5246#section-7.2
12183+
out "likely "
12184+
pr_svrty_critical "VULNERABLE (NOT ok)"
12185+
out ", suspicious error code \"$byte6\" returned. Please report"
12186+
fileout "$jsonID" "CRITICAL" "likely VULNERABLE with $byte6" "$cve" "$cwe" "$hint"
1217012187
fi
1217112188
elif [[ $STARTTLS_PROTOCOL == "mysql" ]] && [[ "${tls_hello_ascii:14:12}" == "233038533031" ]]; then
1217212189
# MySQL community edition (yaSSL) returns a MySQL error instead of a TLS Alert
@@ -12187,7 +12204,7 @@ run_ccs_injection(){
1218712204
fi
1218812205
outln
1218912206

12190-
tmpfile_handle $FUNCNAME.dd $SOCK_REPLY_FILE
12207+
tmpfile_handle ${FUNCNAME[0]}.dd $SOCK_REPLY_FILE
1219112208
close_socket
1219212209
return $ret
1219312210
}

0 commit comments

Comments
 (0)