Skip to content

Commit 1d6c4ff

Browse files
cpuwwqgtxx
authored andcommitted
crypto/tls: reject duplicate TLS 1.3 EncryptedExtensions
When a TLS 1.3 client processes the server's encryptedExtensionsMsg it should reject instances that contain duplicate extension types. RFC 8446 §4.2 says: There MUST NOT be more than one extension of the same type in a given extension block. This update matches enforcement done in the client hello unmarshalling, but applied to the TLS 1.3 encrypted extensions message unmarshalling. Making this change also allows enabling the DuplicateExtensionClient-TLS-TLS13 BoGo test. Updates #72006 Change-Id: I27a2cd231e4b8762b0d9e2dbd3d8ddd5b87fd5d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/673757 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
1 parent fcf1de9 commit 1d6c4ff

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

handshake_messages.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ func (m *encryptedExtensionsMsg) unmarshal(data []byte) bool {
11001100
return false
11011101
}
11021102

1103+
seenExts := make(map[uint16]bool)
11031104
for !extensions.Empty() {
11041105
var extension uint16
11051106
var extData cryptobyte.String
@@ -1108,6 +1109,11 @@ func (m *encryptedExtensionsMsg) unmarshal(data []byte) bool {
11081109
return false
11091110
}
11101111

1112+
if seenExts[extension] {
1113+
return false
1114+
}
1115+
seenExts[extension] = true
1116+
11111117
switch extension {
11121118
case extensionALPN:
11131119
var protoList cryptobyte.String

0 commit comments

Comments
 (0)