Nettacker icon indicating copy to clipboard operation
Nettacker copied to clipboard

ssl weak version vuln: false positive on modern TLS 1.3 servers, and TLS 1.0/1.1 undetectable on OpenSSL 3

Open Sickwoman opened this issue 3 weeks ago • 2 comments

Summary is_weak_ssl_version() in nettacker/core/lib/ssl.py (used by the ssl_weak_version_vuln module via ssl_version_and_cipher_scan) misreports the TLS versions of a server in two ways:

False positive — a modern, correctly configured server that offers only TLS 1.3 with a self-signed / untrusted / hostname-mismatched certificate is reported as weak_version: True, with an empty ssl_version list. False negative — a server that genuinely still allows TLS 1.0/1.1 is reported as supporting only TLS 1.2 and weak_version: False, because those legacy protocols can no longer be probed the way this function does it on OpenSSL 3. Root cause

def is_weak_ssl_version(host, port, timeout): def test_ssl_version(host, port, timeout, ssl_version=None): try: context = ssl.SSLContext(ssl_version) socket_connection = create_socket_connection(context, host, port, timeout) return socket_connection.version() except ssl.SSLError: return False ... ssl_versions = ( ssl.PROTOCOL_TLS_CLIENT, # TLS 1.3 ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1, ) ... return supported_versions, lowest_version not in {"TLSv1.2", "TLSv1.3"} and

def create_socket_connection(context, host, port, timeout): ... socket_connection = context.wrap_socket(socket_connection, server_hostname=host) return socket_connection Cause 1 — certificate verification (false positive). TLS 1.3 is probed only through ssl.PROTOCOL_TLS_CLIENT, whose context verifies the certificate chain and checks the hostname by default. create_socket_connection() never sets check_hostname = False / verify_mode = ssl.CERT_NONE, so against any server with a self-signed, untrusted, or hostname-mismatched certificate (internal services, appliances, and essentially every IP-based scan) the TLS 1.3 handshake raises ssl.SSLError (a SSLCertVerificationError) and the probe returns False. The lower-version probes use bare ssl.SSLContext(PROTOCOL_TLSv1_2/1_1/1), which do not verify — so TLS 1.2 is still detected on such a server, but a TLS 1.3-only server yields an empty supported_versions, and then lowest_version ("") not in {"TLSv1.2","TLSv1.3"} evaluates to True. A correctly configured server is flagged weak.

Cause 2 — legacy protocols undetectable (false negative). The TLS 1.0/1.1 probes use the deprecated ssl.PROTOCOL_TLSv1 / PROTOCOL_TLSv1_1 constants with the default security level. On modern OpenSSL 3 builds (Python 3.10+), these legacy protocols are disabled / blocked by SECLEVEL, so wrap_socket fails with an internal ssl.SSLError even against a server that genuinely offers TLS 1.0/1.1 — the version is never detected. (Reaching them requires an @SECLEVEL=0 cipher string plus explicit version pinning.) These PROTOCOL_TLSv1* constants are also deprecated since Python 3.10.

For contrast, the sibling create_tcp_socket() (used only to set ssl_flag) and the certificate scan use unverified sockets; the verification in create_socket_connection() is unique to is_weak_ssl_version() / is_weak_cipher_suite() and is clearly unintended for a scanner.

Steps to reproduce

cd "$(mktemp -d)" openssl req -x509 -newkey rsa:2048 -nodes -keyout k.pem -out c.pem -days 30 -subj "/CN=localhost"

Server A: TLS 1.3 ONLY, self-signed (a modern, correctly configured server)

openssl s_server -accept 14532 -cert c.pem -key k.pem -tls1_3 -www -quiet &

Server B: offers TLS 1.0 AND TLS 1.2 (genuinely weak: still allows TLS 1.0)

openssl s_server -accept 14531 -cert c.pem -key k.pem -cipher 'DEFAULT:@SECLEVEL=0' -no_tls1_3 -no_tls1_1 -www -quiet & sleep 2

ground truth: server B really does accept TLS 1.0

echo | openssl s_client -connect 127.0.0.1:14531 -tls1 -cipher 'DEFAULT:@SECLEVEL=0' 2>/dev/null | grep "Protocol :" then, from the repo root:

import warnings; warnings.simplefilter("ignore") from nettacker.core.lib.ssl import is_weak_ssl_version for port, desc in ((14532, "TLS 1.3 only, self-signed (modern, correctly configured)"), (14531, "TLS 1.0 + TLS 1.2 (genuinely weak)")): versions, weak = is_weak_ssl_version("127.0.0.1", port, 3) print(f"port {port}: ssl_version={versions} weak_version={weak} [{desc}]") Output on current master:

Protocol : TLSv1 # server B genuinely speaks TLS 1.0

port 14532: ssl_version=[] weak_version=True [TLS 1.3 only, self-signed (modern, correctly configured)] port 14531: ssl_version=['TLSv1.2'] weak_version=False [TLS 1.0 + TLS 1.2 (genuinely weak)] Expected vs actual Expected: server A (TLS 1.3 only) → not weak; server B (allows TLS 1.0) → weak, with TLSv1 shown in the version list. Actual: server A → weak_version: True with an empty version list (false positive); server B → weak_version: False, TLS 1.0 not listed (false negative). Related (not duplicates) #1719 / #1723 / #1726 — the analogous TLS 1.3 masking and cipher-string problems in the sibling function is_weak_cipher_suite() (the ssl_weak_cipher_vuln module). This issue is the version function is_weak_ssl_version() (the ssl_weak_version_vuln module), which those PRs do not change. #1190 / #1676 — replacing the deprecated ssl.wrap_socket and disabling verification in create_tcp_socket() (the ssl_flag probe only); they do not touch is_weak_ssl_version(). Suggested direction (open to maintainers' preference) Disable certificate verification in the version probe, as the rest of the SSL library already does: context.check_hostname = False; context.verify_mode = ssl.CERT_NONE. A version scanner should not require a trusted chain. Probe each protocol with a PROTOCOL_TLS_CLIENT context whose minimum_version/maximum_version are pinned to that version and with an @SECLEVEL=0 cipher string, instead of the deprecated per-protocol constants — so TLS 1.0/1.1 can actually be reached on OpenSSL 3. (This mirrors the direction taken for the cipher function in #1723.) Add tests with local TLS servers of known capability, including a no-false-positive control: a correctly configured TLS 1.3-only server with a self-signed certificate must not be reported weak. Environment Nettacker: current master Python: 3.11 (OpenSSL 3.x) OS: Linux

Sickwoman avatar Nov 14 '26 07:11 Sickwoman

Hi, I'd like to work on this if it's still open. I reproduced both cases on master with Python 3.13 and OpenSSL 3.5 using the two s_server setups from the issue: the TLS 1.3 only server with a self signed cert comes back as ([], True) and the TLS 1.0 + 1.2 server comes back as (['TLSv1.2'], False).

My plan is to turn off cert and hostname checks in the version probe, probe each version with a TLS_CLIENT context pinned through minimum_version and maximum_version plus @SECLEVEL=0 instead of the deprecated PROTOCOL_TLSv1* constants, and add tests against local servers of known capability, including the TLS 1.3 only control. I'll keep it to is_weak_ssl_version so it doesn't overlap with #1723 and #1726.

Could you assign it to me?

Anandb71 avatar Nov 15 '26 17:11 Anandb71

please assign this issue to me @securestep9. I have created the Fix locally. @securestep9

Sickwoman avatar Nov 22 '26 20:11 Sickwoman