From c11853c09b71ebdcc2b960bc30ee8e6e61b0c35b Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Mon, 26 Aug 2019 16:18:24 -0400 Subject: [PATCH] [release-branch.go1.13] crypto/tls: make SSLv3 again disabled by default It was mistakenly re-enabled in CL 146217. Updates #33837 Change-Id: I8c0e1787114c6232df5888e51e355906622295bc Reviewed-on: https://go-review.googlesource.com/c/go/+/191877 Run-TryBot: Filippo Valsorda TryBot-Result: Gobot Gobot Reviewed-by: Dmitri Shuralyov (cherry picked from commit 2ebc3d8157fedba633ce90c5454827512734a793) Reviewed-on: https://go-review.googlesource.com/c/go/+/191998 --- doc/go1.13.html | 13 +++++++++---- src/crypto/tls/common.go | 4 ++++ src/crypto/tls/handshake_server_test.go | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/doc/go1.13.html b/doc/go1.13.html index ef56a862a5..f13c0e58e7 100644 --- a/doc/go1.13.html +++ b/doc/go1.13.html @@ -593,10 +593,15 @@ godoc

Support for SSL version 3.0 (SSLv3) - is now deprecated and will be removed in Go 1.14. Note that SSLv3 - is cryptographically - broken, is already disabled by default in crypto/tls, - and was never supported by Go clients. + is now deprecated and will be removed in Go 1.14. Note that SSLv3 is the + cryptographically broken + protocol predating TLS. +

+ +

+ SSLv3 was always disabled by default, other than in Go 1.12, when it was + mistakenly enabled by default server-side. It is now again disabled by + default. (SSLv3 was never supported client-side.)

diff --git a/src/crypto/tls/common.go b/src/crypto/tls/common.go index da1eae0800..ef0b385848 100644 --- a/src/crypto/tls/common.go +++ b/src/crypto/tls/common.go @@ -794,6 +794,10 @@ var supportedVersions = []uint16{ func (c *Config) supportedVersions(isClient bool) []uint16 { versions := make([]uint16, 0, len(supportedVersions)) for _, v := range supportedVersions { + // TLS 1.0 is the default minimum version. + if (c == nil || c.MinVersion == 0) && v < VersionTLS10 { + continue + } if c != nil && c.MinVersion != 0 && v < c.MinVersion { continue } diff --git a/src/crypto/tls/handshake_server_test.go b/src/crypto/tls/handshake_server_test.go index 22b126fa22..a9c1c08cbc 100644 --- a/src/crypto/tls/handshake_server_test.go +++ b/src/crypto/tls/handshake_server_test.go @@ -77,6 +77,20 @@ func TestRejectBadProtocolVersion(t *testing.T) { }, "unsupported versions") } +func TestSSLv3OptIn(t *testing.T) { + config := testConfig.Clone() + config.MinVersion = 0 + testClientHelloFailure(t, config, &clientHelloMsg{ + vers: VersionSSL30, + random: make([]byte, 32), + }, "unsupported versions") + testClientHelloFailure(t, config, &clientHelloMsg{ + vers: VersionTLS12, + supportedVersions: []uint16{VersionSSL30}, + random: make([]byte, 32), + }, "unsupported versions") +} + func TestNoSuiteOverlap(t *testing.T) { clientHello := &clientHelloMsg{ vers: VersionTLS10, -- 2.48.1