Skip to content

Commit bea0f8c

Browse files
committed
[nabla-c0d3#601]Provide a better error message for SSL2-only servers
1 parent 91f024a commit bea0f8c

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

sslyze/server_connectivity.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def check_connectivity_to_server(
8686
TlsVersionEnum.TLS_1_1,
8787
TlsVersionEnum.TLS_1_0,
8888
TlsVersionEnum.SSL_3_0,
89+
TlsVersionEnum.SSL_2_0,
8990
]:
9091
try:
9192
tls_detection_result = _detect_support_for_tls_1_2_or_below(
@@ -105,6 +106,14 @@ def check_connectivity_to_server(
105106
error_message="TLS probing failed: could not find a TLS version and cipher suite supported by the server",
106107
)
107108

109+
if tls_detection_result.tls_version_supported == TlsVersionEnum.SSL_2_0:
110+
raise ServerTlsConfigurationNotSupported(
111+
server_location=server_location,
112+
network_configuration=network_configuration,
113+
error_message="WARNING: Server only supports SSL 2.0 and is therefore affected by critical vulnerabilities."
114+
" Update the server's software as soon as possible.",
115+
)
116+
108117
# If the server requested a client certificate, detect if the client cert is optional or required
109118
client_auth_requirement = ClientAuthRequirementEnum.DISABLED
110119
if tls_detection_result.server_requested_client_cert:
@@ -272,10 +281,17 @@ def _detect_support_for_tls_1_2_or_below(
272281
network_config: ServerNetworkConfiguration,
273282
tls_version: TlsVersionEnum,
274283
) -> _TlsVersionDetectionResult:
284+
285+
if tls_version == TlsVersionEnum.SSL_2_0:
286+
# DEFAULT excludes SSLv2 ciphers in OpenSSL 1.0.2
287+
default_cipher_list = "SSLv2"
288+
else:
289+
default_cipher_list = "DEFAULT"
290+
275291
# First try the default cipher list, and then all ciphers; this is to work around F5 network devices
276292
# that time out when the client hello is too long (ie. too many cipher suites enabled)
277293
# https://support.f5.com/csp/article/K14758
278-
for cipher_list in ["DEFAULT", "ALL:COMPLEMENTOFALL:-PSK:-SRP"]:
294+
for cipher_list in [default_cipher_list, "ALL:COMPLEMENTOFALL:-PSK:-SRP"]:
279295
ssl_connection = SslConnection(
280296
server_location=server_location,
281297
network_configuration=network_config,

tests/server_connectivity_tests/test_direct_connection.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,25 @@ def test_server_triggers_unexpected_connection_error(self):
158158
)
159159

160160
# When testing connectivity against it
161-
# It fails and return the generic "connection failed" error, instead of crashing
162-
with pytest.raises(ConnectionToServerFailed) as e:
161+
# It fails and the actual error / root cause is mentioned in the message
162+
with pytest.raises(ConnectionToServerFailed, match="unrecognized name") as e:
163+
check_connectivity_to_server(
164+
server_location=server_location,
165+
network_configuration=ServerNetworkConfiguration.default_for_server_location(server_location),
166+
)
167+
168+
@can_only_run_on_linux_64
169+
def test_server_only_supports_sslv2(self):
170+
# Given a TLS server that only supports SSLv2
171+
with LegacyOpenSslServer(openssl_cipher_string="SSLv2") as server:
172+
server_location = ServerNetworkLocation(
173+
hostname=server.hostname, ip_address=server.ip_address, port=server.port
174+
)
175+
176+
# When testing connectivity against it
177+
# It fails and the fact that the server only supports SSL 2.0 is mentioned in the error
178+
with pytest.raises(ConnectionToServerFailed, match="SSL 2.0") as e:
163179
check_connectivity_to_server(
164180
server_location=server_location,
165181
network_configuration=ServerNetworkConfiguration.default_for_server_location(server_location),
166182
)
167-
# And the actual error / root cause is mentioned in the message
168-
assert "unrecognized name" in e.error_message

0 commit comments

Comments
 (0)