idnits 2.17.1 draft-ietf-quic-tls-01.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (January 14, 2017) is 2652 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Outdated reference: A later version (-28) exists of draft-ietf-tls-tls13-18 -- Possible downref: Non-RFC (?) normative reference: ref. 'QUIC-TRANSPORT' ** Downref: Normative reference to an Informational RFC: RFC 5869 ** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112) -- Obsolete informational reference (is this intentional?): RFC 793 (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 7540 (Obsoleted by RFC 9113) Summary: 2 errors (**), 0 flaws (~~), 3 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 QUIC M. Thomson, Ed. 3 Internet-Draft Mozilla 4 Intended status: Standards Track S. Turner, Ed. 5 Expires: July 18, 2017 sn3rd 6 January 14, 2017 8 Using Transport Layer Security (TLS) to Secure QUIC 9 draft-ietf-quic-tls-01 11 Abstract 13 This document describes how Transport Layer Security (TLS) can be 14 used to secure QUIC. 16 Note to Readers 18 Discussion of this draft takes place on the QUIC working group 19 mailing list (quic@ietf.org), which is archived at 20 https://mailarchive.ietf.org/arch/search/?email_list=quic . 22 Working Group information can be found at https://github.com/quicwg ; 23 source code and issues list for this draft can be found at 24 https://github.com/quicwg/base-drafts/labels/tls . 26 Status of This Memo 28 This Internet-Draft is submitted in full conformance with the 29 provisions of BCP 78 and BCP 79. 31 Internet-Drafts are working documents of the Internet Engineering 32 Task Force (IETF). Note that other groups may also distribute 33 working documents as Internet-Drafts. The list of current Internet- 34 Drafts is at http://datatracker.ietf.org/drafts/current/. 36 Internet-Drafts are draft documents valid for a maximum of six months 37 and may be updated, replaced, or obsoleted by other documents at any 38 time. It is inappropriate to use Internet-Drafts as reference 39 material or to cite them other than as "work in progress." 41 This Internet-Draft will expire on July 18, 2017. 43 Copyright Notice 45 Copyright (c) 2017 IETF Trust and the persons identified as the 46 document authors. All rights reserved. 48 This document is subject to BCP 78 and the IETF Trust's Legal 49 Provisions Relating to IETF Documents 50 (http://trustee.ietf.org/license-info) in effect on the date of 51 publication of this document. Please review these documents 52 carefully, as they describe your rights and restrictions with respect 53 to this document. Code Components extracted from this document must 54 include Simplified BSD License text as described in Section 4.e of 55 the Trust Legal Provisions and are provided without warranty as 56 described in the Simplified BSD License. 58 Table of Contents 60 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 61 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 3 62 3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 4 63 3.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 5 64 3.2. TLS Handshake . . . . . . . . . . . . . . . . . . . . . . 6 65 4. TLS Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 7 66 4.1. Handshake and Setup Sequence . . . . . . . . . . . . . . 7 67 4.2. Interface to TLS . . . . . . . . . . . . . . . . . . . . 9 68 4.2.1. Handshake Interface . . . . . . . . . . . . . . . . . 9 69 4.2.2. Key Ready Events . . . . . . . . . . . . . . . . . . 10 70 4.2.3. Secret Export . . . . . . . . . . . . . . . . . . . . 11 71 4.2.4. TLS Interface Summary . . . . . . . . . . . . . . . . 11 72 5. QUIC Packet Protection . . . . . . . . . . . . . . . . . . . 11 73 5.1. Installing New Keys . . . . . . . . . . . . . . . . . . . 12 74 5.2. QUIC Key Expansion . . . . . . . . . . . . . . . . . . . 12 75 5.2.1. 0-RTT Secret . . . . . . . . . . . . . . . . . . . . 12 76 5.2.2. 1-RTT Secrets . . . . . . . . . . . . . . . . . . . . 13 77 5.2.3. Packet Protection Key and IV . . . . . . . . . . . . 14 78 5.3. QUIC AEAD Usage . . . . . . . . . . . . . . . . . . . . . 15 79 5.4. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 15 80 6. Key Phases . . . . . . . . . . . . . . . . . . . . . . . . . 16 81 6.1. Packet Protection for the TLS Handshake . . . . . . . . . 17 82 6.1.1. Initial Key Transitions . . . . . . . . . . . . . . . 17 83 6.1.2. Retransmission and Acknowledgment of Unprotected 84 Packets . . . . . . . . . . . . . . . . . . . . . . . 18 85 6.2. Key Update . . . . . . . . . . . . . . . . . . . . . . . 19 86 7. Pre-handshake QUIC Messages . . . . . . . . . . . . . . . . . 21 87 7.1. Unprotected Packets Prior to Handshake Completion . . . . 22 88 7.1.1. STREAM Frames . . . . . . . . . . . . . . . . . . . . 22 89 7.1.2. ACK Frames . . . . . . . . . . . . . . . . . . . . . 22 90 7.1.3. WINDOW_UPDATE Frames . . . . . . . . . . . . . . . . 23 91 7.1.4. Denial of Service with Unprotected Packets . . . . . 23 92 7.2. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 24 93 7.3. Protected Packets Prior to Handshake Completion . . . . . 24 94 8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 25 95 8.1. Protocol and Version Negotiation . . . . . . . . . . . . 25 96 8.2. QUIC Extension . . . . . . . . . . . . . . . . . . . . . 26 97 8.3. Source Address Validation . . . . . . . . . . . . . . . . 26 98 8.4. Priming 0-RTT . . . . . . . . . . . . . . . . . . . . . . 26 99 9. Security Considerations . . . . . . . . . . . . . . . . . . . 27 100 9.1. Packet Reflection Attack Mitigation . . . . . . . . . . . 27 101 9.2. Peer Denial of Service . . . . . . . . . . . . . . . . . 27 102 10. Error codes . . . . . . . . . . . . . . . . . . . . . . . . . 28 103 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 30 104 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 30 105 12.1. Normative References . . . . . . . . . . . . . . . . . . 30 106 12.2. Informative References . . . . . . . . . . . . . . . . . 31 107 Appendix A. Contributors . . . . . . . . . . . . . . . . . . . . 31 108 Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 31 109 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 32 110 C.1. Since draft-ietf-quic-tls-00: . . . . . . . . . . . . . . 32 111 C.2. Since draft-thomson-quic-tls-01: . . . . . . . . . . . . 32 112 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 32 114 1. Introduction 116 QUIC [QUIC-TRANSPORT] provides a multiplexed transport. When used 117 for HTTP [RFC7230] semantics [QUIC-HTTP] it provides several key 118 advantages over HTTP/1.1 [RFC7230] or HTTP/2 [RFC7540] over TCP 119 [RFC0793]. 121 This document describes how QUIC can be secured using Transport Layer 122 Security (TLS) version 1.3 [I-D.ietf-tls-tls13]. TLS 1.3 provides 123 critical latency improvements for connection establishment over 124 previous versions. Absent packet loss, most new connections can be 125 established and secured within a single round trip; on subsequent 126 connections between the same client and server, the client can often 127 send application data immediately, that is, zero round trip setup. 129 This document describes how the standardized TLS 1.3 can act a 130 security component of QUIC. The same design could work for TLS 1.2, 131 though few of the benefits QUIC provides would be realized due to the 132 handshake latency in versions of TLS prior to 1.3. 134 2. Notational Conventions 136 The words "MUST", "MUST NOT", "SHOULD", and "MAY" are used in this 137 document. It's not shouting; when they are capitalized, they have 138 the special meaning defined in [RFC2119]. 140 This document uses the terminology established in [QUIC-TRANSPORT]. 142 For brevity, the acronym TLS is used to refer to TLS 1.3. 144 TLS terminology is used when referring to parts of TLS. Though TLS 145 assumes a continuous stream of octets, it divides that stream into 146 _records_. Most relevant to QUIC are the records that contain TLS 147 _handshake messages_, which are discrete messages that are used for 148 key agreement, authentication and parameter negotiation. Ordinarily, 149 TLS records can also contain _application data_, though in the QUIC 150 usage there is no use of TLS application data. 152 3. Protocol Overview 154 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 155 and integrity protection of packets. For this it uses keys derived 156 from a TLS 1.3 connection [I-D.ietf-tls-tls13]; QUIC also relies on 157 TLS 1.3 for authentication and negotiation of parameters that are 158 critical to security and performance. 160 Rather than a strict layering, these two protocols are co-dependent: 161 QUIC uses the TLS handshake; TLS uses the reliability and ordered 162 delivery provided by QUIC streams. 164 This document defines how QUIC interacts with TLS. This includes a 165 description of how TLS is used, how keying material is derived from 166 TLS, and the application of that keying material to protect QUIC 167 packets. Figure 1 shows the basic interactions between TLS and QUIC, 168 with the QUIC packet protection being called out specially. 170 +------------+ +------------+ 171 | |----- Handshake ---->| | 172 | |<---- Handshake -----| | 173 | QUIC | | TLS | 174 | |<----- 0-RTT OK -----| | 175 | |<----- 1-RTT OK -----| | 176 | |<-- Handshake Done --| | 177 +------------+ +------------+ 178 | ^ ^ | 179 | Protect | Protected | | 180 v | Packet | | 181 +------------+ / / 182 | QUIC | / / 183 | Packet |------ Get Secret ------' / 184 | Protection |<------ Secret ----------' 185 +------------+ 187 Figure 1: QUIC and TLS Interactions 189 The initial state of a QUIC connection has packets exchanged without 190 any form of protection. In this state, QUIC is limited to using 191 stream 1 and associated packets. Stream 1 is reserved for a TLS 192 connection. This is a complete TLS connection as it would appear 193 when layered over TCP; the only difference is that QUIC provides the 194 reliability and ordering that would otherwise be provided by TCP. 196 At certain points during the TLS handshake, keying material is 197 exported from the TLS connection for use by QUIC. This keying 198 material is used to derive packet protection keys. Details on how 199 and when keys are derived and used are included in Section 5. 201 This arrangement means that some TLS messages receive redundant 202 protection from both the QUIC packet protection and the TLS record 203 protection. These messages are limited in number; the TLS connection 204 is rarely needed once the handshake completes. 206 3.1. TLS Overview 208 TLS provides two endpoints a way to establish a means of 209 communication over an untrusted medium (that is, the Internet) that 210 ensures that messages they exchange cannot be observed, modified, or 211 forged. 213 TLS features can be separated into two basic functions: an 214 authenticated key exchange and record protection. QUIC primarily 215 uses the authenticated key exchange provided by TLS; QUIC provides 216 its own packet protection. 218 The TLS authenticated key exchange occurs between two entities: 219 client and server. The client initiates the exchange and the server 220 responds. If the key exchange completes successfully, both client 221 and server will agree on a secret. TLS supports both pre-shared key 222 (PSK) and Diffie-Hellman (DH) key exchange. PSK is the basis for 223 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 224 keys are destroyed. 226 After completing the TLS handshake, the client will have learned and 227 authenticated an identity for the server and the server is optionally 228 able to learn and authenticate an identity for the client. TLS 229 supports X.509 certificate-based authentication [RFC5280] for both 230 server and client. 232 The TLS key exchange is resistent to tampering by attackers and it 233 produces shared secrets that cannot be controlled by either 234 participating peer. 236 3.2. TLS Handshake 238 TLS 1.3 provides two basic handshake modes of interest to QUIC: 240 o A full, 1-RTT handshake in which the client is able to send 241 application data after one round trip and the server immediately 242 after receiving the first handshake message from the client. 244 o A 0-RTT handshake in which the client uses information it has 245 previously learned about the server to send immediately. This 246 data can be replayed by an attacker so it MUST NOT carry a self- 247 contained trigger for any non-idempotent action. 249 A simplified TLS 1.3 handshake with 0-RTT application data is shown 250 in Figure 2, see [I-D.ietf-tls-tls13] for more options and details. 252 Client Server 254 ClientHello 255 (0-RTT Application Data) --------> 256 ServerHello 257 {EncryptedExtensions} 258 {ServerConfiguration} 259 {Certificate} 260 {CertificateVerify} 261 {Finished} 262 <-------- [Application Data] 263 (EndOfEarlyData) 264 {Finished} --------> 266 [Application Data] <-------> [Application Data] 268 Figure 2: TLS Handshake with 0-RTT 270 This 0-RTT handshake is only possible if the client and server have 271 previously communicated. In the 1-RTT handshake, the client is 272 unable to send protected application data until it has received all 273 of the handshake messages sent by the server. 275 Two additional variations on this basic handshake exchange are 276 relevant to this document: 278 o The server can respond to a ClientHello with a HelloRetryRequest, 279 which adds an additional round trip prior to the basic exchange. 280 This is needed if the server wishes to request a different key 281 exchange key from the client. HelloRetryRequest is also used to 282 verify that the client is correctly able to receive packets on the 283 address it claims to have (see Section 8.3). 285 o A pre-shared key mode can be used for subsequent handshakes to 286 avoid public key operations. This is the basis for 0-RTT data, 287 even if the remainder of the connection is protected by a new 288 Diffie-Hellman exchange. 290 4. TLS Usage 292 QUIC reserves stream 1 for a TLS connection. Stream 1 contains a 293 complete TLS connection, which includes the TLS record layer. Other 294 than the definition of a QUIC-specific extension (see Section-TBD), 295 TLS is unmodified for this use. This means that TLS will apply 296 confidentiality and integrity protection to its records. In 297 particular, TLS record protection is what provides confidentiality 298 protection for the TLS handshake messages sent by the server. 300 QUIC permits a client to send frames on streams starting from the 301 first packet. The initial packet from a client contains a stream 302 frame for stream 1 that contains the first TLS handshake messages 303 from the client. This allows the TLS handshake to start with the 304 first packet that a client sends. 306 QUIC packets are protected using a scheme that is specific to QUIC, 307 see Section 5. Keys are exported from the TLS connection when they 308 become available using a TLS exporter (see Section 7.3.3 of 309 [I-D.ietf-tls-tls13] and Section 5.2). After keys are exported from 310 TLS, QUIC manages its own key schedule. 312 4.1. Handshake and Setup Sequence 314 The integration of QUIC with a TLS handshake is shown in more detail 315 in Figure 3. QUIC "STREAM" frames on stream 1 carry the TLS 316 handshake. QUIC performs loss recovery [QUIC-RECOVERY] for this 317 stream and ensures that TLS handshake messages are delivered in the 318 correct order. 320 Client Server 322 @C QUIC STREAM Frame(s) <1>: 323 ClientHello 324 + QUIC Extension 325 --------> 326 0-RTT Key => @0 328 @0 QUIC STREAM Frame(s) : 329 Replayable QUIC Frames 330 --------> 332 QUIC STREAM Frame <1>: @C 333 ServerHello 334 {TLS Handshake Messages} 335 <-------- 336 1-RTT Key => @1 338 QUIC Frames @1 339 <-------- 340 @1 QUIC STREAM Frame(s) <1>: 341 (EndOfEarlyData) 342 {Finished} 343 --------> 345 @1 QUIC Frames <-------> QUIC Frames @1 347 Figure 3: QUIC over TLS Handshake 349 In Figure 3, symbols mean: 351 o "<" and ">" enclose stream numbers. 353 o "@" indicates the key phase that is currently used for protecting 354 QUIC packets. 356 o "(" and ")" enclose messages that are protected with TLS 0-RTT 357 handshake or application keys. 359 o "{" and "}" enclose messages that are protected by the TLS 360 Handshake keys. 362 If 0-RTT is not attempted, then the client does not send packets 363 protected by the 0-RTT key (@0). In that case, the only key 364 transition on the client is from unprotected packets (@C) to 1-RTT 365 protection (@1), which happens before it sends its final set of TLS 366 handshake messages. 368 The server sends TLS handshake messages without protection (@C). The 369 server transitions from no protection (@C) to full 1-RTT protection 370 (@1) after it sends the last of its handshake messages. 372 Some TLS handshake messages are protected by the TLS handshake record 373 protection. These keys are not exported from the TLS connection for 374 use in QUIC. QUIC packets from the server are sent in the clear 375 until the final transition to 1-RTT keys. 377 The client transitions from cleartext (@C) to 0-RTT keys (@0) when 378 sending 0-RTT data, and subsequently to to 1-RTT keys (@1) for its 379 second flight of TLS handshake messages. This creates the potential 380 for unprotected packets to be received by a server in close proximity 381 to packets that are protected with 1-RTT keys. 383 More information on key transitions is included in Section 6.1. 385 4.2. Interface to TLS 387 As shown in Figure 1, the interface from QUIC to TLS consists of 388 three primary functions: Handshake, Key Ready Events, and Secret 389 Export. 391 Additional functions might be needed to configure TLS. 393 4.2.1. Handshake Interface 395 In order to drive the handshake, TLS depends on being able to send 396 and receive handshake messages on stream 1. There are two basic 397 functions on this interface: one where QUIC requests handshake 398 messages and one where QUIC provides handshake packets. 400 A QUIC client starts TLS by requesting TLS handshake octets from TLS. 401 The client acquires handshake octets before sending its first packet. 403 A QUIC server starts the process by providing TLS with stream 1 404 octets. 406 Each time that an endpoint receives data on stream 1, it delivers the 407 octets to TLS if it is able. Each time that TLS is provided with new 408 data, new handshake octets are requested from TLS. TLS might not 409 provide any octets if the handshake messages it has received are 410 incomplete or it has no data to send. 412 Once the TLS handshake is complete, this is indicated to QUIC along 413 with any final handshake octets that TLS needs to send. Once the 414 handshake is complete, TLS becomes passive. TLS can still receive 415 data from its peer and respond in kind that data, but it will not 416 need to send more data unless specifically requested - either by an 417 application or QUIC. One reason to send data is that the server 418 might wish to provide additional or updated session tickets to a 419 client. 421 When the handshake is complete, QUIC only needs to provide TLS with 422 any data that arrives on stream 1. In the same way that is done 423 during the handshake, new data is requested from TLS after providing 424 received data. 426 Important: Until the handshake is reported as complete, the 427 connection and key exchange are not properly authenticated at the 428 server. Even though 1-RTT keys are available to a server after 429 receiving the first handshake messages from a client, the server 430 cannot consider the client to be authenticated until it receives 431 and validates the client's Finished message. 433 4.2.2. Key Ready Events 435 TLS provides QUIC with signals when 0-RTT and 1-RTT keys are ready 436 for use. These events are not asynchronous, they always occur 437 immediately after TLS is provided with new handshake octets, or after 438 TLS produces handshake octets. 440 When TLS has enough information to generate 1-RTT keys, it indicates 441 their availability. On the client, this occurs after receiving the 442 entirety of the first flight of TLS handshake messages from the 443 server. A server indicates that 1-RTT keys are available after it 444 sends its handshake messages. 446 This ordering ensures that a client sends its second flight of 447 handshake messages protected with 1-RTT keys. More importantly, it 448 ensures that the server sends its flight of handshake messages 449 without protection. 451 If 0-RTT is possible, it is ready after the client sends a TLS 452 ClientHello message or the server receives that message. After 453 providing a QUIC client with the first handshake octets, the TLS 454 stack might signal that 0-RTT keys are ready. On the server, after 455 receiving handshake octets that contain a ClientHello message, a TLS 456 server might signal that 0-RTT keys are available. 458 1-RTT keys are used for both sending and receiving packets. 0-RTT 459 keys are only used to protect packets that the client sends. 461 4.2.3. Secret Export 463 Details how secrets are exported from TLS are included in 464 Section 5.2. 466 4.2.4. TLS Interface Summary 468 Figure 4 summarizes the exchange between QUIC and TLS for both client 469 and server. 471 Client Server 473 Get Handshake 474 0-RTT Key Ready 475 --- send/receive ---> 476 Handshake Received 477 0-RTT Key Ready 478 Get Handshake 479 1-RTT Keys Ready 480 <--- send/receive --- 481 Handshake Received 482 1-RTT Keys Ready 483 Get Handshake 484 Handshake Complete 485 --- send/receive ---> 486 Handshake Received 487 Get Handshake 488 Handshake Complete 489 <--- send/receive --- 490 Handshake Received 491 Get Handshake 493 Figure 4: Interaction Summary between QUIC and TLS 495 5. QUIC Packet Protection 497 QUIC packet protection provides authenticated encryption of packets. 498 This provides confidentiality and integrity protection for the 499 content of packets (see Section 5.3). Packet protection uses keys 500 that are exported from the TLS connection (see Section 5.2). 502 Different keys are used for QUIC packet protection and TLS record 503 protection. Having separate QUIC and TLS record protection means 504 that TLS records can be protected by two different keys. This 505 redundancy is limited to a only a few TLS records, and is maintained 506 for the sake of simplicity. 508 5.1. Installing New Keys 510 As TLS reports the availability of keying material, the packet 511 protection keys and initialization vectors (IVs) are updated (see 512 Section 5.2). The selection of AEAD function is also updated to 513 match the AEAD negotiated by TLS. 515 For packets other than any unprotected handshake packets (see 516 Section 6.1), once a change of keys has been made, packets with 517 higher packet numbers MUST use the new keying material. The 518 KEY_PHASE bit on these packets is inverted each time new keys are 519 installed to signal the use of the new keys to the recipient (see 520 Section 6 for details). 522 An endpoint retransmits stream data in a new packet. New packets 523 have new packet numbers and use the latest packet protection keys. 524 This simplifies key management when there are key updates (see 525 Section 6.2). 527 5.2. QUIC Key Expansion 529 QUIC uses a system of packet protection secrets, keys and IVs that 530 are modelled on the system used in TLS [I-D.ietf-tls-tls13]. The 531 secrets that QUIC uses as the basis of its key schedule are obtained 532 using TLS exporters (see Section 7.3.3 of [I-D.ietf-tls-tls13]). 534 QUIC uses the Pseudo-Random Function (PRF) hash function negotiated 535 by TLS for key derivation. For example, if TLS is using the 536 TLS_AES_128_GCM_SHA256, the SHA-256 hash function is used. 538 5.2.1. 0-RTT Secret 540 0-RTT keys are those keys that are used in resumed connections prior 541 to the completion of the TLS handshake. Data sent using 0-RTT keys 542 might be replayed and so has some restrictions on its use, see 543 Section 7.2. 0-RTT keys are used after sending or receiving a 544 ClientHello. 546 The secret is exported from TLS using the exporter label "EXPORTER- 547 QUIC 0-RTT Secret" and an empty context. The size of the secret MUST 548 be the size of the hash output for the PRF hash function negotiated 549 by TLS. This uses the TLS early_exporter_secret. The QUIC 0-RTT 550 secret is only used for protection of packets sent by the client. 552 client_0rtt_secret 553 = TLS-Exporter("EXPORTER-QUIC 0-RTT Secret" 554 "", Hash.length) 556 5.2.2. 1-RTT Secrets 558 1-RTT keys are used by both client and server after the TLS handshake 559 completes. There are two secrets used at any time: one is used to 560 derive packet protection keys for packets sent by the client, the 561 other for protecting packets sent by the server. 563 The initial client packet protection secret is exported from TLS 564 using the exporter label "EXPORTER-QUIC client 1-RTT Secret"; the 565 initial server packet protection secret uses the exporter label 566 "EXPORTER-QUIC server 1-RTT Secret". Both exporters use an empty 567 context. The size of the secret MUST be the size of the hash output 568 for the PRF hash function negotiated by TLS. 570 client_pp_secret_0 571 = TLS-Exporter("EXPORTER-QUIC client 1-RTT Secret" 572 "", Hash.length) 573 server_pp_secret_0 574 = TLS-Exporter("EXPORTER-QUIC server 1-RTT Secret" 575 "", Hash.length) 577 These secrets are used to derive the initial client and server packet 578 protection keys. 580 After a key update (see Section 6.2), these secrets are updated using 581 the HKDF-Expand-Label function defined in Section 7.1 of 582 [I-D.ietf-tls-tls13]. HKDF-Expand-Label uses the the PRF hash 583 function negotiated by TLS. The replacement secret is derived using 584 the existing Secret, a Label of "QUIC client 1-RTT Secret" for the 585 client and "QUIC server 1-RTT Secret" for the server, an empty 586 HashValue, and the same output Length as the hash function selected 587 by TLS for its PRF. 589 client_pp_secret_ 590 = HKDF-Expand-Label(client_pp_secret_, 591 "QUIC client 1-RTT Secret", 592 "", Hash.length) 593 server_pp_secret_ 594 = HKDF-Expand-Label(server_pp_secret_, 595 "QUIC server 1-RTT Secret", 596 "", Hash.length) 598 This allows for a succession of new secrets to be created as needed. 600 HKDF-Expand-Label uses HKDF-Expand [RFC5869] with a specially 601 formatted info parameter. The info parameter that includes the 602 output length (in this case, the size of the PRF hash output) encoded 603 on two octets in network byte order, the length of the prefixed Label 604 as a single octet, the value of the Label prefixed with "TLS 1.3, ", 605 and a zero octet to indicate an empty HashValue. For example, the 606 client packet protection secret uses an info parameter of: 608 info = (HashLen / 256) || (HashLen % 256) || 0x21 || 609 "TLS 1.3, QUIC client 1-RTT secret" || 0x00 611 5.2.3. Packet Protection Key and IV 613 The complete key expansion uses an identical process for key 614 expansion as defined in Section 7.3 of [I-D.ietf-tls-tls13], using 615 different values for the input secret. QUIC uses the AEAD function 616 negotiated by TLS. 618 The packet protection key and IV used to protect the 0-RTT packets 619 sent by a client use the QUIC 0-RTT secret. This uses the HKDF- 620 Expand-Label with the PRF hash function negotiated by TLS. 622 The length of the output is determined by the requirements of the 623 AEAD function selected by TLS. The key length is the AEAD key size. 624 As defined in Section 5.3 of [I-D.ietf-tls-tls13], the IV length is 625 the larger of 8 or N_MIN (see Section 4 of [RFC5116]). 627 client_0rtt_key = HKDF-Expand-Label(client_0rtt_secret, 628 "key", "", key_length) 629 client_0rtt_iv = HKDF-Expand-Label(client_0rtt_secret, 630 "iv", "", iv_length) 632 Similarly, the packet protection key and IV used to protect 1-RTT 633 packets sent by both client and server use the current packet 634 protection secret. 636 client_pp_key_ = HKDF-Expand-Label(client_pp_secret_, 637 "key", "", key_length) 638 client_pp_iv_ = HKDF-Expand-Label(client_pp_secret_, 639 "iv", "", iv_length) 640 server_pp_key_ = HKDF-Expand-Label(server_pp_secret_, 641 "key", "", key_length) 642 server_pp_iv_ = HKDF-Expand-Label(server_pp_secret_, 643 "iv", "", iv_length) 645 The client protects (or encrypts) packets with the client packet 646 protection key and IV; the server protects packets with the server 647 packet protection key. 649 The QUIC record protection initially starts without keying material. 650 When the TLS state machine reports that the ClientHello has been 651 sent, the 0-RTT keys can be generated and installed for writing. 653 When the TLS state machine reports completion of the handshake, the 654 1-RTT keys can be generated and installed for writing. 656 5.3. QUIC AEAD Usage 658 The Authentication Encryption with Associated Data (AEAD) [RFC5116] 659 function used for QUIC packet protection is AEAD that is negotiated 660 for use with the TLS connection. For example, if TLS is using the 661 TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is used. 663 Regular QUIC packets are protected by an AEAD [RFC5116]. Version 664 negotiation and public reset packets are not protected. 666 Once TLS has provided a key, the contents of regular QUIC packets 667 immediately after any TLS messages have been sent are protected by 668 the AEAD selected by TLS. 670 The key, K, for the AEAD is either the client packet protection key 671 (client_pp_key_n) or the server packet protection key 672 (server_pp_key_n), derived as defined in Section 5.2. 674 The nonce, N, for the AEAD is formed by combining either the packet 675 protection IV (either client_pp_iv_n or server_pp_iv_n) with packet 676 numbers. The 64 bits of the reconstructed QUIC packet number in 677 network byte order is left-padded with zeros to the size of the IV. 678 The exclusive OR of the padded packet number and the IV forms the 679 AEAD nonce. 681 The associated data, A, for the AEAD is an empty sequence. 683 The input plaintext, P, for the AEAD is the contents of the QUIC 684 frame following the packet number, as described in [QUIC-TRANSPORT]. 686 The output ciphertext, C, of the AEAD is transmitted in place of P. 688 Prior to TLS providing keys, no record protection is performed and 689 the plaintext, P, is transmitted unmodified. 691 5.4. Packet Numbers 693 QUIC has a single, contiguous packet number space. In comparison, 694 TLS restarts its sequence number each time that record protection 695 keys are changed. The sequence number restart in TLS ensures that a 696 compromise of the current traffic keys does not allow an attacker to 697 truncate the data that is sent after a key update by sending 698 additional packets under the old key (causing new packets to be 699 discarded). 701 QUIC does not assume a reliable transport and is required to handle 702 attacks where packets are dropped in other ways. QUIC is therefore 703 not affected by this form of truncation. 705 The packet number is not reset and it is not permitted to go higher 706 than its maximum value of 2^64-1. This establishes a hard limit on 707 the number of packets that can be sent. 709 Some AEAD functions have limits for how many packets can be encrypted 710 under the same key and IV (see for example [AEBounds]). This might 711 be lower than the packet number limit. An endpoint MUST initiate a 712 key update (Section 6.2) prior to exceeding any limit set for the 713 AEAD that is in use. 715 TLS maintains a separate sequence number that is used for record 716 protection on the connection that is hosted on stream 1. This 717 sequence number is not visible to QUIC. 719 6. Key Phases 721 As TLS reports the availability of 0-RTT and 1-RTT keys, new keying 722 material can be exported from TLS and used for QUIC packet 723 protection. At each transition during the handshake a new secret is 724 exported from TLS and packet protection keys are derived from that 725 secret. 727 Every time that a new set of keys is used for protecting outbound 728 packets, the KEY_PHASE bit in the public flags is toggled. The 729 exception is the transition from 0-RTT keys to 1-RTT keys, where the 730 presence of the version field and its associated bit is used (see 731 Section 6.1.1). 733 Once the connection is fully enabled, the KEY_PHASE bit allows a 734 recipient to detect a change in keying material without necessarily 735 needing to receive the first packet that triggered the change. An 736 endpoint that notices a changed KEY_PHASE bit can update keys and 737 decrypt the packet that contains the changed bit, see Section 6.2. 739 The KEY_PHASE bit is the third bit of the public flags (0x04). 741 Transitions between keys during the handshake are complicated by the 742 need to ensure that TLS handshake messages are sent with the correct 743 packet protection. 745 6.1. Packet Protection for the TLS Handshake 747 The initial exchange of packets are sent without protection. These 748 packets are marked with a KEY_PHASE of 0. 750 TLS handshake messages that are critical to the TLS key exchange 751 cannot be protected using QUIC packet protection. A KEY_PHASE of 0 752 is used for all of these packets, even during retransmission. The 753 messages critical to key exchange are the TLS ClientHello and any TLS 754 handshake message from the server, except those that are sent after 755 the handshake completes, such as NewSessionTicket. 757 The second flight of TLS handshake messages from the client, and any 758 TLS handshake messages that are sent after completing the TLS 759 handshake do not need special packet protection rules. This includes 760 the EndOfEarlyData message that is sent by a client to mark the end 761 of its 0-RTT data. Packets containing these messages use the packet 762 protection keys that are current at the time of sending (or 763 retransmission). 765 Like the client, a server MUST send retransmissions of its 766 unprotected handshake messages or acknowledgments for unprotected 767 handshake messages sent by the client in unprotected packets 768 (KEY_PHASE=0). 770 6.1.1. Initial Key Transitions 772 Once the TLS key exchange is complete, keying material is exported 773 from TLS and QUIC packet protection commences. 775 Packets protected with 1-RTT keys have a KEY_PHASE bit set to 1. 776 These packets also have a VERSION bit set to 0. 778 If the client is unable to send 0-RTT data - or it does not have 779 0-RTT data to send - packet protection with 1-RTT keys starts with 780 the packets that contain its second flight of TLS handshake messages. 781 That is, the flight containing the TLS Finished handshake message and 782 optionally a Certificate and CertificateVerify message. 784 If the client sends 0-RTT data, it marks packets protected with 0-RTT 785 keys with a KEY_PHASE of 1 and a VERSION bit of 1. Setting the 786 version bit means that all packets also include the version field. 787 The client removes the VERSION bit when it transitions to using 1-RTT 788 keys, but it does not change the KEY_PHASE bit. 790 Marking 0-RTT data with the both KEY_PHASE and VERSION bits ensures 791 that the server is able to identify these packets as 0-RTT data in 792 case the packet containing the TLS ClientHello is lost or delayed. 794 Including the version also ensures that the packet format is known to 795 the server in this case. 797 Using both KEY_PHASE and VERSION also ensures that the server is able 798 to distinguish between cleartext handshake packets (KEY_PHASE=0, 799 VERSION=1), 0-RTT protected packets (KEY_PHASE=1, VERSION=1), and 800 1-RTT protected packets (KEY_PHASE=1, VERSION=0). Packets with all 801 of these markings can arrive concurrently, and being able to identify 802 each cleanly ensures that the correct packet protection keys can be 803 selected and applied. 805 A server might choose to retain 0-RTT packets that arrive before a 806 TLS ClientHello. The server can then use those packets once the 807 ClientHello arrives. However, the potential for denial of service 808 from buffering 0-RTT packets is significant. These packets cannot be 809 authenticated and so might be employed by an attacker to exhaust 810 server resources. Limiting the number of packets that are saved 811 might be necessary. 813 The server transitions to using 1-RTT keys after sending its first 814 flight of TLS handshake messages. From this point, the server 815 protects all packets with 1-RTT keys. Future packets are therefore 816 protected with 1-RTT keys and marked with a KEY_PHASE of 1. 818 6.1.2. Retransmission and Acknowledgment of Unprotected Packets 820 The first flight of TLS handshake messages from both client and 821 server (ClientHello, or ServerHello through to the server's Finished) 822 are critical to the key exchange. The contents of these messages 823 determines the keys used to protect later messages. If these 824 handshake messages are included in packets that are protected with 825 these keys, they will be indecipherable to the recipient. 827 Even though newer keys could be available when retranmitting, 828 retransmissions of these handshake messages MUST be sent in 829 unprotected packets (with a KEY_PHASE of 0). An endpoint MUST also 830 generate ACK frames for these messages that are sent in unprotected 831 packets. 833 The TLS handshake messages that are affected by this rule are 834 specifically: 836 o A client MUST NOT restransmit a TLS ClientHello with 0-RTT keys. 837 The server needs this message in order to determine the 0-RTT 838 keys. 840 o A server MUST NOT retransmit any of its TLS handshake messages 841 with 1-RTT keys. The client needs these messages in order to 842 determine the 1-RTT keys. 844 A HelloRetryRequest handshake message might be used to reject an 845 initial ClientHello. A HelloRetryRequest handshake message and any 846 second ClientHello that is sent in response MUST also be sent without 847 packet protection. This is natural, because no new keying material 848 will be available when these messages need to be sent. Upon receipt 849 of a HelloRetryRequest, a client SHOULD cease any transmission of 850 0-RTT data; 0-RTT data will only be discarded by any server that 851 sends a HelloRetryRequest. 853 Note: TLS handshake data that needs to be sent without protection is 854 all the handshake data acquired from TLS before the point that 855 1-RTT keys are provided by TLS (see Section 4.2.2). 857 The KEY_PHASE and VERSION bits ensure that protected packets are 858 clearly distinguished from unprotected packets. Loss or reordering 859 might cause unprotected packets to arrive once 1-RTT keys are in use, 860 unprotected packets are easily distinguished from 1-RTT packets. 862 Once 1-RTT keys are available to an endpoint, it no longer needs the 863 TLS handshake messages that are carried in unprotected packets. 864 However, a server might need to retransmit its TLS handshake messages 865 in response to receiving an unprotected packet that contains ACK 866 frames. A server MUST process ACK frames in unprotected packets 867 until the TLS handshake is reported as complete, or it receives an 868 ACK frame in a protected packet that acknowledges all of its 869 handshake messages. 871 To limit the number of key phases that could be active, an endpoint 872 MUST NOT initiate a key update while there are any unacknowledged 873 handshake messages, see Section 6.2. 875 6.2. Key Update 877 Once the TLS handshake is complete, the KEY_PHASE bit allows for 878 refreshes of keying material by either peer. Endpoints start using 879 updated keys immediately without additional signaling; the change in 880 the KEY_PHASE bit indicates that a new key is in use. 882 An endpoint MUST NOT initiate more than one key update at a time. A 883 new key cannot be used until the endpoint has received and 884 successfully decrypted a packet with a matching KEY_PHASE. Note that 885 when 0-RTT is attempted the value of the KEY_PHASE bit will be 886 different on packets sent by either peer. 888 A receiving endpoint detects an update when the KEY_PHASE bit doesn't 889 match what it is expecting. It creates a new secret (see 890 Section 5.2) and the corresponding read key and IV. If the packet 891 can be decrypted and authenticated using these values, then the keys 892 it uses for packet protection are also updated. The next packet sent 893 by the endpoint will then use the new keys. 895 An endpoint doesn't need to send packets immediately when it detects 896 that its peer has updated keys. The next packet that it sends will 897 simply use the new keys. If an endpoint detects a second update 898 before it has sent any packets with updated keys it indicates that 899 its peer has updated keys twice without awaiting a reciprocal update. 900 An endpoint MUST treat consecutive key updates as a fatal error and 901 abort the connection. 903 An endpoint SHOULD retain old keys for a short period to allow it to 904 decrypt packets with smaller packet numbers than the packet that 905 triggered the key update. This allows an endpoint to consume packets 906 that are reordered around the transition between keys. Packets with 907 higher packet numbers always use the updated keys and MUST NOT be 908 decrypted with old keys. 910 Keys and their corresponding secrets SHOULD be discarded when an 911 endpoint has received all packets with sequence numbers lower than 912 the lowest sequence number used for the new key. An endpoint might 913 discard keys if it determines that the length of the delay to 914 affected packets is excessive. 916 This ensures that once the handshake is complete, packets with the 917 same KEY_PHASE will have the same packet protection keys, unless 918 there are multiple key updates in a short time frame succession and 919 significant packet reordering. 921 Initiating Peer Responding Peer 923 @M QUIC Frames 924 New Keys -> @N 925 @N QUIC Frames 926 --------> 927 QUIC Frames @M 928 New Keys -> @N 929 QUIC Frames @N 930 <-------- 932 Figure 5: Key Update 934 As shown in Figure 3 and Figure 5, there is never a situation where 935 there are more than two different sets of keying material that might 936 be received by a peer. Once both sending and receiving keys have 937 been updated, 939 A server cannot initiate a key update until it has received the 940 client's Finished message. Otherwise, packets protected by the 941 updated keys could be confused for retransmissions of handshake 942 messages. A client cannot initiate a key update until all of its 943 handshake messages have been acknowledged by the server. 945 7. Pre-handshake QUIC Messages 947 Implementations MUST NOT exchange data on any stream other than 948 stream 1 without packet protection. QUIC requires the use of several 949 types of frame for managing loss detection and recovery during this 950 phase. In addition, it might be useful to use the data acquired 951 during the exchange of unauthenticated messages for congestion 952 control. 954 This section generally only applies to TLS handshake messages from 955 both peers and acknowledgments of the packets carrying those 956 messages. In many cases, the need for servers to provide 957 acknowledgments is minimal, since the messages that clients send are 958 small and implicitly acknowledged by the server's responses. 960 The actions that a peer takes as a result of receiving an 961 unauthenticated packet needs to be limited. In particular, state 962 established by these packets cannot be retained once record 963 protection commences. 965 There are several approaches possible for dealing with 966 unauthenticated packets prior to handshake completion: 968 o discard and ignore them 970 o use them, but reset any state that is established once the 971 handshake completes 973 o use them and authenticate them afterwards; failing the handshake 974 if they can't be authenticated 976 o save them and use them when they can be properly authenticated 978 o treat them as a fatal error 980 Different strategies are appropriate for different types of data. 981 This document proposes that all strategies are possible depending on 982 the type of message. 984 o Transport parameters and options are made usable and authenticated 985 as part of the TLS handshake (see Section 8.2). 987 o Most unprotected messages are treated as fatal errors when 988 received except for the small number necessary to permit the 989 handshake to complete (see Section 7.1). 991 o Protected packets can either be discarded or saved and later used 992 (see Section 7.3). 994 7.1. Unprotected Packets Prior to Handshake Completion 996 This section describes the handling of messages that are sent and 997 received prior to the completion of the TLS handshake. 999 Sending and receiving unprotected messages is hazardous. Unless 1000 expressly permitted, receipt of an unprotected message of any kind 1001 MUST be treated as a fatal error. 1003 7.1.1. STREAM Frames 1005 "STREAM" frames for stream 1 are permitted. These carry the TLS 1006 handshake messages. Once 1-RTT keys are available, unprotected 1007 "STREAM" frames on stream 1 can be ignored. 1009 Receiving unprotected "STREAM" frames for other streams MUST be 1010 treated as a fatal error. 1012 7.1.2. ACK Frames 1014 "ACK" frames are permitted prior to the handshake being complete. 1015 Information learned from "ACK" frames cannot be entirely relied upon, 1016 since an attacker is able to inject these packets. Timing and packet 1017 retransmission information from "ACK" frames is critical to the 1018 functioning of the protocol, but these frames might be spoofed or 1019 altered. 1021 Endpoints MUST NOT use an unprotected "ACK" frame to acknowledge data 1022 that was protected by 0-RTT or 1-RTT keys. An endpoint MUST ignore 1023 an unprotected "ACK" frame if it claims to acknowledge data that was 1024 sent in a protected packet. Such an acknowledgement can only serve 1025 as a denial of service, since an endpoint that can read protected 1026 data is always able to send protected data. 1028 ISSUE: What about 0-RTT data? Should we allow acknowledgment of 1029 0-RTT with unprotected frames? If we don't, then 0-RTT data will 1030 be unacknowledged until the handshake completes. This isn't a 1031 problem if the handshake completes without loss, but it could mean 1032 that 0-RTT stalls when a handshake packet disappears for any 1033 reason. 1035 An endpoint SHOULD use data from unprotected or 0-RTT-protected "ACK" 1036 frames only during the initial handshake and while they have 1037 insufficient information from 1-RTT-protected "ACK" frames. Once 1038 sufficient information has been obtained from protected messages, 1039 information obtained from less reliable sources can be discarded. 1041 7.1.3. WINDOW_UPDATE Frames 1043 "WINDOW_UPDATE" frames MUST NOT be sent unprotected. 1045 Though data is exchanged on stream 1, the initial flow control window 1046 is is sufficiently large to allow the TLS handshake to complete. 1047 This limits the maximum size of the TLS handshake and would prevent a 1048 server or client from using an abnormally large certificate chain. 1050 Stream 1 is exempt from the connection-level flow control window. 1052 7.1.4. Denial of Service with Unprotected Packets 1054 Accepting unprotected - specifically unauthenticated - packets 1055 presents a denial of service risk to endpoints. An attacker that is 1056 able to inject unprotected packets can cause a recipient to drop even 1057 protected packets with a matching sequence number. The spurious 1058 packet shadows the genuine packet, causing the genuine packet to be 1059 ignored as redundant. 1061 Once the TLS handshake is complete, both peers MUST ignore 1062 unprotected packets. From that point onward, unprotected messages 1063 can be safely dropped. 1065 Since only TLS handshake packets and acknowledgments are sent in the 1066 clear, an attacker is able to force implementations to rely on 1067 retransmission for packets that are lost or shadowed. Thus, an 1068 attacker that intends to deny service to an endpoint has to drop or 1069 shadow protected packets in order to ensure that their victim 1070 continues to accept unprotected packets. The ability to shadow 1071 packets means that an attacker does not need to be on path. 1073 ISSUE: This would not be an issue if QUIC had a randomized starting 1074 sequence number. If we choose to randomize, we fix this problem 1075 and reduce the denial of service exposure to on-path attackers. 1076 The only possible problem is in authenticating the initial value, 1077 so that peers can be sure that they haven't missed an initial 1078 message. 1080 In addition to causing valid packets to be dropped, an attacker can 1081 generate packets with an intent of causing the recipient to expend 1082 processing resources. See Section 9.2 for a discussion of these 1083 risks. 1085 To avoid receiving TLS packets that contain no useful data, a TLS 1086 implementation MUST reject empty TLS handshake records and any record 1087 that is not permitted by the TLS state machine. Any TLS application 1088 data or alerts that is received prior to the end of the handshake 1089 MUST be treated as a fatal error. 1091 7.2. Use of 0-RTT Keys 1093 If 0-RTT keys are available, the lack of replay protection means that 1094 restrictions on their use are necessary to avoid replay attacks on 1095 the protocol. 1097 A client MUST only use 0-RTT keys to protect data that is idempotent. 1098 A client MAY wish to apply additional restrictions on what data it 1099 sends prior to the completion of the TLS handshake. A client 1100 otherwise treats 0-RTT keys as equivalent to 1-RTT keys. 1102 A client that receives an indication that its 0-RTT data has been 1103 accepted by a server can send 0-RTT data until it receives all of the 1104 server's handshake messages. A client SHOULD stop sending 0-RTT data 1105 if it receives an indication that 0-RTT data has been rejected. 1107 A server MUST NOT use 0-RTT keys to protect packets. 1109 7.3. Protected Packets Prior to Handshake Completion 1111 Due to reordering and loss, protected packets might be received by an 1112 endpoint before the final handshake messages are received. If these 1113 can be decrypted successfully, such packets MAY be stored and used 1114 once the handshake is complete. 1116 Unless expressly permitted below, encrypted packets MUST NOT be used 1117 prior to completing the TLS handshake, in particular the receipt of a 1118 valid Finished message and any authentication of the peer. If 1119 packets are processed prior to completion of the handshake, an 1120 attacker might use the willingness of an implementation to use these 1121 packets to mount attacks. 1123 TLS handshake messages are covered by record protection during the 1124 handshake, once key agreement has completed. This means that 1125 protected messages need to be decrypted to determine if they are TLS 1126 handshake messages or not. Similarly, "ACK" and "WINDOW_UPDATE" 1127 frames might be needed to successfully complete the TLS handshake. 1129 Any timestamps present in "ACK" frames MUST be ignored rather than 1130 causing a fatal error. Timestamps on protected frames MAY be saved 1131 and used once the TLS handshake completes successfully. 1133 An endpoint MAY save the last protected "WINDOW_UPDATE" frame it 1134 receives for each stream and apply the values once the TLS handshake 1135 completes. Failing to do this might result in temporary stalling of 1136 affected streams. 1138 8. QUIC-Specific Additions to the TLS Handshake 1140 QUIC uses the TLS handshake for more than just negotiation of 1141 cryptographic parameters. The TLS handshake validates protocol 1142 version selection, provides preliminary values for QUIC transport 1143 parameters, and allows a server to perform return routeability checks 1144 on clients. 1146 8.1. Protocol and Version Negotiation 1148 The QUIC version negotiation mechanism is used to negotiate the 1149 version of QUIC that is used prior to the completion of the 1150 handshake. However, this packet is not authenticated, enabling an 1151 active attacker to force a version downgrade. 1153 To ensure that a QUIC version downgrade is not forced by an attacker, 1154 version information is copied into the TLS handshake, which provides 1155 integrity protection for the QUIC negotiation. This does not prevent 1156 version downgrade during the handshake, though it means that such a 1157 downgrade causes a handshake failure. 1159 Protocols that use the QUIC transport MUST use Application Layer 1160 Protocol Negotiation (ALPN) [RFC7301]. The ALPN identifier for the 1161 protocol MUST be specific to the QUIC version that it operates over. 1162 When constructing a ClientHello, clients MUST include a list of all 1163 the ALPN identifiers that they support, regardless of whether the 1164 QUIC version that they have currently selected supports that 1165 protocol. 1167 Servers SHOULD select an application protocol based solely on the 1168 information in the ClientHello, not using the QUIC version that the 1169 client has selected. If the protocol that is selected is not 1170 supported with the QUIC version that is in use, the server MAY send a 1171 QUIC version negotiation packet to select a compatible version. 1173 If the server cannot select a combination of ALPN identifier and QUIC 1174 version it MUST abort the connection. A client MUST abort a 1175 connection if the server picks an incompatible version of QUIC 1176 version and ALPN. 1178 8.2. QUIC Extension 1180 QUIC defines an extension for use with TLS. That extension defines 1181 transport-related parameters. This provides integrity protection for 1182 these values. Including these in the TLS handshake also make the 1183 values that a client sets available to a server one-round trip 1184 earlier than parameters that are carried in QUIC packets. This 1185 document does not define that extension. 1187 8.3. Source Address Validation 1189 QUIC implementations describe a source address token. This is an 1190 opaque blob that a server might provide to clients when they first 1191 use a given source address. The client returns this token in 1192 subsequent messages as a return routeability check. That is, the 1193 client returns this token to prove that it is able to receive packets 1194 at the source address that it claims. This prevents the server from 1195 being used in packet reflection attacks (see Section 9.1). 1197 A source address token is opaque and consumed only by the server. 1198 Therefore it can be included in the TLS 1.3 pre-shared key identifier 1199 for 0-RTT handshakes. Servers that use 0-RTT are advised to provide 1200 new pre-shared key identifiers after every handshake to avoid 1201 linkability of connections by passive observers. Clients MUST use a 1202 new pre-shared key identifier for every connection that they 1203 initiate; if no pre-shared key identifier is available, then 1204 resumption is not possible. 1206 A server that is under load might include a source address token in 1207 the cookie extension of a HelloRetryRequest. 1209 8.4. Priming 0-RTT 1211 QUIC uses TLS without modification. Therefore, it is possible to use 1212 a pre-shared key that was obtained in a TLS connection over TCP to 1213 enable 0-RTT in QUIC. Similarly, QUIC can provide a pre-shared key 1214 that can be used to enable 0-RTT in TCP. 1216 All the restrictions on the use of 0-RTT apply, with the exception of 1217 the ALPN label, which MUST only change to a label that is explicitly 1218 designated as being compatible. The client indicates which ALPN 1219 label it has chosen by placing that ALPN label first in the ALPN 1220 extension. 1222 The certificate that the server uses MUST be considered valid for 1223 both connections, which will use different protocol stacks and could 1224 use different port numbers. For instance, HTTP/1.1 and HTTP/2 1225 operate over TLS and TCP, whereas QUIC operates over UDP. 1227 Source address validation is not completely portable between 1228 different protocol stacks. Even if the source IP address remains 1229 constant, the port number is likely to be different. Packet 1230 reflection attacks are still possible in this situation, though the 1231 set of hosts that can initiate these attacks is greatly reduced. A 1232 server might choose to avoid source address validation for such a 1233 connection, or allow an increase to the amount of data that it sends 1234 toward the client without source validation. 1236 9. Security Considerations 1238 There are likely to be some real clangers here eventually, but the 1239 current set of issues is well captured in the relevant sections of 1240 the main text. 1242 Never assume that because it isn't in the security considerations 1243 section it doesn't affect security. Most of this document does. 1245 9.1. Packet Reflection Attack Mitigation 1247 A small ClientHello that results in a large block of handshake 1248 messages from a server can be used in packet reflection attacks to 1249 amplify the traffic generated by an attacker. 1251 Certificate caching [RFC7924] can reduce the size of the server's 1252 handshake messages significantly. 1254 A client SHOULD also pad [RFC7685] its ClientHello to at least 1024 1255 octets. A server is less likely to generate a packet reflection 1256 attack if the data it sends is a small multiple of the data it 1257 receives. A server SHOULD use a HelloRetryRequest if the size of the 1258 handshake messages it sends is likely to exceed the size of the 1259 ClientHello. 1261 9.2. Peer Denial of Service 1263 QUIC, TLS and HTTP/2 all contain a messages that have legitimate uses 1264 in some contexts, but that can be abused to cause a peer to expend 1265 processing resources without having any observable impact on the 1266 state of the connection. If processing is disproportionately large 1267 in comparison to the observable effects on bandwidth or state, then 1268 this could allow a malicious peer to exhaust processing capacity 1269 without consequence. 1271 QUIC prohibits the sending of empty "STREAM" frames unless they are 1272 marked with the FIN bit. This prevents "STREAM" frames from being 1273 sent that only waste effort. 1275 TLS records SHOULD always contain at least one octet of a handshake 1276 messages or alert. Records containing only padding are permitted 1277 during the handshake, but an excessive number might be used to 1278 generate unnecessary work. Once the TLS handshake is complete, 1279 endpoints SHOULD NOT send TLS application data records unless it is 1280 to hide the length of QUIC records. QUIC packet protection does not 1281 include any allowance for padding; padded TLS application data 1282 records can be used to mask the length of QUIC frames. 1284 While there are legitimate uses for some redundant packets, 1285 implementations SHOULD track redundant packets and treat excessive 1286 volumes of any non-productive packets as indicative of an attack. 1288 10. Error codes 1290 The portion of the QUIC error code space allocated for the crypto 1291 handshake is 0xB000-0xFFFF. The following error codes are defined 1292 when TLS is used for the crypto handshake: 1294 TLS_HANDSHAKE_FAILED (0xB01c): Crypto errors. Handshake failed. 1296 TLS_MESSAGE_OUT_OF_ORDER (0xB01d): Handshake message received out of 1297 order. 1299 TLS_TOO_MANY_ENTRIES (0xB01e): Handshake message contained too many 1300 entries. 1302 TLS_INVALID_VALUE_LENGTH (0xB01f): Handshake message contained an 1303 invalid value length. 1305 TLS_MESSAGE_AFTER_HANDSHAKE_COMPLETE (0xB020): A handshake message 1306 was received after the handshake was complete. 1308 TLS_INVALID_RECORD_TYPE (0xB021): A handshake message was received 1309 with an illegal record type. 1311 TLS_INVALID_PARAMETER (0xB022): A handshake message was received 1312 with an illegal parameter. 1314 TLS_INVALID_CHANNEL_ID_SIGNATURE (0xB034): An invalid channel id 1315 signature was supplied. 1317 TLS_MESSAGE_PARAMETER_NOT_FOUND (0xB023): A handshake message was 1318 received with a mandatory parameter missing. 1320 TLS_MESSAGE_PARAMETER_NO_OVERLAP (0xB024): A handshake message was 1321 received with a parameter that has no overlap with the local 1322 parameter. 1324 TLS_MESSAGE_INDEX_NOT_FOUND (0xB025): A handshake message was 1325 received that contained a parameter with too few values. 1327 TLS_UNSUPPORTED_PROOF_DEMAND (0xB05e): A demand for an unsupported 1328 proof type was received. 1330 TLS_INTERNAL_ERROR (0xB026): An internal error occured in handshake 1331 processing. 1333 TLS_VERSION_NOT_SUPPORTED (0xB027): A handshake handshake message 1334 specified an unsupported version. 1336 TLS_HANDSHAKE_STATELESS_REJECT (0xB048): A handshake handshake 1337 message resulted in a stateless reject. 1339 TLS_NO_SUPPORT (0xB028): There was no intersection between the 1340 crypto primitives supported by the peer and ourselves. 1342 TLS_TOO_MANY_REJECTS (0xB029): The server rejected our client hello 1343 messages too many times. 1345 TLS_PROOF_INVALID (0xB02a): The client rejected the server's 1346 certificate chain or signature. 1348 TLS_DUPLICATE_TAG (0xB02b): A handshake message was received with a 1349 duplicate tag. 1351 TLS_ENCRYPTION_LEVEL_INCORRECT (0xB02c): A handshake message was 1352 received with the wrong encryption level (i.e. it should have been 1353 encrypted but was not.) 1355 TLS_SERVER_CONFIG_EXPIRED (0xB02d): The server config for a server 1356 has expired. 1358 TLS_SYMMETRIC_KEY_SETUP_FAILED (0xB035): We failed to set up the 1359 symmetric keys for a connection. 1361 TLS_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO (0xB036): A handshake 1362 message arrived, but we are still validating the previous 1363 handshake message. 1365 TLS_UPDATE_BEFORE_HANDSHAKE_COMPLETE (0xB041): A server config 1366 update arrived before the handshake is complete. 1368 TLS_CLIENT_HELLO_TOO_LARGE (0xB05a): ClientHello cannot fit in one 1369 packet. 1371 11. IANA Considerations 1373 This document has no IANA actions. Yet. 1375 12. References 1377 12.1. Normative References 1379 [I-D.ietf-tls-tls13] 1380 Rescorla, E., "The Transport Layer Security (TLS) Protocol 1381 Version 1.3", draft-ietf-tls-tls13-18 (work in progress), 1382 October 2016. 1384 [QUIC-TRANSPORT] 1385 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1386 Multiplexed and Secure Transport". 1388 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1389 Requirement Levels", BCP 14, RFC 2119, 1390 DOI 10.17487/RFC2119, March 1997, 1391 . 1393 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 1394 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1395 . 1397 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1398 Key Derivation Function (HKDF)", RFC 5869, 1399 DOI 10.17487/RFC5869, May 2010, 1400 . 1402 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1403 Protocol (HTTP/1.1): Message Syntax and Routing", 1404 RFC 7230, DOI 10.17487/RFC7230, June 2014, 1405 . 1407 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1408 "Transport Layer Security (TLS) Application-Layer Protocol 1409 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1410 July 2014, . 1412 [RFC7685] Langley, A., "A Transport Layer Security (TLS) ClientHello 1413 Padding Extension", RFC 7685, DOI 10.17487/RFC7685, 1414 October 2015, . 1416 12.2. Informative References 1418 [AEBounds] 1419 Luykx, A. and K. Paterson, "Limits on Authenticated 1420 Encryption Use in TLS", March 2016, 1421 . 1423 [QUIC-HTTP] 1424 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1425 QUIC". 1427 [QUIC-RECOVERY] 1428 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1429 and Congestion Control". 1431 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 1432 RFC 793, DOI 10.17487/RFC0793, September 1981, 1433 . 1435 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1436 Housley, R., and W. Polk, "Internet X.509 Public Key 1437 Infrastructure Certificate and Certificate Revocation List 1438 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1439 . 1441 [RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 1442 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 1443 DOI 10.17487/RFC7540, May 2015, 1444 . 1446 [RFC7924] Santesson, S. and H. Tschofenig, "Transport Layer Security 1447 (TLS) Cached Information Extension", RFC 7924, 1448 DOI 10.17487/RFC7924, July 2016, 1449 . 1451 Appendix A. Contributors 1453 Ryan Hamilton was originally an author of this specification. 1455 Appendix B. Acknowledgments 1457 This document has benefited from input from Dragana Damjanovic, 1458 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 1459 Rescorla, Ian Swett, and many others. 1461 Appendix C. Change Log 1463 *RFC Editor's Note:* Please remove this section prior to 1464 publication of a final version of this document. 1466 C.1. Since draft-ietf-quic-tls-00: 1468 o Changed bit used to signal key phase. 1470 o Updated key phase markings during the handshake. 1472 o Added TLS interface requirements section. 1474 o Moved to use of TLS exporters for key derivation. 1476 o Moved TLS error code definitions into this document. 1478 C.2. Since draft-thomson-quic-tls-01: 1480 o Adopted as base for draft-ietf-quic-tls. 1482 o Updated authors/editors list. 1484 o Added status note. 1486 Authors' Addresses 1488 Martin Thomson (editor) 1489 Mozilla 1491 Email: martin.thomson@gmail.com 1493 Sean Turner (editor) 1494 sn3rd