Mercurial > hg
comparison mercurial/sslutil.py @ 29560:303e9300772a
sslutil: require TLS 1.1+ when supported
Currently, Mercurial will use TLS 1.0 or newer when connecting to
remote servers, selecting the highest TLS version supported by both
peers. On older Pythons, only TLS 1.0 is available. On newer Pythons,
TLS 1.1 and 1.2 should be available.
Security professionals recommend avoiding TLS 1.0 if possible.
PCI DSS 3.1 "strongly encourages" the use of TLS 1.2.
Known attacks like BEAST and POODLE exist against TLS 1.0 (although
mitigations are available and properly configured servers aren't
vulnerable).
I asked Eric Rescorla - Mozilla's resident crypto expert - whether
Mercurial should drop support for TLS 1.0. His response was
"if you can get away with it." Essentially, a number of servers on
the Internet don't support TLS 1.1+. This is why web browsers
continue to support TLS 1.0 despite desires from security experts.
This patch changes Mercurial's default behavior on modern Python
versions to require TLS 1.1+, thus avoiding known security issues
with TLS 1.0 and making Mercurial more secure by default. Rather
than drop TLS 1.0 support wholesale, we still allow TLS 1.0 to be
used if configured. This is a compromise solution - ideally we'd
disallow TLS 1.0. However, since we're not sure how many Mercurial
servers don't support TLS 1.1+ and we're not sure how much user
inconvenience this change will bring, I think it is prudent to ship
an escape hatch that still allows usage of TLS 1.0. In the default
case our users get better security. In the worst case, they are no
worse off than before this patch.
This patch has no effect when running on Python versions that don't
support TLS 1.1+.
As the added test shows, connecting to a server that doesn't
support TLS 1.1+ will display a warning message with a link to
our wiki, where we can guide people to configure their client to
allow less secure connections.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 13 Jul 2016 21:35:54 -0700 |
parents | 7dec5e441bf7 |
children | 1a782fabf80d |
comparison
equal
deleted
inserted
replaced
29559:7dec5e441bf7 | 29560:303e9300772a |
---|---|
152 _('unsupported protocol from hostsecurity.%s: %s') % | 152 _('unsupported protocol from hostsecurity.%s: %s') % |
153 (key, protocol), | 153 (key, protocol), |
154 hint=_('valid protocols: %s') % | 154 hint=_('valid protocols: %s') % |
155 ' '.join(sorted(configprotocols))) | 155 ' '.join(sorted(configprotocols))) |
156 | 156 |
157 # Legacy Python can only do TLS 1.0. We default to TLS 1.1+ where we | |
158 # can because TLS 1.0 has known vulnerabilities (like BEAST and POODLE). | |
159 # We allow users to downgrade to TLS 1.0+ via config options in case a | |
160 # legacy server is encountered. | |
161 if modernssl: | |
162 defaultprotocol = 'tls1.1' | |
163 else: | |
164 defaultprotocol = 'tls1.0' | |
165 | |
157 key = 'minimumprotocol' | 166 key = 'minimumprotocol' |
158 # Default to TLS 1.0+ as that is what browsers are currently doing. | 167 protocol = ui.config('hostsecurity', key, defaultprotocol) |
159 protocol = ui.config('hostsecurity', key, 'tls1.0') | |
160 validateprotocol(protocol, key) | 168 validateprotocol(protocol, key) |
161 | 169 |
162 key = '%s:minimumprotocol' % hostname | 170 key = '%s:minimumprotocol' % hostname |
163 protocol = ui.config('hostsecurity', key, protocol) | 171 protocol = ui.config('hostsecurity', key, protocol) |
164 validateprotocol(protocol, key) | 172 validateprotocol(protocol, key) |