Skip to content

Commit cc6dd09

Browse files
committed
Rework legacy_tls handling to be consistent across our services. All of them
now default to TLSv1.2+ and only adjust ciphers offered if the service-specific `enable_SVC_legacy_tls` conf option is set. Drop the outdated client comments and disable ftps tls_legacy now that modern pyOpenSSL is available on every supported platform. Add `enable_openid_legacy_tls` conf option and implement the same cipher handling in the built-in OpenID service.
1 parent 2158a79 commit cc6dd09

6 files changed

Lines changed: 54 additions & 38 deletions

File tree

mig/install/MiGserver-template.conf

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -586,24 +586,15 @@ enable_sftp_subsys = __ENABLE_SFTP_SUBSYS__
586586
# Pure Python WsgiDAV-based webdav(s) daemon
587587
enable_davs = __ENABLE_DAVS__
588588
# Allow sub-optimal but still relatively strong legacy TLS support in WebDAVS
589-
# NOTE: Python-2.7.x ssl supports TLSv1.2+ with strong ciphers and all popular
589+
# NOTE: Python-2.7+ ssl supports TLSv1.2+ with strong ciphers and all popular
590590
# clients (including Windows 10+ native WebDAVS) also work with those.
591-
# NOTE: Apparently Win 7 (+8.1?) native WebDAVS only works with semi-strong
592-
# legacy ciphers and TLSv1.0+v1.1 unless updated and enabled
593-
# NOTE: Win 7 went EoL in January 2020 and should no longer be needed
594591
#enable_davs_legacy_tls = False
595592
# Pure Python pyftpdlib-based ftp(s) daemon
596593
enable_ftps = __ENABLE_FTPS__
597594
# Allow sub-optimal but still relatively strong legacy TLS supports in FTPS
598-
# NOTE: Recent PyOpenSSL supports TLSv1.2+ with strong ciphers and all popular
595+
# NOTE: Modern PyOpenSSL supports TLSv1.2+ with strong ciphers and all popular
599596
# clients also work with those.
600-
# NOTE: CentOS 7 native pyOpenSSL 0.13 does NOT support elliptic curve ciphers
601-
# and FileZilla fails on listdir with remaining strong DHE ciphers.
602-
# Installing a recent pyopenssl e.g. from the centos-openstack-X repo
603-
# allows disabling legacy tls support without breaking FileZilla support.
604-
# TODO: disable as soon as a recent pyopenssl version is available - the one
605-
# from pip breaks paramiko so do NOT go there.
606-
enable_ftps_legacy_tls = True
597+
#enable_ftps_legacy_tls = False
607598
# Enable WSGI served web pages (faster than CGI) - requires apache wsgi module
608599
enable_wsgi = __ENABLE_WSGI__
609600
# Enable system notify helper used e.g. to warn about failed user logins
@@ -638,6 +629,10 @@ peers_explicit_fields = __PEERS_EXPLICIT_FIELDS__
638629
peers_contact_hint = __PEERS_CONTACT_HINT__
639630
# Enable OpenID daemon for web access with user/pw from local user DB
640631
enable_openid = __ENABLE_OPENID__
632+
# Allow sub-optimal but still relatively strong legacy TLS support in OpenID 2.0
633+
# NOTE: Python-2.7+ ssl supports TLSv1.2+ with strong ciphers and all popular
634+
# clients also work with those.
635+
#enable_openid_legacy_tls = False
641636
# Enable share links for easy external exchange of data with anyone
642637
enable_sharelinks = __ENABLE_SHARELINKS__
643638
# Enable storage quota

mig/server/grid_ftps.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# --- BEGIN_HEADER ---
55
#
66
# grid_ftps - secure ftp server wrapping ftp in tls/ssl and mapping user home
7-
# Copyright (C) 2014-2022 The MiG Project lead by Brian Vinter
7+
# Copyright (C) 2014-2026 The MiG Project by the Science HPC Center at UCPH
88
#
99
# This file is part of MiG.
1010
#
@@ -20,7 +20,8 @@
2020
#
2121
# You should have received a copy of the GNU General Public License
2222
# along with this program; if not, write to the Free Software
23-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24+
# USA.
2425
#
2526
# -- END_HEADER ---
2627
#
@@ -95,6 +96,7 @@
9596
from mig.shared.accountstate import check_account_accessible
9697
from mig.shared.base import invisible_path, force_utf8, force_native_str
9798
from mig.shared.conf import get_configuration_object
99+
from mig.shared.defaults import STRONG_TLS_CIPHERS, STRONG_TLS_LEGACY_CIPHERS
98100
from mig.shared.fileio import user_chroot_exceptions
99101
from mig.shared.griddaemons.ftps import default_max_user_hits, \
100102
default_user_abuse_hits, default_proto_abuse_hits, \
@@ -333,7 +335,7 @@ class MiGRestrictedFilesystem(AbstractedFS):
333335

334336
def _acceptable_chmod(self, ftps_path, mode):
335337
"""Wrap helper"""
336-
#logger.debug("acceptable_chmod: %s" % ftps_path)
338+
# logger.debug("acceptable_chmod: %s" % ftps_path)
337339
reply = acceptable_chmod(ftps_path, mode, self.chmod_exceptions)
338340
if not reply:
339341
logger.warning("acceptable_chmod failed: %s %s %s" %
@@ -352,7 +354,7 @@ def validpath(self, path):
352354
try:
353355
get_fs_path(configuration, path, self.root,
354356
daemon_conf['chroot_exceptions'])
355-
#logger.debug("accepted access to %s" % path)
357+
# logger.debug("accepted access to %s" % path)
356358
return True
357359
except ValueError as err:
358360
logger.warning("rejected illegal access to %s :: %s" % (path, err))
@@ -490,14 +492,22 @@ def start_service(conf):
490492
handler.tls_data_required = True
491493
keyfile = certfile = conf.user_ftps_key
492494
handler.certfile = certfile
495+
# Mimic cipher setup from other daemons
496+
ciphers = daemon_conf['ssl_ciphers'] = None
493497
# Harden TLS/SSL if possible, requires recent pyftpdlib
494498
if hasattr(handler, 'ssl_context'):
495-
dhparamsfile = configuration.user_shared_dhparams
499+
dhparams_path = configuration.user_shared_dhparams
496500
legacy_tls = configuration.site_enable_ftps_legacy_tls
501+
if ciphers is not None:
502+
use_ciphers = ciphers
503+
elif legacy_tls:
504+
use_ciphers = STRONG_TLS_LEGACY_CIPHERS
505+
else:
506+
use_ciphers = STRONG_TLS_CIPHERS
497507
ssl_ctx = hardened_openssl_context(conf, OpenSSL, keyfile,
498508
certfile,
499-
dhparamsfile=dhparamsfile,
500-
allow_pre_tlsv12=legacy_tls)
509+
dhparamsfile=dhparams_path,
510+
ciphers=use_ciphers)
501511
handler.ssl_context = ssl_ctx
502512
else:
503513
logger.warning("Unable to enforce explicit strong TLS connections")

mig/server/grid_openid.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
from mig.shared.base import client_id_dir, cert_field_map, force_utf8, \
103103
force_native_str
104104
from mig.shared.conf import get_configuration_object
105+
from mig.shared.defaults import STRONG_TLS_CIPHERS, \
106+
STRONG_TLS_LEGACY_CIPHERS
105107
from mig.shared.griddaemons.openid import default_max_user_hits, \
106108
default_user_abuse_hits, default_proto_abuse_hits, \
107109
default_username_validator, refresh_user_creds, update_login_map, \
@@ -1654,6 +1656,8 @@ def start_service(configuration):
16541656
data_path = configuration.openid_store
16551657
daemon_conf = configuration.daemon_conf
16561658
nossl = daemon_conf['nossl']
1659+
# Mimic cipher setup from other daemons
1660+
ciphers = daemon_conf['ssl_ciphers'] = None
16571661
addr = (host, port)
16581662
# TODO: is this threaded version robust enough (thread safety)?
16591663
# OpenIDServer = OpenIDHTTPServer
@@ -1675,12 +1679,20 @@ def start_service(configuration):
16751679
# Use best possible SSL/TLS args for this python version
16761680
key_path = cert_path = configuration.user_openid_key
16771681
dhparams_path = configuration.user_shared_dhparams
1682+
legacy_tls = configuration.site_enable_openid_legacy_tls
1683+
if ciphers is not None:
1684+
use_ciphers = ciphers
1685+
elif legacy_tls:
1686+
use_ciphers = STRONG_TLS_LEGACY_CIPHERS
1687+
else:
1688+
use_ciphers = STRONG_TLS_CIPHERS
16781689
if not os.path.isfile(cert_path):
16791690
logger.error('No such server key: %s' % cert_path)
16801691
sys.exit(1)
16811692
logger.info('Wrapping connections in SSL')
16821693
ssl_ctx = hardened_ssl_context(configuration, key_path, cert_path,
1683-
dhparams_path)
1694+
dhparamsfile=dhparams_path,
1695+
ciphers=use_ciphers)
16841696
httpserver.socket = ssl_ctx.wrap_socket(httpserver.socket,
16851697
server_side=True)
16861698
# Override default SSLSocket accept function to inject timeout support

mig/server/grid_webdavs.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ def __init__(self, certificate, private_key, certificate_chain=None,
335335
context to use in all future connections in the wrap method.
336336
337337
If the optional legacy_tls arg is set the STRONG_TLS_LEGACY_CIPHERS
338-
are used instead of the STRONG_TLS_CIPHERS, and the limitation to
339-
TLSv1.2+ is left out to allow legacy TLSv1.0 and TLSv1.1 connections.
338+
are used instead of the STRONG_TLS_CIPHERS.
340339
This is required to support e.g. native Windows 7 WebDAVS access with
341340
the weak ECDHE-RSA-AES128-SHA cipher.
342341
"""
@@ -345,17 +344,17 @@ def __init__(self, certificate, private_key, certificate_chain=None,
345344
certificate_chain, ciphers)
346345
# logger.debug("proceed with hardening of ssl contetx")
347346
# Set up hardened SSL context once and for all
348-
dhparams = configuration.user_shared_dhparams
347+
dhparams_path = configuration.user_shared_dhparams
349348
if ciphers is not None:
350349
use_ciphers = ciphers
351350
elif legacy_tls:
352351
use_ciphers = STRONG_TLS_LEGACY_CIPHERS
353352
else:
354353
use_ciphers = STRONG_TLS_CIPHERS
355354
self.context = hardened_ssl_context(configuration, self.private_key,
356-
self.certificate, dhparams,
357-
ciphers=use_ciphers,
358-
allow_pre_tlsv12=legacy_tls)
355+
self.certificate,
356+
dhparamsfile=dhparams_path,
357+
ciphers=use_ciphers)
359358
# logger.debug("established hardened ssl contetx")
360359

361360
def __force_close(self, socket_list):

mig/shared/configuration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,11 @@ def reload_config(self, verbose, skip_log=False, disable_auth_log=False,
16001600
'SITE', 'enable_openid')
16011601
else:
16021602
self.site_enable_openid = False
1603+
if config.has_option('SITE', 'enable_openid_legacy_tls'):
1604+
self.site_enable_openid_legacy_tls = config.getboolean(
1605+
'SITE', 'enable_openid_legacy_tls')
1606+
else:
1607+
self.site_enable_openid_legacy_tls = False
16031608
if config.has_option('GLOBAL', 'user_openid_address'):
16041609
self.user_openid_address = config.get('GLOBAL',
16051610
'user_openid_address')

tests/fixture/confs-stdlocal/MiGserver.conf

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -586,24 +586,15 @@ enable_sftp_subsys = False
586586
# Pure Python WsgiDAV-based webdav(s) daemon
587587
enable_davs = False
588588
# Allow sub-optimal but still relatively strong legacy TLS support in WebDAVS
589-
# NOTE: Python-2.7.x ssl supports TLSv1.2+ with strong ciphers and all popular
589+
# NOTE: Python-2.7+ ssl supports TLSv1.2+ with strong ciphers and all popular
590590
# clients (including Windows 10+ native WebDAVS) also work with those.
591-
# NOTE: Apparently Win 7 (+8.1?) native WebDAVS only works with semi-strong
592-
# legacy ciphers and TLSv1.0+v1.1 unless updated and enabled
593-
# NOTE: Win 7 went EoL in January 2020 and should no longer be needed
594591
#enable_davs_legacy_tls = False
595592
# Pure Python pyftpdlib-based ftp(s) daemon
596593
enable_ftps = False
597594
# Allow sub-optimal but still relatively strong legacy TLS supports in FTPS
598-
# NOTE: Recent PyOpenSSL supports TLSv1.2+ with strong ciphers and all popular
595+
# NOTE: Modern PyOpenSSL supports TLSv1.2+ with strong ciphers and all popular
599596
# clients also work with those.
600-
# NOTE: CentOS 7 native pyOpenSSL 0.13 does NOT support elliptic curve ciphers
601-
# and FileZilla fails on listdir with remaining strong DHE ciphers.
602-
# Installing a recent pyopenssl e.g. from the centos-openstack-X repo
603-
# allows disabling legacy tls support without breaking FileZilla support.
604-
# TODO: disable as soon as a recent pyopenssl version is available - the one
605-
# from pip breaks paramiko so do NOT go there.
606-
enable_ftps_legacy_tls = True
597+
#enable_ftps_legacy_tls = False
607598
# Enable WSGI served web pages (faster than CGI) - requires apache wsgi module
608599
enable_wsgi = True
609600
# Enable system notify helper used e.g. to warn about failed user logins
@@ -638,6 +629,10 @@ peers_explicit_fields =
638629
peers_contact_hint = employed here and authorized to invite external users
639630
# Enable OpenID daemon for web access with user/pw from local user DB
640631
enable_openid = False
632+
# Allow sub-optimal but still relatively strong legacy TLS support in OpenID 2.0
633+
# NOTE: Python-2.7+ ssl supports TLSv1.2+ with strong ciphers and all popular
634+
# clients also work with those.
635+
#enable_openid_legacy_tls = False
641636
# Enable share links for easy external exchange of data with anyone
642637
enable_sharelinks = True
643638
# Enable storage quota

0 commit comments

Comments
 (0)