Skip to content

Commit e97d873

Browse files
justsmthdavidben
andauthored
Reject NewSessionTicket messages with empty tickets in TLS 1.3 (#2367)
In TLS 1.2, the ticket field could be empty to indicate the server changed its mind on sending a ticket, having previously committed to sending a NewSessionTicket message a round-trip ago. In TLS 1.3, the server does not commit to sending NewSessionTicket. It can always just not send it. So the ticket field is required to be non-empty. It's important we enforce this on the client because otherwise we produce a mixed up SSL_SESSION object that looks like an ID session (thanks to the placeholder ID field that was added for a still unfixed Envoy bug, see b/200292207). That, in turn, confuses some code in assembling the next ClientHello. The subsequent CL will tighten that up. Update-Note: BoringSSL TLS 1.3 clients will now correctly reject zero-length tickets, rather than letting servers get us into a slightly funny state. Change-Id: I1651e7887f9611ebc44ac54af89c85bf86a9feff Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/73007 Commit-Queue: David Benjamin <[email protected]> Auto-Submit: David Benjamin <[email protected]> Reviewed-by: Adam Langley <[email protected]> ### Issues: Resolves #ISSUE-NUMBER1 Addresses #ISSUE-NUMBER2 ### Description of changes: Describe AWS-LC’s current behavior and how your code changes that behavior. If there are no issues this pr is resolving, explain why this change is necessary. ### Call-outs: Point out areas that need special attention or support during the review process. Discuss architecture or design changes. ### Testing: How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. Co-authored-by: David Benjamin <[email protected]>
1 parent f7cee60 commit e97d873

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

ssl/test/runner/runner.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12442,7 +12442,7 @@ func addSessionTicketTests() {
1244212442
testCases = append(testCases, testCase{
1244312443
// In TLS 1.2 and below, empty NewSessionTicket messages
1244412444
// mean the server changed its mind on sending a ticket.
12445-
name: "SendEmptySessionTicket",
12445+
name: "SendEmptySessionTicket-TLS12",
1244612446
config: Config{
1244712447
MaxVersion: VersionTLS12,
1244812448
Bugs: ProtocolBugs{
@@ -12452,6 +12452,21 @@ func addSessionTicketTests() {
1245212452
flags: []string{"-expect-no-session"},
1245312453
})
1245412454

12455+
testCases = append(testCases, testCase{
12456+
// In TLS 1.3, empty NewSessionTicket messages are not
12457+
// allowed.
12458+
name: "SendEmptySessionTicket-TLS13",
12459+
config: Config{
12460+
MaxVersion: VersionTLS13,
12461+
Bugs: ProtocolBugs{
12462+
SendEmptySessionTicket: true,
12463+
},
12464+
},
12465+
shouldFail: true,
12466+
expectedError: ":DECODE_ERROR:",
12467+
expectedLocalError: "remote error: error decoding message",
12468+
})
12469+
1245512470
// Test that the server ignores unknown PSK modes.
1245612471
testCases = append(testCases, testCase{
1245712472
testType: serverTest,

ssl/tls13_client.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,9 @@ UniquePtr<SSL_SESSION> tls13_create_session_with_ticket(SSL *ssl, CBS *body) {
10741074
!CBS_get_u32(body, &session->ticket_age_add) ||
10751075
!CBS_get_u8_length_prefixed(body, &ticket_nonce) ||
10761076
!CBS_get_u16_length_prefixed(body, &ticket) ||
1077+
CBS_len(&ticket) == 0 || //
10771078
!session->ticket.CopyFrom(ticket) ||
1078-
!CBS_get_u16_length_prefixed(body, &extensions) ||
1079+
!CBS_get_u16_length_prefixed(body, &extensions) || //
10791080
CBS_len(body) != 0) {
10801081
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
10811082
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);

0 commit comments

Comments
 (0)