crypto/tls: reject known extensions in disallowed handshake messages

Change-Id: I9f3d9f3575359fb4730e0fb278d2d6a16a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/804180
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
This commit is contained in:
Filippo Valsorda 2026-07-22 13:14:40 +02:00 committed by Gopher Robot
parent 5a957dc766
commit e88582c5e1
2 changed files with 43 additions and 3 deletions

View File

@ -97,8 +97,6 @@
"UnsolicitedServerNameAck-TLS-TLS12": "TODO: first pass, this should be fixed",
"TicketSessionIDLength-33-TLS-TLS12": "TODO: first pass, this should be fixed",
"UnsolicitedServerNameAck-TLS-TLS13": "TODO: first pass, this should be fixed",
"RenegotiationInfo-Forbidden-TLS13": "TODO: first pass, this should be fixed",
"EMS-Forbidden-TLS13": "TODO: first pass, this should be fixed",
"SendUnsolicitedOCSPOnCertificate-TLS13": "TODO: first pass, this should be fixed",
"SendUnsolicitedSCTOnCertificate-TLS13": "TODO: first pass, this should be fixed",
"SendUnknownExtensionOnCertificate-TLS13": "TODO: first pass, this should be fixed",
@ -118,7 +116,6 @@
"UnknownExtension-Client-TLS13": "TODO: first pass, this should be fixed",
"SendClientVersion-RSA": "TODO: first pass, this should be fixed",
"NoCommonCurves": "TODO: first pass, this should be fixed",
"PointFormat-EncryptedExtensions-TLS13": "TODO: first pass, this should be fixed",
"TLS13-SendNoKEMModesWithPSK-Server": "TODO: first pass, this should be fixed",
"TLS13-DuplicateTicketEarlyDataSupport": "TODO: first pass, this should be fixed",
"Basic-Client-NoTicket-TLS-Sync": "TODO: first pass, this should be fixed",

View File

@ -1107,6 +1107,16 @@ func (m *encryptedExtensionsMsg) unmarshal(data []byte) bool {
return false
}
m.serverNameAck = true
case extensionStatusRequest, extensionSupportedPoints,
extensionSignatureAlgorithms, extensionSCT,
extensionExtendedMasterSecret, extensionSessionTicket,
extensionPreSharedKey, extensionSupportedVersions,
extensionCookie, extensionPSKModes,
extensionCertificateAuthorities, extensionSignatureAlgorithmsCert,
extensionKeyShare, extensionRenegotiationInfo,
extensionECHOuterExtensions:
// Not allowed in EncryptedExtensions.
return false
default:
// Ignore unknown extensions.
continue
@ -1231,6 +1241,18 @@ func (m *newSessionTicketMsgTLS13) unmarshal(data []byte) bool {
if !extData.ReadUint32(&m.maxEarlyData) {
return false
}
case extensionServerName, extensionStatusRequest,
extensionSupportedCurves, extensionSupportedPoints,
extensionSignatureAlgorithms, extensionALPN, extensionSCT,
extensionExtendedMasterSecret, extensionSessionTicket,
extensionPreSharedKey, extensionSupportedVersions,
extensionCookie, extensionPSKModes,
extensionCertificateAuthorities, extensionSignatureAlgorithmsCert,
extensionKeyShare, extensionQUICTransportParameters,
extensionRenegotiationInfo, extensionECHOuterExtensions,
extensionEncryptedClientHello:
// Not allowed in TLS 1.3 NewSessionTicket.
return false
default:
// Ignore unknown extensions.
continue
@ -1375,6 +1397,15 @@ func (m *certificateRequestMsgTLS13) unmarshal(data []byte) bool {
}
m.certificateAuthorities = append(m.certificateAuthorities, ca)
}
case extensionSupportedCurves, extensionSupportedPoints,
extensionALPN, extensionExtendedMasterSecret,
extensionSessionTicket, extensionPreSharedKey,
extensionEarlyData, extensionSupportedVersions,
extensionCookie, extensionPSKModes, extensionKeyShare,
extensionQUICTransportParameters, extensionRenegotiationInfo,
extensionECHOuterExtensions, extensionEncryptedClientHello:
// Not allowed in TLS 1.3 CertificateRequest.
return false
default:
// Ignore unknown extensions.
continue
@ -1585,6 +1616,18 @@ func unmarshalCertificate(s *cryptobyte.String, certificate *Certificate) bool {
certificate.SignedCertificateTimestamps = append(
certificate.SignedCertificateTimestamps, sct)
}
case extensionServerName, extensionSupportedCurves,
extensionSupportedPoints, extensionSignatureAlgorithms,
extensionALPN, extensionExtendedMasterSecret,
extensionSessionTicket, extensionPreSharedKey,
extensionEarlyData, extensionSupportedVersions,
extensionCookie, extensionPSKModes,
extensionCertificateAuthorities, extensionSignatureAlgorithmsCert,
extensionKeyShare, extensionQUICTransportParameters,
extensionRenegotiationInfo, extensionECHOuterExtensions,
extensionEncryptedClientHello:
// Not allowed in Certificate.
return false
default:
// Ignore unknown extensions.
continue