From 69bdbeb982c53c03b3bca4249b032f22ce26becd Mon Sep 17 00:00:00 2001 From: Magnus Larsen Date: Wed, 18 Sep 2024 09:08:07 +0200 Subject: [PATCH 1/3] feat(rating): line-wrapping comments for grade_cap_reasons --- testssl.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/testssl.sh b/testssl.sh index 4068440..a17ea56 100755 --- a/testssl.sh +++ b/testssl.sh @@ -22933,15 +22933,20 @@ run_rating() { pr_headlineln " Rating (experimental) " outln - [[ -n "$STARTTLS_PROTOCOL" ]] && set_grade_cap "T" "STARTTLS encryption is not mandatory for clients. STARTTLS can only be secured client-side" - # TL;DR: E-mail transfer via port 25 is broken and the amendments suggested so far are duct tape. So please do not expect testssl.sh to shut up. + if [[ -n "$STARTTLS_PROTOCOL" ]]; then + read -r -d '' grade_cap_reason <<'EOF' +TL;DR: E-mail transfer via port 25 is broken and the amendments suggested so far are duct tape. So please do not expect testssl.sh to shut up. - # Explanation: For other than SMTP you should use TLS as per RFC 8314 . For SMTP however there's this thing named reality: A mail server cannot - # just switch to the mail submission port 587 only and continue to receive mail from everyone. Even if you advertise this via SRV record (RFC 6186). - # For STARTTLS there's no way to tell for testssl.sh whether it is secure. A MitM can always intercept the connection, unless the client checks - # the certificate accordingly (it's getting better but some just don't). TLSA Records/DANE and MTA-STS (RFC-8461) on the server side can help too. - # But as said, it's useless unless the client MTA checks all that which no tool can check. +Explanation: For other than SMTP you should use TLS as per RFC 8314. For SMTP however there's this thing named reality: A mail server cannot +just switch to the mail submission port 587 only and continue to receive mail from everyone. Even if you advertise this via SRV record (RFC 6186). +For STARTTLS there's no way to tell for testssl.sh whether it is secure. A MitM can always intercept the connection, unless the client checks +the certificate accordingly (it's getting better but some just don't). TLSA Records/DANE and MTA-STS (RFC-8461) on the server side can help too. +But as said, it's useless unless the client MTA checks all that which no tool can check. +EOF + # We can't use newlines in the message, as the grade-sorting function will mess up the reason + set_grade_cap "T" "$(tr '\n' ' ' <<<$grade_cap_reason)" + fi pr_bold " Rating specs"; out " (not complete) "; outln "SSL Labs's 'SSL Server Rating Guide' (version 2009q from 2020-01-30)" pr_bold " Specification documentation "; pr_url "https://github.com/ssllabs/research/wiki/SSL-Server-Rating-Guide" @@ -23127,9 +23132,9 @@ run_rating() { # Pretty print - again, it's just nicer to read for reason in "${sorted_reasons[@]}"; do if [[ $reason_nr -eq 0 ]]; then - pr_bold " Grade cap reasons "; outln "$reason" + pr_bold " Grade cap reasons "; out_row_aligned_max_width "$reason\n" ' ' $TERM_WIDTH else - outln " $reason" + out_row_aligned_max_width " $reason\n" ' ' $TERM_WIDTH fi ((reason_nr++)) fileout "grade_cap_reason_${reason_nr}" "INFO" "$reason" From 7c0ccb3da789673b0c0593764da0987c203a5894 Mon Sep 17 00:00:00 2001 From: Dirk Date: Mon, 14 Oct 2024 13:08:45 +0200 Subject: [PATCH 2/3] Fix HTML output in #2568 --- testssl.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testssl.sh b/testssl.sh index 9511703..2975d13 100755 --- a/testssl.sh +++ b/testssl.sh @@ -23132,9 +23132,11 @@ EOF # Pretty print - again, it's just nicer to read for reason in "${sorted_reasons[@]}"; do if [[ $reason_nr -eq 0 ]]; then - pr_bold " Grade cap reasons "; out_row_aligned_max_width "$reason\n" ' ' $TERM_WIDTH + pr_bold " Grade cap reasons " + outln "$(out_row_aligned_max_width "$reason" " " $TERM_WIDTH)" else - out_row_aligned_max_width " $reason\n" ' ' $TERM_WIDTH + outln "$(out_row_aligned_max_width " $reason" " " $TERM_WIDTH)" + fi ((reason_nr++)) fileout "grade_cap_reason_${reason_nr}" "INFO" "$reason" From fa5664f43479edfe812b2fba0a2a8511040bd49a Mon Sep 17 00:00:00 2001 From: Dirk Date: Mon, 14 Oct 2024 14:17:02 +0200 Subject: [PATCH 3/3] Polish comment + grade cap reason for STARTTLS --- testssl.sh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/testssl.sh b/testssl.sh index 2975d13..697b9a0 100755 --- a/testssl.sh +++ b/testssl.sh @@ -22933,20 +22933,18 @@ run_rating() { pr_headlineln " Rating (experimental) " outln + [[ -n "$STARTTLS_PROTOCOL" ]] && set_grade_cap "T" "STARTTLS is prone to MITM downgrade attacks. A secure TLS upgrade can only be ensured client-side. You should use TLS only (=implicit TLS) rather than STARTTLS as per RFC 8314, for other than SMTP and SIEVE" - if [[ -n "$STARTTLS_PROTOCOL" ]]; then - read -r -d '' grade_cap_reason <<'EOF' -TL;DR: E-mail transfer via port 25 is broken and the amendments suggested so far are duct tape. So please do not expect testssl.sh to shut up. + # TL;DR: STARTTLS connections are inherently insecure. A MITM can always intercept the connection, unless the client checks e.g. the + # certificate accordingly. A secure STARTTLS client is the key but we can't test for it. For other than SMTP and SIEVE (there's no implicit TLS port) + # you should use implicit TLS as per RFC 8314. Especially e-mail transfer via port 25 is broken and amendments so far are duct tape. -Explanation: For other than SMTP you should use TLS as per RFC 8314. For SMTP however there's this thing named reality: A mail server cannot -just switch to the mail submission port 587 only and continue to receive mail from everyone. Even if you advertise this via SRV record (RFC 6186). -For STARTTLS there's no way to tell for testssl.sh whether it is secure. A MitM can always intercept the connection, unless the client checks -the certificate accordingly (it's getting better but some just don't). TLSA Records/DANE and MTA-STS (RFC-8461) on the server side can help too. -But as said, it's useless unless the client MTA checks all that which no tool can check. -EOF - # We can't use newlines in the message, as the grade-sorting function will mess up the reason - set_grade_cap "T" "$(tr '\n' ' ' <<<$grade_cap_reason)" - fi + # Explanation: There are active MitM attacks possible when using STARTTLS like https://github.com/tintinweb/striptls or + # https://github.com/libcrack/starttlsstrip. It depends on the client only whether it can detect such downgrade attack. + # As some SMTP servers are still misconfigured with wrong certificates it's is still common practice for SMTP client MTAs to + # accept those wrong certificates -- delivering e-mails is more important. There is an e-mail submission port 587 but a mail server + # cannot just switch to it and continue to receive mail from everyone. Even if you advertise this via SRV record (RFC 6186). + # TLSA Records/DANE and MTA-STS (RFC-8461) on the server side can help too, pr_bold " Rating specs"; out " (not complete) "; outln "SSL Labs's 'SSL Server Rating Guide' (version 2009q from 2020-01-30)" pr_bold " Specification documentation "; pr_url "https://github.com/ssllabs/research/wiki/SSL-Server-Rating-Guide"