Skip to content

Commit b21743c

Browse files
aglbradfitz
authored andcommitted
crypto/tls: reject zero-length SCTs.
The SignedCertificateTimestampList[1] specifies that both the list and each element must not be empty. Checking that the list is not empty was handled in [2] and this change checks that the SCTs themselves are not zero-length. [1] https://tools.ietf.org/html/rfc6962#section-3.3 [2] https://golang.org/cl/33265 Change-Id: Iabaae7a15f6d111eb079e5086e0bd2005fae9e48 Reviewed-on: https://go-review.googlesource.com/33355 Run-TryBot: Adam Langley <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent c099459 commit b21743c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/crypto/tls/handshake_messages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ func (m *serverHelloMsg) unmarshal(data []byte) bool {
813813
}
814814
sctLen := int(d[0])<<8 | int(d[1])
815815
d = d[2:]
816-
if len(d) < sctLen {
816+
if sctLen == 0 || len(d) < sctLen {
817817
return false
818818
}
819819
m.scts = append(m.scts, d[:sctLen])

src/crypto/tls/handshake_messages_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,21 @@ func TestRejectEmptySCTList(t *testing.T) {
305305
t.Fatal("Unmarshaled ServerHello with empty SCT list")
306306
}
307307
}
308+
309+
func TestRejectEmptySCT(t *testing.T) {
310+
// Not only must the SCT list be non-empty, but the SCT elements must
311+
// not be zero length.
312+
313+
var random [32]byte
314+
serverHello := serverHelloMsg{
315+
vers: VersionTLS12,
316+
random: random[:],
317+
scts: [][]byte{nil},
318+
}
319+
serverHelloBytes := serverHello.marshal()
320+
321+
var serverHelloCopy serverHelloMsg
322+
if serverHelloCopy.unmarshal(serverHelloBytes) {
323+
t.Fatal("Unmarshaled ServerHello with zero-length SCT")
324+
}
325+
}

0 commit comments

Comments
 (0)