Skip to content

Commit e282cbb

Browse files
committed
crypto/tls: handle client hello version too high
If the client hello legacy version is >= TLS 1.3, and no supported_versions extension is sent, negotiate TLS 1.2 or lower when supported. On the topic of supported version negotiation RFC 8446 4.2.1 indicates TLS 1.3 implementations MUST send a supported_versions extension with a list of their supported protocol versions. The crypto/tls package enforces this when the client hello legacy version indicates TLS 1.3 (0x0304), aborting the handshake with an alertMissingExtension alert if no supported_versions were received. However, section 4.2.1 indicates different behaviour should be used when the extension is not present and TLS 1.2 or prior are supported: If this extension is not present, servers which are compliant with this specification and which also support TLS 1.2 MUST negotiate TLS 1.2 or prior as specified in [RFC5246], even if ClientHello.legacy_version is 0x0304 or later. This commit updates the client hello processing logic to allow this behaviour. If no supported_versions extension was received we ignore the legacy version being >= TLS 1.3 and instead negotiate a lower supported version if the server configuration allows. This fix in turn allows enabling the BoGo ClientHelloVersionTooHigh, MinorVersionTolerance, and MajorVersionTolerance tests. Updates #72006 Change-Id: I27a2cd231e4b8762b0d9e2dbd3d8ddd5b87fd5c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/671235 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent fd60545 commit e282cbb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/crypto/tls/bogo_config.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,8 @@
6666
"SupportTicketsWithSessionID": "TODO: first pass, this should be fixed",
6767
"NoNullCompression-TLS12": "TODO: first pass, this should be fixed",
6868
"KeyUpdate-RequestACK": "TODO: first pass, this should be fixed",
69-
"ClientHelloVersionTooHigh": "TODO: first pass, this should be fixed",
70-
"MinorVersionTolerance": "TODO: first pass, this should be fixed",
7169
"IgnoreClientVersionOrder": "TODO: first pass, this should be fixed",
7270
"SupportedVersionSelection-TLS12": "TODO: first pass, this should be fixed",
73-
"MajorVersionTolerance": "TODO: first pass, this should be fixed",
7471
"DuplicateExtensionServer-TLS-TLS1": "TODO: first pass, this should be fixed",
7572
"DuplicateExtensionClient-TLS-TLS1": "TODO: first pass, this should be fixed",
7673
"UnsolicitedServerNameAck-TLS-TLS1": "TODO: first pass, this should be fixed",

src/crypto/tls/handshake_server.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,15 @@ func (c *Conn) readClientHello(ctx context.Context) (*clientHelloMsg, *echServer
169169
c.ticketKeys = originalConfig.ticketKeys(configForClient)
170170

171171
clientVersions := clientHello.supportedVersions
172-
if len(clientHello.supportedVersions) == 0 {
172+
if clientHello.vers >= VersionTLS13 && len(clientVersions) == 0 {
173+
// RFC 8446 4.2.1 indicates when the supported_versions extension is not sent,
174+
// compatible servers MUST negotiate TLS 1.2 or earlier if supported, even
175+
// if the client legacy version is TLS 1.3 or later.
176+
//
177+
// Since we reject empty extensionSupportedVersions in the client hello unmarshal
178+
// finding the supportedVersions empty indicates the extension was not present.
179+
clientVersions = supportedVersionsFromMax(VersionTLS12)
180+
} else if len(clientVersions) == 0 {
173181
clientVersions = supportedVersionsFromMax(clientHello.vers)
174182
}
175183
c.vers, ok = c.config.mutualVersion(roleServer, clientVersions)

0 commit comments

Comments
 (0)