RFC 9001: Using TLS to Secure QUIC
- M. Thomson, Ed.,
- S. Turner, Ed.
Abstract
This document describes how Transport Layer Security (TLS) is used to secure QUIC.¶
Status of This Memo
This is an Internet Standards Track document.¶
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.¶
Information about the current status of this document, any
errata, and how to provide feedback on it may be obtained at
https://
Copyright Notice
Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://
1. Introduction
This document describes how QUIC [QUIC-TRANSPORT] is secured using TLS [TLS13].¶
TLS 1.3 provides critical latency improvements for connection establishment over previous versions. Absent packet loss, most new connections can be established and secured within a single round trip; on subsequent connections between the same client and server, the client can often send application data immediately, that is, using a zero round-trip setup.¶
This document describes how TLS acts as a security component of QUIC.¶
2. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
This document uses the terminology established in [QUIC-TRANSPORT].¶
For brevity, the acronym TLS is used to refer to TLS 1.3, though a newer version could be used; see Section 4.2.¶
2.1. TLS Overview
TLS provides two endpoints with a way to establish a means of communication over an untrusted medium (for example, the Internet). TLS enables authentication of peers and provides confidentiality and integrity protection for messages that endpoints exchange.¶
Internally, TLS is a layered protocol, with the structure shown in Figure 1.¶
Each content-layer message (e.g., handshake, alerts, and application data) is
carried as a series of typed TLS records by the record layer. Records are
individually cryptographical
The TLS authenticated key exchange occurs between two endpoints: client and server. The client initiates the exchange and the server responds. If the key exchange completes successfully, both client and server will agree on a secret. TLS supports both pre-shared key (PSK) and Diffie-Hellman over either finite fields or elliptic curves ((EC)DHE) key exchanges. PSK is the basis for Early Data (0-RTT); the latter provides forward secrecy (FS) when the (EC)DHE keys are destroyed. The two modes can also be combined to provide forward secrecy while using the PSK for authentication.¶
After completing the TLS handshake, the client will have learned and
authenticated an identity for the server, and the server is optionally able to
learn and authenticate an identity for the client. TLS supports X.509
[RFC5280] certificate
The TLS key exchange is resistant to tampering by attackers, and it produces shared secrets that cannot be controlled by either participating peer.¶
TLS provides two basic handshake modes of interest to QUIC:¶
A simplified TLS handshake with 0-RTT application data is shown in Figure 2.¶
Figure 2 omits the EndOfEarlyData message, which is not used in QUIC; see
Section 8.3. Likewise, neither Change
Data is protected using a number of encryption levels:¶
Application data can only appear in the early data and application data levels. Handshake and alert messages may appear in any level.¶
The 0-RTT handshake can be used if the client and server have previously communicated. In the 1-RTT handshake, the client is unable to send protected application data until it has received all of the handshake messages sent by the server.¶
3. Protocol Overview
QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality and
integrity protection of packets. For this it uses keys derived from a TLS
handshake [TLS13], but instead of carrying TLS records over QUIC (as with
TCP), TLS handshake and alert messages are carried directly over the QUIC
transport, which takes over the responsibilitie
QUIC also relies on TLS for authentication and negotiation of parameters that are critical to security and performance.¶
Rather than a strict layering, these two protocols cooperate: QUIC uses the TLS handshake; TLS uses the reliability, ordered delivery, and record layer provided by QUIC.¶
At a high level, there are two main interactions between the TLS and QUIC components:¶
Figure 4 shows these interactions in more detail, with the QUIC packet protection being called out specially.¶
Unlike TLS over TCP, QUIC applications that want to send data do not send it using TLS Application Data records. Rather, they send it as QUIC STREAM frames or other frame types, which are then carried in QUIC packets.¶
4. Carrying TLS Messages
QUIC carries TLS handshake data in CRYPTO frames, each of which consists of a contiguous block of handshake data identified by an offset and length. Those frames are packaged into QUIC packets and encrypted under the current encryption level. As with TLS over TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's responsibility to deliver it reliably. Each chunk of data that is produced by TLS is associated with the set of keys that TLS is currently using. If QUIC needs to retransmit that data, it MUST use the same keys even if TLS has already updated to newer keys.¶
Each encryption level corresponds to a packet number space. The packet number space that is used determines the semantics of frames. Some frames are prohibited in different packet number spaces; see Section 12.5 of [QUIC-TRANSPORT].¶
Because packets could be reordered on the wire, QUIC uses the packet type to indicate which keys were used to protect a given packet, as shown in Table 1. When packets of different types need to be sent, endpoints SHOULD use coalesced packets to send them in the same UDP datagram.¶
Section 17 of [QUIC-TRANSPORT] shows how packets at the various encryption levels fit into the handshake process.¶
4.1. Interface to TLS
As shown in Figure 4, the interface from QUIC to TLS consists of four primary functions:¶
Additional functions might be needed to configure TLS. In particular, QUIC and TLS need to agree on which is responsible for validation of peer credentials, such as certificate validation [RFC5280].¶
4.1.1. Handshake Complete
In this document, the TLS handshake is considered complete when the TLS stack has reported that the handshake is complete. This happens when the TLS stack has both sent a Finished message and verified the peer's Finished message. Verifying the peer's Finished message provides the endpoints with an assurance that previous handshake messages have not been modified. Note that the handshake does not complete at both endpoints simultaneously. Consequently, any requirement that is based on the completion of the handshake depends on the perspective of the endpoint in question.¶
4.1.2. Handshake Confirmed
In this document, the TLS handshake is considered confirmed at the server when the handshake completes. The server MUST send a HANDSHAKE_DONE frame as soon as the handshake is complete. At the client, the handshake is considered confirmed when a HANDSHAKE_DONE frame is received.¶
Additionally, a client MAY consider the handshake to be confirmed when it receives an acknowledgment for a 1-RTT packet. This can be implemented by recording the lowest packet number sent with 1-RTT keys and comparing it to the Largest Acknowledged field in any received 1-RTT ACK frame: once the latter is greater than or equal to the former, the handshake is confirmed.¶
4.1.3. Sending and Receiving Handshake Messages
In order to drive the handshake, TLS depends on being able to send and receive handshake messages. There are two basic functions on this interface: one where QUIC requests handshake messages and one where QUIC provides bytes that comprise handshake messages.¶
Before starting the handshake, QUIC provides TLS with the transport parameters (see Section 8.2) that it wishes to carry.¶
A QUIC client starts TLS by requesting TLS handshake bytes from TLS. The client acquires handshake bytes before sending its first packet. A QUIC server starts the process by providing TLS with the client's handshake bytes.¶
At any time, the TLS stack at an endpoint will have a current sending encryption level and a receiving encryption level. TLS encryption levels determine the QUIC packet type and keys that are used for protecting data.¶
Each encryption level is associated with a different sequence of bytes, which is reliably transmitted to the peer in CRYPTO frames. When TLS provides handshake bytes to be sent, they are appended to the handshake bytes for the current encryption level. The encryption level then determines the type of packet that the resulting CRYPTO frame is carried in; see Table 1.¶
Four encryption levels are used, producing keys for Initial, 0-RTT, Handshake, and 1-RTT packets. CRYPTO frames are carried in just three of these levels, omitting the 0-RTT level. These four levels correspond to three packet number spaces: Initial and Handshake encrypted packets use their own separate spaces; 0-RTT and 1-RTT packets use the application data packet number space.¶
QUIC takes the unprotected content of TLS handshake records as the content of CRYPTO frames. TLS record protection is not used by QUIC. QUIC assembles CRYPTO frames into QUIC packets, which are protected using QUIC packet protection.¶
QUIC CRYPTO frames only carry TLS handshake messages. TLS
alerts are turned into QUIC CONNECTION
When an endpoint receives a QUIC packet containing a CRYPTO frame from the network, it proceeds as follows:¶
Each time that TLS is provided with new data, new handshake bytes are requested from TLS. TLS might not provide any bytes if the handshake messages it has received are incomplete or it has no data to send.¶
The content of CRYPTO frames might either be processed incrementally by TLS or buffered until complete messages or flights are available. TLS is responsible for buffering handshake bytes that have arrived in order. QUIC is responsible for buffering handshake bytes that arrive out of order or for encryption levels that are not yet ready. QUIC does not provide any means of flow control for CRYPTO frames; see Section 7.5 of [QUIC-TRANSPORT].¶
Once the TLS handshake is complete, this is indicated to QUIC along with any final handshake bytes that TLS needs to send. At this stage, the transport parameters that the peer advertised during the handshake are authenticated; see Section 8.2.¶
Once the handshake is complete, TLS becomes passive. TLS can still receive data from its peer and respond in kind, but it will not need to send more data unless specifically requested -- either by an application or QUIC. One reason to send data is that the server might wish to provide additional or updated session tickets to a client.¶
When the handshake is complete, QUIC only needs to provide TLS with any data that arrives in CRYPTO streams. In the same manner that is used during the handshake, new data is requested from TLS after providing received data.¶
4.1.4. Encryption Level Changes
As keys at a given encryption level become available to TLS, TLS indicates to QUIC that reading or writing keys at that encryption level are available.¶
The availability of new keys is always a result of providing inputs to TLS. TLS only provides new keys after being initialized (by a client) or when provided with new handshake data.¶
However, a TLS implementation could perform some of its processing asynchronously. In particular, the process of validating a certificate can take some time. While waiting for TLS processing to complete, an endpoint SHOULD buffer received packets if they might be processed using keys that are not yet available. These packets can be processed once keys are provided by TLS. An endpoint SHOULD continue to respond to packets that can be processed during this time.¶
After processing inputs, TLS might produce handshake bytes, keys for new encryption levels, or both.¶
TLS provides QUIC with three items as a new encryption level becomes available:¶
These values are based on the values that TLS negotiates and are used by QUIC to generate packet and header protection keys; see Section 5 and Section 5.4.¶
If 0-RTT is possible, it is ready after the client sends a TLS ClientHello message or the server receives that message. After providing a QUIC client with the first handshake bytes, the TLS stack might signal the change to 0-RTT keys. On the server, after receiving handshake bytes that contain a ClientHello message, a TLS server might signal that 0-RTT keys are available.¶
Although TLS only uses one encryption level at a time, QUIC may use more than one level. For instance, after sending its Finished message (using a CRYPTO frame at the Handshake encryption level) an endpoint can send STREAM data (in 1-RTT encryption). If the Finished message is lost, the endpoint uses the Handshake encryption level to retransmit the lost message. Reordering or loss of packets can mean that QUIC will need to handle packets at multiple encryption levels. During the handshake, this means potentially handling packets at higher and lower encryption levels than the current encryption level used by TLS.¶
In particular, server implementations need to be able to read packets at the Handshake encryption level at the same time as the 0-RTT encryption level. A client could interleave ACK frames that are protected with Handshake keys with 0-RTT data, and the server needs to process those acknowledgments in order to detect lost Handshake packets.¶
QUIC also needs access to keys that might not ordinarily be available to a TLS implementation. For instance, a client might need to acknowledge Handshake packets before it is ready to send CRYPTO frames at that encryption level. TLS therefore needs to provide keys to QUIC before it might produce them for its own use.¶
4.1.5. TLS Interface Summary
Figure 5 summarizes the exchange between QUIC and TLS for both client and server. Solid arrows indicate packets that carry handshake data; dashed arrows show where application data can be sent. Each arrow is tagged with the encryption level used for that transmission.¶
Figure 5 shows the multiple packets that form a single "flight" of messages being processed individually, to show what incoming messages trigger different actions. This shows multiple "Get Handshake" invocations to retrieve handshake messages at different encryption levels. New handshake messages are requested after incoming packets have been processed.¶
Figure 5 shows one possible structure for a simple handshake exchange. The exact process varies based on the structure of endpoint implementations and the order in which packets arrive. Implementations could use a different number of operations or execute them in other orders.¶
4.2. TLS Version
This document describes how TLS 1.3 [TLS13] is used with QUIC.¶
In practice, the TLS handshake will negotiate a version of TLS to use. This could result in a version of TLS newer than 1.3 being negotiated if both endpoints support that version. This is acceptable provided that the features of TLS 1.3 that are used by QUIC are supported by the newer version.¶
Clients MUST NOT offer TLS versions older than 1.3. A badly configured TLS implementation could negotiate TLS 1.2 or another older version of TLS. An endpoint MUST terminate the connection if a version of TLS older than 1.3 is negotiated.¶
4.3. ClientHello Size
The first Initial packet from a client contains the start or all of its first
cryptographic handshake message, which for TLS is the ClientHello. Servers
might need to parse the entire ClientHello (e.g., to access extensions such as
Server Name Identification (SNI) or Application
QUIC packet and framing add at least 36 bytes of overhead to the ClientHello message. That overhead increases if the client chooses a Source Connection ID field longer than zero bytes. Overheads also do not include the token or a Destination Connection ID longer than 8 bytes, both of which might be required if a server sends a Retry packet.¶
A typical TLS ClientHello can easily fit into a 1200-byte packet. However, in addition to the overheads added by QUIC, there are several variables that could cause this limit to be exceeded. Large session tickets, multiple or large key shares, and long lists of supported ciphers, signature algorithms, versions, QUIC transport parameters, and other negotiable parameters and extensions could cause this message to grow.¶
For servers, in addition to connection IDs and tokens, the size of TLS session tickets can have an effect on a client's ability to connect efficiently. Minimizing the size of these values increases the probability that clients can use them and still fit their entire ClientHello message in their first Initial packet.¶
The TLS implementation does not need to ensure that the ClientHello is large enough to meet QUIC's requirements for datagrams that carry Initial packets; see Section 14.1 of [QUIC-TRANSPORT]. QUIC implementations use PADDING frames or packet coalescing to ensure that datagrams are large enough.¶
4.4. Peer Authentication
The requirements for authentication depend on the application protocol that is in use. TLS provides server authentication and permits the server to request client authentication.¶
A client MUST authenticate the identity of the server. This typically involves verification that the identity of the server is included in a certificate and that the certificate is issued by a trusted entity (see for example [RFC2818]).¶
A server MAY request that the client authenticate during the handshake. A server MAY refuse a connection if the client is unable to authenticate when requested. The requirements for client authentication vary based on application protocol and deployment.¶
A server MUST NOT use post-handshake client authentication (as defined in
Section 4.6.2 of [TLS13]) because the multiplexing offered by QUIC prevents
clients from correlating the certificate request with the application
4.5. Session Resumption
QUIC can use the session resumption feature of TLS 1.3. It does this by
carrying New
Endpoints that use session resumption might need to remember some information about the current connection when creating a resumed connection. TLS requires that some information be retained; see Section 4.6.1 of [TLS13]. QUIC itself does not depend on any state being retained when resuming a connection unless 0-RTT is also used; see Section 7.4.1 of [QUIC-TRANSPORT] and Section 4.6.1. Application protocols could depend on state that is retained between resumed connections.¶
Clients can store any state required for resumption along with the session ticket. Servers can use the session ticket to help carry state.¶
Session resumption allows servers to link activity on the original connection with the resumed connection, which might be a privacy issue for clients. Clients can choose not to enable resumption to avoid creating this correlation. Clients SHOULD NOT reuse tickets as that allows entities other than the server to correlate connections; see Appendix C.4 of [TLS13].¶
4.6. 0-RTT
The 0-RTT feature in QUIC allows a client to send application data before the handshake is complete. This is made possible by reusing negotiated parameters from a previous connection. To enable this, 0-RTT depends on the client remembering critical parameters and providing the server with a TLS session ticket that allows the server to recover the same information.¶
This information includes parameters that determine TLS state, as governed by [TLS13], QUIC transport parameters, the chosen application protocol, and any information the application protocol might need; see Section 4.6.3. This information determines how 0-RTT packets and their contents are formed.¶
To ensure that the same information is available to both endpoints, all information used to establish 0-RTT comes from the same connection. Endpoints cannot selectively disregard information that might alter the sending or processing of 0-RTT.¶
[TLS13] sets a limit of seven days on the time between the original connection and any attempt to use 0-RTT. There are other constraints on 0-RTT usage, notably those caused by the potential exposure to replay attack; see Section 9.2.¶
4.6.1. Enabling 0-RTT
The TLS early_data extension in the New
Servers MUST NOT send the early_data extension with a max
A client that wishes to send 0-RTT packets uses the early_data extension in the ClientHello message of a subsequent handshake; see Section 4.2.10 of [TLS13]. It then sends application data in 0-RTT packets.¶
A client that attempts 0-RTT might also provide an address validation token if the server has sent a NEW_TOKEN frame; see Section 8.1 of [QUIC-TRANSPORT].¶
4.6.2. Accepting and Rejecting 0-RTT
A server accepts 0-RTT by sending an early_data extension in the
Encrypted
A server rejects 0-RTT by sending the Encrypted
When 0-RTT is rejected, all connection characteristics that the client assumed might be incorrect. This includes the choice of application protocol, transport parameters, and any application configuration. The client therefore MUST reset the state of all streams, including application state bound to those streams.¶
A client MAY reattempt 0-RTT if it receives a Retry or Version Negotiation packet. These packets do not signify rejection of 0-RTT.¶
4.6.3. Validating 0-RTT Configuration
When a server receives a ClientHello with the early_data extension, it has to decide whether to accept or reject 0-RTT data from the client. Some of this decision is made by the TLS stack (e.g., checking that the cipher suite being resumed was included in the ClientHello; see Section 4.2.10 of [TLS13]). Even when the TLS stack has no reason to reject 0-RTT data, the QUIC stack or the application protocol using QUIC might reject 0-RTT data because the configuration of the transport or application associated with the resumed session is not compatible with the server's current configuration.¶
QUIC requires additional transport state to be associated with a 0-RTT session ticket. One common way to implement this is using stateless session tickets and storing this state in the session ticket. Application protocols that use QUIC might have similar requirements regarding associating or storing state. This associated state is used for deciding whether 0-RTT data must be rejected. For example, HTTP/3 settings [QUIC-HTTP] determine how 0-RTT data from the client is interpreted. Other applications using QUIC could have different requirements for determining whether to accept or reject 0-RTT data.¶
4.7. HelloRetryRequest
The Hello
4.8. TLS Errors
If TLS experiences an error, it generates an appropriate alert as defined in Section 6 of [TLS13].¶
A TLS alert is converted into a QUIC connection error. The Alert
QUIC is only able to convey an alert level of "fatal". In TLS 1.3, the only existing uses for the "warning" level are to signal connection close; see Section 6.1 of [TLS13]. As QUIC provides alternative mechanisms for connection termination and the TLS connection is only closed if an error is encountered, a QUIC endpoint MUST treat any alert from TLS as if it were at the "fatal" level.¶
QUIC permits the use of a generic code in place of a specific error code; see
Section 11 of [QUIC-TRANSPORT]. For TLS alerts, this includes replacing any
alert with a generic alert, such as handshake
4.9. Discarding Unused Keys
After QUIC has completed a move to a new encryption level, packet protection keys for previous encryption levels can be discarded. This occurs several times during the handshake, as well as when keys are updated; see Section 6.¶
Packet protection keys are not discarded immediately when new keys are available. If packets from a lower encryption level contain CRYPTO frames, frames that retransmit that data MUST be sent at the same encryption level. Similarly, an endpoint generates acknowledgments for packets at the same encryption level as the packet being acknowledged. Thus, it is possible that keys for a lower encryption level are needed for a short time after keys for a newer encryption level are available.¶
An endpoint cannot discard keys for a given encryption level unless it has received all the cryptographic handshake messages from its peer at that encryption level and its peer has done the same. Different methods for determining this are provided for Initial keys (Section 4.9.1) and Handshake keys (Section 4.9.2). These methods do not prevent packets from being received or sent at that encryption level because a peer might not have received all the acknowledgments necessary.¶
Though an endpoint might retain older keys, new data MUST be sent at the highest currently available encryption level. Only ACK frames and retransmissions of data in CRYPTO frames are sent at a previous encryption level. These packets MAY also include PADDING frames.¶
4.9.1. Discarding Initial Keys
Packets protected with Initial secrets (Section 5.2) are not authenticated, meaning that an attacker could spoof packets with the intent to disrupt a connection. To limit these attacks, Initial packet protection keys are discarded more aggressively than other keys.¶
The successful use of Handshake packets indicates that no more Initial packets need to be exchanged, as these keys can only be produced after receiving all CRYPTO frames from Initial packets. Thus, a client MUST discard Initial keys when it first sends a Handshake packet and a server MUST discard Initial keys when it first successfully processes a Handshake packet. Endpoints MUST NOT send Initial packets after this point.¶
This results in abandoning loss recovery state for the Initial encryption level and ignoring any outstanding Initial packets.¶
4.9.2. Discarding Handshake Keys
An endpoint MUST discard its Handshake keys when the TLS handshake is confirmed (Section 4.1.2).¶
4.9.3. Discarding 0-RTT Keys
0-RTT and 1-RTT packets share the same packet number space, and clients do not send 0-RTT packets after sending a 1-RTT packet (Section 5.6).¶
Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 1-RTT keys as they have no use after that moment.¶
Additionally, a server MAY discard 0-RTT keys as soon as it receives a 1-RTT packet. However, due to packet reordering, a 0-RTT packet could arrive after a 1-RTT packet. Servers MAY temporarily retain 0-RTT keys to allow decrypting reordered packets without requiring their contents to be retransmitted with 1-RTT keys. After receiving a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; the RECOMMENDED time period is three times the Probe Timeout (PTO, see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it determines that it has received all 0-RTT packets, which can be done by keeping track of missing packet numbers.¶
5. Packet Protection
As with TLS over TCP, QUIC protects packets with keys derived from the TLS handshake, using the AEAD algorithm [AEAD] negotiated by TLS.¶
QUIC packets have varying protections depending on their type:¶
This section describes how packet protection is applied to Handshake packets, 0-RTT packets, and 1-RTT packets. The same packet protection process is applied to Initial packets. However, as it is trivial to determine the keys used for Initial packets, these packets are not considered to have confidentiality or integrity protection. Retry packets use a fixed key and so similarly lack confidentiality and integrity protection.¶
5.1. Packet Protection Keys
QUIC derives packet protection keys in the same way that TLS derives record protection keys.¶
Each encryption level has separate secret values for protection of packets sent in each direction. These traffic secrets are derived by TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all encryption levels except the Initial encryption level. The secrets for the Initial encryption level are computed based on the client's initial Destination Connection ID, as described in Section 5.2.¶
The keys used for packet protection are computed from the TLS secrets using the
KDF provided by TLS. In TLS 1.3, the HKDF
Note that labels, which are described using strings, are encoded as bytes using ASCII [ASCII] without quotes or any trailing NUL byte.¶
Other versions of TLS MUST provide a similar function in order to be used with QUIC.¶
The current encryption level secret and the label "quic key" are input to the KDF to produce the AEAD key; the label "quic iv" is used to derive the Initialization Vector (IV); see Section 5.3. The header protection key uses the "quic hp" label; see Section 5.4. Using these labels provides key separation between QUIC and TLS; see Section 9.6.¶
Both "quic key" and "quic hp" are used to produce keys, so the Length provided
to HKDF
The KDF used for initial secrets is always the HKDF
5.2. Initial Secrets
Initial packets apply the packet protection process, but use a secret derived from the Destination Connection ID field from the client's first Initial packet.¶
This secret is determined by using HKDF-Extract (see Section 2.2 of [HKDF])
with a salt of 0x38762cf7f5593
The secret used by clients to construct Initial packets uses the PRK and the
label "client in" as input to the HKDF
This process in pseudocode is:¶
The connection ID used with HKDF
Future versions of QUIC SHOULD generate a new salt value, thus ensuring that the keys are different for each version of QUIC. This prevents a middlebox that recognizes only one version of QUIC from seeing or modifying the contents of packets from future versions.¶
The HKDF
The secrets used for constructing subsequent Initial packets change when a server sends a Retry packet to use the connection ID value selected by the server. The secrets do not change when a client changes the Destination Connection ID it uses in response to an Initial packet from the server.¶
Appendix A contains sample Initial packets.¶
5.3. AEAD Usage
The Authenticated Encryption with Associated Data (AEAD) function (see
[AEAD]) used for QUIC packet protection is the AEAD that is negotiated for
use with the TLS connection. For example, if TLS is using the
TLS
QUIC can use any of the cipher suites defined in [TLS13] with the exception
of TLS
An endpoint MUST NOT reject a ClientHello that offers a cipher suite that it
does not support, or it would be impossible to deploy a new cipher suite. This
also applies to TLS
When constructing packets, the AEAD function is applied prior to applying header protection; see Section 5.4. The unprotected packet header is part of the associated data (A). When processing packets, an endpoint first removes the header protection.¶
The key and IV for the packet are computed as described in Section 5.1. The nonce, N, is formed by combining the packet protection IV with the packet number. The 62 bits of the reconstructed QUIC packet number in network byte order are left-padded with zeros to the size of the IV. The exclusive OR of the padded packet number and the IV forms the AEAD nonce.¶
The associated data, A, for the AEAD is the contents of the QUIC header, starting from the first byte of either the short or long header, up to and including the unprotected packet number.¶
The input plaintext, P, for the AEAD is the payload of the QUIC packet, as described in [QUIC-TRANSPORT].¶
The output ciphertext, C, of the AEAD is transmitted in place of P.¶
Some AEAD functions have limits for how many packets can be encrypted under the same key and IV; see Section 6.6. This might be lower than the packet number limit. An endpoint MUST initiate a key update (Section 6) prior to exceeding any limit set for the AEAD that is in use.¶
5.4. Header Protection
Parts of QUIC packet headers, in particular the Packet Number field, are protected using a key that is derived separately from the packet protection key and IV. The key derived using the "quic hp" label is used to provide confidentiality protection for those fields that are not exposed to on-path elements.¶
This protection applies to the least significant bits of the first byte, plus the Packet Number field. The four least significant bits of the first byte are protected for packets with long headers; the five least significant bits of the first byte are protected for packets with short headers. For both header forms, this covers the reserved bits and the Packet Number Length field; the Key Phase bit is also protected for packets with a short header.¶
The same header protection key is used for the duration of the connection, with the value not changing after a key update (see Section 6). This allows header protection to be used to protect the key phase.¶
This process does not apply to Retry or Version Negotiation packets, which do not contain a protected payload or any of the fields that are protected by this process.¶
5.4.1. Header Protection Application
Header protection is applied after packet protection is applied (see Section 5.3). The ciphertext of the packet is sampled and used as input to an encryption algorithm. The algorithm used depends on the negotiated AEAD.¶
The output of this algorithm is a 5-byte mask that is applied to the protected header fields using exclusive OR. The least significant bits of the first byte of the packet are masked by the least significant bits of the first mask byte, and the packet number is masked with the remaining bytes. Any unused bytes of mask that might result from a shorter packet number encoding are unused.¶
Figure 6 shows a sample algorithm for applying header protection. Removing header protection only differs in the order in which the packet number length (pn_length) is determined (here "^" is used to represent exclusive OR).¶
Specific header protection functions are defined based on the selected cipher suite; see Section 5.4.3 and Section 5.4.4.¶
Figure 7 shows an example long header packet (Initial) and a short header packet (1-RTT). Figure 7 shows the fields in each header that are covered by header protection and the portion of the protected packet payload that is sampled.¶
Before a TLS cipher suite can be used with QUIC, a header protection algorithm
MUST be specified for the AEAD used with that cipher suite. This document
defines algorithms for AEAD
5.4.2. Header Protection Sample
The header protection algorithm uses both the header protection key and a sample of the ciphertext from the packet Payload field.¶
The same number of bytes are always sampled, but an allowance needs to be made for the removal of protection by a receiving endpoint, which will not know the length of the Packet Number field. The sample of ciphertext is taken starting from an offset of 4 bytes after the start of the Packet Number field. That is, in sampling packet ciphertext for header protection, the Packet Number field is assumed to be 4 bytes long (its maximum possible encoded length).¶
An endpoint MUST discard packets that are not long enough to contain a complete sample.¶
To ensure that sufficient data is available for sampling, packets are padded so
that the combined lengths of the encoded packet number and protected payload is
at least 4 bytes longer than the sample required for header protection. The
cipher suites defined in [TLS13] -- other than TLS
The sampled ciphertext can be determined by the following pseudocode:¶
Where the packet number offset of a short header packet can be calculated as:¶
And the packet number offset of a long header packet can be calculated as:¶
For example, for a packet with a short header, an 8-byte connection ID, and
protected with AEAD
Multiple QUIC packets might be included in the same UDP datagram. Each packet is handled separately.¶
5.4.3. AES-Based Header Protection
This section defines the packet protection algorithm for AEAD
This algorithm samples 16 bytes from the packet ciphertext. This value is used as the input to AES-ECB. In pseudocode, the header protection function is defined as:¶
5.4.4. ChaCha20-Based Header Protection
When AEAD
The first 4 bytes of the sampled ciphertext are the block counter. A ChaCha20 implementation could take a 32-bit integer in place of a byte sequence, in which case, the byte sequence is interpreted as a little-endian value.¶
The remaining 12 bytes are used as the nonce. A ChaCha20 implementation might take an array of three 32-bit integers in place of a byte sequence, in which case, the nonce bytes are interpreted as a sequence of 32-bit little-endian integers.¶
The encryption mask is produced by invoking ChaCha20 to protect 5 zero bytes. In pseudocode, the header protection function is defined as:¶
5.5. Receiving Protected Packets
Once an endpoint successfully receives a packet with a given packet number, it MUST discard all packets in the same packet number space with higher packet numbers if they cannot be successfully unprotected with either the same key, or -- if there is a key update -- a subsequent packet protection key; see Section 6. Similarly, a packet that appears to trigger a key update but cannot be unprotected successfully MUST be discarded.¶
Failure to unprotect a packet does not necessarily indicate the existence of a protocol error in a peer or an attack. The truncated packet number encoding used in QUIC can cause packet numbers to be decoded incorrectly if they are delayed significantly.¶
5.6. Use of 0-RTT Keys
If 0-RTT keys are available (see Section 4.6.1), the lack of replay protection means that restrictions on their use are necessary to avoid replay attacks on the protocol.¶
Of the frames defined in [QUIC-TRANSPORT], the STREAM, RESET_STREAM,
STOP_SENDING, and CONNECTION
An application protocol that uses QUIC MUST include a profile that defines acceptable use of 0-RTT; otherwise, 0-RTT can only be used to carry QUIC frames that do not carry application data. For example, a profile for HTTP is described in [HTTP-REPLAY] and used for HTTP/3; see Section 10.9 of [QUIC-HTTP].¶
Though replaying packets might result in additional connection attempts, the effect of processing replayed frames that do not carry application data is limited to changing the state of the affected connection. A TLS handshake cannot be successfully completed using replayed packets.¶
A client MAY wish to apply additional restrictions on what data it sends prior to the completion of the TLS handshake.¶
A client otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that it cannot send certain frames with 0-RTT keys; see Section 12.5 of [QUIC-TRANSPORT].¶
A client that receives an indication that its 0-RTT data has been accepted by a server can send 0-RTT data until it receives all of the server's handshake messages. A client SHOULD stop sending 0-RTT data if it receives an indication that 0-RTT data has been rejected.¶
A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT keys to protect acknowledgments of 0-RTT packets. A client MUST NOT attempt to decrypt 0-RTT packets it receives and instead MUST discard them.¶
Once a client has installed 1-RTT keys, it MUST NOT send any more 0-RTT packets.¶
5.7. Receiving Out-of-Order Protected Packets
Due to reordering and loss, protected packets might be received by an endpoint before the final TLS handshake messages are received. A client will be unable to decrypt 1-RTT packets from the server, whereas a server will be able to decrypt 1-RTT packets from the client. Endpoints in either role MUST NOT decrypt 1-RTT packets from their peer prior to completing the handshake.¶
Even though 1-RTT keys are available to a server after receiving the first handshake messages from a client, it is missing assurances on the client state:¶
Therefore, the server's use of 1-RTT keys before the handshake is complete is limited to sending data. A server MUST NOT process incoming 1-RTT protected packets before the TLS handshake is complete. Because sending acknowledgments indicates that all frames in a packet have been processed, a server cannot send acknowledgments for 1-RTT packets until the TLS handshake is complete. Received packets protected with 1-RTT keys MAY be stored and later decrypted and used once the handshake is complete.¶
The requirement for the server to wait for the client Finished message creates a dependency on that message being delivered. A client can avoid the potential for head-of-line blocking that this implies by sending its 1-RTT packets coalesced with a Handshake packet containing a copy of the CRYPTO frame that carries the Finished message, until one of the Handshake packets is acknowledged. This enables immediate server processing for those packets.¶
A server could receive packets protected with 0-RTT keys prior to receiving a TLS ClientHello. The server MAY retain these packets for later decryption in anticipation of receiving a ClientHello.¶
A client generally receives 1-RTT keys at the same time as the handshake completes. Even if it has 1-RTT secrets, a client MUST NOT process incoming 1-RTT protected packets before the TLS handshake is complete.¶
5.8. Retry Packet Integrity
Retry packets (see Section 17.2.5 of [QUIC-TRANSPORT]) carry a Retry Integrity Tag that provides two properties: it allows the discarding of packets that have accidentally been corrupted by the network, and only an entity that observes an Initial packet can send a valid Retry packet.¶
The Retry Integrity Tag is a 128-bit field that is computed as the output of
AEAD
The secret key and the nonce are values derived by calling HKDF
The Retry Pseudo-Packet is not sent over the wire. It is computed by taking the transmitted Retry packet, removing the Retry Integrity Tag, and prepending the two following fields:¶
- ODCID Length:
-
The ODCID Length field contains the length in bytes of the Original Destination Connection ID field that follows it, encoded as an 8-bit unsigned integer.¶
- Original Destination Connection ID:
-
The Original Destination Connection ID contains the value of the Destination Connection ID from the Initial packet that this Retry is in response to. The length of this field is given in ODCID Length. The presence of this field ensures that a valid Retry packet can only be sent by an entity that observes the Initial packet.¶
6. Key Update
Once the handshake is confirmed (see Section 4.1.2), an endpoint MAY initiate a key update.¶
The Key Phase bit indicates which packet protection keys are used to protect the packet. The Key Phase bit is initially set to 0 for the first set of 1-RTT packets and toggled to signal each subsequent key update.¶
The Key Phase bit allows a recipient to detect a change in keying material without needing to receive the first packet that triggered the change. An endpoint that notices a changed Key Phase bit updates keys and decrypts the packet that contains the changed value.¶
Initiating a key update results in both endpoints updating keys. This differs from TLS where endpoints can update keys independently.¶
This mechanism replaces the key update mechanism of TLS, which relies on
KeyUpdate messages sent using 1-RTT encryption keys. Endpoints MUST NOT send a
TLS KeyUpdate message. Endpoints MUST treat the receipt of a TLS KeyUpdate
message as a connection error of type 0x010a, equivalent to a
fatal TLS alert of unexpected
Figure 9 shows a key update process, where the initial set of keys used (identified with @M) are replaced by updated keys (identified with @N). The value of the Key Phase bit is indicated in brackets [].¶
6.1. Initiating a Key Update
Endpoints maintain separate read and write secrets for packet protection. An endpoint initiates a key update by updating its packet protection write secret and using that to protect new packets. The endpoint creates a new write secret from the existing write secret as performed in Section 7.2 of [TLS13]. This uses the KDF function provided by TLS with a label of "quic ku". The corresponding key and IV are created from that secret as defined in Section 5.1. The header protection key is not updated.¶
For example, to update write keys with TLS 1.3, HKDF
The endpoint toggles the value of the Key Phase bit and uses the updated key and IV to protect all subsequent packets.¶
An endpoint MUST NOT initiate a key update prior to having confirmed the handshake (Section 4.1.2). An endpoint MUST NOT initiate a subsequent key update unless it has received an acknowledgment for a packet that was sent protected with keys from the current key phase. This ensures that keys are available to both peers before another key update can be initiated. This can be implemented by tracking the lowest packet number sent with each key phase and the highest acknowledged packet number in the 1-RTT space: once the latter is higher than or equal to the former, another key update can be initiated.¶
The endpoint that initiates a key update also updates the keys that it uses for receiving packets. These keys will be needed to process packets the peer sends after updating.¶
An endpoint MUST retain old keys until it has successfully unprotected a packet sent using the new keys. An endpoint SHOULD retain old keys for some time after unprotecting a packet sent using the new keys. Discarding old keys too early can cause delayed packets to be discarded. Discarding packets will be interpreted as packet loss by the peer and could adversely affect performance.¶
6.2. Responding to a Key Update
A peer is permitted to initiate a key update after receiving an acknowledgment of a packet in the current key phase. An endpoint detects a key update when processing a packet with a key phase that differs from the value used to protect the last packet it sent. To process this packet, the endpoint uses the next packet protection key and IV. See Section 6.3 for considerations about generating these keys.¶
If a packet is successfully processed using the next key and IV, then the peer has initiated a key update. The endpoint MUST update its send keys to the corresponding key phase in response, as described in Section 6.1. Sending keys MUST be updated before sending an acknowledgment for the packet that was received with updated keys. By acknowledging the packet that triggered the key update in a packet protected with the updated keys, the endpoint signals that the key update is complete.¶
An endpoint can defer sending the packet or acknowledgment according to its
normal packet sending behavior; it is not necessary to immediately generate a
packet in response to a key update. The next packet sent by the endpoint will
use the updated keys. The next packet that contains an acknowledgment will
cause the key update to be completed. If an endpoint detects a second update
before it has sent any packets with updated keys containing an
acknowledgment for the packet that initiated the key update, it indicates that
its peer has updated keys twice without awaiting confirmation. An endpoint MAY
treat such consecutive key updates as a connection error of type
KEY
An endpoint that receives an acknowledgment that is carried in a packet
protected with old keys where any acknowledged packet was protected with newer
keys MAY treat that as a connection error of type KEY
6.3. Timing of Receive Key Generation
Endpoints responding to an apparent key update MUST NOT generate a timing side-channel signal that might indicate that the Key Phase bit was invalid (see Section 9.5). Endpoints can use randomized packet protection keys in place of discarded keys when key updates are not yet permitted. Using randomized keys ensures that attempting to remove packet protection does not result in timing variations, and results in packets with an invalid Key Phase bit being rejected.¶
The process of creating new packet protection keys for receiving packets could reveal that a key update has occurred. An endpoint MAY generate new keys as part of packet processing, but this creates a timing signal that could be used by an attacker to learn when key updates happen and thus leak the value of the Key Phase bit.¶
Endpoints are generally expected to have current and next receive packet protection keys available. For a short period after a key update completes, up to the PTO, endpoints MAY defer generation of the next set of receive packet protection keys. This allows endpoints to retain only two sets of receive keys; see Section 6.5.¶
Once generated, the next set of packet protection keys SHOULD be retained, even if the packet that was received was subsequently discarded. Packets containing apparent key updates are easy to forge, and while the process of key update does not require significant effort, triggering this process could be used by an attacker for DoS.¶
For this reason, endpoints MUST be able to retain two sets of packet protection keys for receiving packets: the current and the next. Retaining the previous keys in addition to these might improve performance, but this is not essential.¶
6.4. Sending with Updated Keys
An endpoint never sends packets that are protected with old keys. Only the current keys are used. Keys used for protecting packets can be discarded immediately after switching to newer keys.¶
Packets with higher packet numbers MUST be protected with either the same or
newer packet protection keys than packets with lower packet numbers. An
endpoint that successfully removes protection with old keys when newer keys were
used for packets with lower packet numbers MUST treat this as a connection error
of type KEY
6.5. Receiving with Different Keys
For receiving packets during a key update, packets protected with older keys might arrive if they were delayed by the network. Retaining old packet protection keys allows these packets to be successfully processed.¶
As packets protected with keys from the next key phase use the same Key Phase value as those protected with keys from the previous key phase, it is necessary to distinguish between the two if packets protected with old keys are to be processed. This can be done using packet numbers. A recovered packet number that is lower than any packet number from the current key phase uses the previous packet protection keys; a recovered packet number that is higher than any packet number from the current key phase requires the use of the next packet protection keys.¶
Some care is necessary to ensure that any process for selecting between previous, current, and next packet protection keys does not expose a timing side channel that might reveal which keys were used to remove packet protection. See Section 9.5 for more information.¶
Alternatively, endpoints can retain only two sets of packet protection keys, swapping previous for next after enough time has passed to allow for reordering in the network. In this case, the Key Phase bit alone can be used to select keys.¶
An endpoint MAY allow a period of approximately the Probe Timeout (PTO; see [QUIC-RECOVERY]) after promoting the next set of receive keys to be current before it creates the subsequent set of packet protection keys. These updated keys MAY replace the previous keys at that time. With the caveat that PTO is a subjective measure -- that is, a peer could have a different view of the RTT -- this time is expected to be long enough that any reordered packets would be declared lost by a peer even if they were acknowledged and short enough to allow a peer to initiate further key updates.¶
Endpoints need to allow for the possibility that a peer might not be able to decrypt packets that initiate a key update during the period when the peer retains old keys. Endpoints SHOULD wait three times the PTO before initiating a key update after receiving an acknowledgment that confirms that the previous key update was received. Failing to allow sufficient time could lead to packets being discarded.¶
An endpoint SHOULD retain old read keys for no more than three times the PTO after having received a packet protected using the new keys. After this period, old read keys and their corresponding secrets SHOULD be discarded.¶
6.6. Limits on AEAD Usage
This document sets usage limits for AEAD algorithms to ensure that overuse does
not give an adversary a disproportionat
The usage limits defined in TLS 1.3 exist for protection against attacks on confidentiality and apply to successful applications of AEAD protection. The integrity protections in authenticated encryption also depend on limiting the number of attempts to forge packets. TLS achieves this by closing connections after any record fails an authentication check. In comparison, QUIC ignores any packet that cannot be authenticated, allowing multiple forgery attempts.¶
QUIC accounts for AEAD confidentiality and integrity limits separately. The confidentiality limit applies to the number of packets encrypted with a given key. The integrity limit applies to the number of packets decrypted within a given connection. Details on enforcing these limits for each AEAD algorithm follow below.¶
Endpoints MUST count the number of encrypted packets for each set of keys. If
the total number of encrypted packets with the same key exceeds the
confidentiality limit for the selected AEAD, the endpoint MUST stop using those
keys. Endpoints MUST initiate a key update before sending more protected packets
than the confidentiality limit for the selected AEAD permits. If a key update
is not possible or integrity limits are reached, the endpoint MUST stop using
the connection and only send stateless resets in response to receiving packets.
It is RECOMMENDED that endpoints immediately close the connection with a
connection error of type AEAD
For AEAD
In addition to counting packets sent, endpoints MUST count the number of
received packets that fail authentication during the lifetime of a connection.
If the total number of received packets that fail authentication within the
connection, across all keys, exceeds the integrity limit for the selected AEAD,
the endpoint MUST immediately close the connection with a connection error of
type AEAD
For AEAD
Endpoints that limit the size of packets MAY use higher confidentiality and integrity limits; see Appendix B for details.¶
Future analyses and specifications MAY relax confidentiality or integrity limits for an AEAD.¶
Any TLS cipher suite that is specified for use with QUIC MUST define limits on the use of the associated AEAD function that preserves margins for confidentiality and integrity. That is, limits MUST be specified for the number of packets that can be authenticated and for the number of packets that can fail authentication. Providing a reference to any analysis upon which values are based -- and any assumptions used in that analysis -- allows limits to be adapted to varying usage conditions.¶
6.7. Key Update Error Code
The KEY
7. Security of Initial Messages
Initial packets are not protected with a secret key, so they are subject to potential tampering by an attacker. QUIC provides protection against attackers that cannot read packets but does not attempt to provide additional protection against attacks where the attacker can observe and inject packets. Some forms of tampering -- such as modifying the TLS messages themselves -- are detectable, but some -- such as modifying ACKs -- are not.¶
For example, an attacker could inject a packet containing an ACK frame to make it appear that a packet had not been received or to create a false impression of the state of the connection (e.g., by modifying the ACK Delay). Note that such a packet could cause a legitimate packet to be dropped as a duplicate. Implementations SHOULD use caution in relying on any data that is contained in Initial packets that is not otherwise authenticated.¶
It is also possible for the attacker to tamper with data that is carried in Handshake packets, but because that sort of tampering requires modifying TLS handshake messages, any such tampering will cause the TLS handshake to fail.¶
8. QUIC-Specific Adjustments to the TLS Handshake
Certain aspects of the TLS handshake are different when used with QUIC.¶
QUIC also requires additional features from TLS. In addition to negotiation of cryptographic parameters, the TLS handshake carries and authenticates values for QUIC transport parameters.¶
8.1. Protocol Negotiation
QUIC requires that the cryptographic handshake provide authenticated protocol
negotiation. TLS uses Application
When using ALPN, endpoints MUST immediately close a connection (see Section 10.2 of [QUIC-TRANSPORT]) with a no
An application protocol MAY restrict the QUIC versions that it can operate over.
Servers MUST select an application protocol compatible with the QUIC version
that the client has selected. The server MUST treat the inability to select a
compatible application protocol as a connection error of type 0x0178
8.2. QUIC Transport Parameters Extension
QUIC transport parameters are carried in a TLS extension. Different versions of QUIC might define a different method for negotiating transport configuration.¶
Including transport parameters in the TLS handshake provides integrity protection for these values.¶
The extension_data field of the quic
The quic
Transport parameters become available prior to the completion of the handshake. A server might use these values earlier than handshake completion. However, the value of transport parameters is not authenticated until the handshake completes, so any use of these parameters cannot depend on their authenticity. Any tampering with transport parameters will cause the handshake to fail.¶
Endpoints MUST NOT send this extension in a TLS connection that does not use
QUIC (such as the use of TLS with TCP defined in [TLS13]). A fatal
unsupported
Negotiating the quic
8.3. Removing the EndOfEarlyData Message
The TLS EndOfEarlyData message is not used with QUIC. QUIC does not rely on this message to mark the end of 0-RTT data or to signal the change to Handshake keys.¶
Clients MUST NOT send the EndOfEarlyData message. A server MUST treat receipt
of a CRYPTO frame in a 0-RTT packet as a connection error of type
PROTOCOL
As a result, EndOfEarlyData does not appear in the TLS handshake transcript.¶
8.4. Prohibit TLS Middlebox Compatibility Mode
Appendix D.4 of [TLS13] describes an alteration to the TLS 1.3 handshake as
a workaround for bugs in some middleboxes. The TLS 1.3 middlebox compatibility
mode involves setting the legacy
This mode has no use in QUIC as it only applies to middleboxes that interfere
with TLS over TCP. QUIC also provides no means to carry a change
9. Security Considerations
All of the security considerations that apply to TLS also apply to the use of TLS in QUIC. Reading all of [TLS13] and its appendices is the best way to gain an understanding of the security properties of QUIC.¶
This section summarizes some of the more important security aspects specific to
the TLS integration, though there are many security
9.1. Session Linkability
Use of TLS session tickets allows servers and possibly other entities to correlate connections made by the same client; see Section 4.5 for details.¶
9.2. Replay Attacks with 0-RTT
As described in Section 8 of [TLS13], use of TLS early data comes with an exposure to replay attack. The use of 0-RTT in QUIC is similarly vulnerable to replay attack.¶
Endpoints MUST implement and use the replay protections described in [TLS13], however it is recognized that these protections are imperfect. Therefore, additional consideration of the risk of replay is needed.¶
QUIC is not vulnerable to replay attack, except via the application protocol information it might carry. The management of QUIC protocol state based on the frame types defined in [QUIC-TRANSPORT] is not vulnerable to replay. Processing of QUIC frames is idempotent and cannot result in invalid connection states if frames are replayed, reordered, or lost. QUIC connections do not produce effects that last beyond the lifetime of the connection, except for those produced by the application protocol that QUIC serves.¶
TLS session tickets and address validation tokens are used to carry QUIC configuration information between connections, specifically, to enable a server to efficiently recover state that is used in connection establishment and address validation. These MUST NOT be used to communicate application semantics between endpoints; clients MUST treat them as opaque values. The potential for reuse of these tokens means that they require stronger protections against replay.¶
A server that accepts 0-RTT on a connection incurs a higher cost than accepting a connection without 0-RTT. This includes higher processing and computation costs. Servers need to consider the probability of replay and all associated costs when accepting 0-RTT.¶
Ultimately, the responsibility for managing the risks of replay attacks with 0-RTT lies with an application protocol. An application protocol that uses QUIC MUST describe how the protocol uses 0-RTT and the measures that are employed to protect against replay attack. An analysis of replay risk needs to consider all QUIC protocol features that carry application semantics.¶
Disabling 0-RTT entirely is the most effective defense against replay attack.¶
QUIC extensions MUST either describe how replay attacks affect their operation or prohibit the use of the extension in 0-RTT. Application protocols MUST either prohibit the use of extensions that carry application semantics in 0-RTT or provide replay mitigation strategies.¶
9.3. Packet Reflection Attack Mitigation
A small ClientHello that results in a large block of handshake messages from a server can be used in packet reflection attacks to amplify the traffic generated by an attacker.¶
QUIC includes three defenses against this attack. First, the packet containing a ClientHello MUST be padded to a minimum size. Second, if responding to an unverified source address, the server is forbidden to send more than three times as many bytes as the number of bytes it has received (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because acknowledgments of Handshake packets are authenticated, a blind attacker cannot forge them. Put together, these defenses limit the level of amplification.¶
9.4. Header Protection Analysis
[NAN] analyzes authenticated encryption
algorithms that provide nonce privacy, referred to as "Hide Nonce" (HN)
transforms. The general header protection construction in this document is
one of those algorithms (HN1). Header protection is applied after the packet
protection AEAD, sampling a set of bytes (sample) from the AEAD output and
encrypting the header field using a pseudorandom function (PRF) as follows:¶
The header protection variants in this document use a pseudorandom permutation (PRP) in place of a generic PRF. However, since all PRPs are also PRFs [IMC], these variants do not deviate from the HN1 construction.¶
As hp_key is distinct from the packet protection key, it follows that header
protection achieves AE2 security as defined in [NAN] and therefore guarantees
privacy of field, the protected packet header. Future header protection
variants based on this construction MUST use a PRF to ensure equivalent
security guarantees.¶
Use of the same key and ciphertext sample more than once risks compromising header protection. Protecting two different headers with the same key and ciphertext sample reveals the exclusive OR of the protected fields. Assuming that the AEAD acts as a PRF, if L bits are sampled, the odds of two ciphertext samples being identical approach 2-L/2, that is, the birthday bound. For the algorithms described in this document, that probability is one in 264.¶
To prevent an attacker from modifying packet headers, the header is transitively authenticated using packet protection; the entire packet header is part of the authenticated additional data. Protected fields that are falsified or modified can only be detected once the packet protection is removed.¶
9.5. Header Protection Timing Side Channels
An attacker could guess values for packet numbers or Key Phase and have an endpoint confirm guesses through timing side channels. Similarly, guesses for the packet number length can be tried and exposed. If the recipient of a packet discards packets with duplicate packet numbers without attempting to remove packet protection, they could reveal through timing side channels that the packet number matches a received packet. For authentication to be free from side channels, the entire process of header protection removal, packet number recovery, and packet protection removal MUST be applied together without timing and other side channels.¶
For the sending of packets, construction and protection of packet payloads and packet numbers MUST be free from side channels that would reveal the packet number or its encoded size.¶
During a key update, the time taken to generate new keys could reveal through timing side channels that a key update has occurred. Alternatively, where an attacker injects packets, this side channel could reveal the value of the Key Phase on injected packets. After receiving a key update, an endpoint SHOULD generate and save the next set of receive packet protection keys, as described in Section 6.3. By generating new keys before a key update is received, receipt of packets will not create timing signals that leak the value of the Key Phase.¶
This depends on not doing this key generation during packet processing, and it can require that endpoints maintain three sets of packet protection keys for receiving: for the previous key phase, for the current key phase, and for the next key phase. Endpoints can instead choose to defer generation of the next receive packet protection keys until they discard old keys so that only two sets of receive keys need to be retained at any point in time.¶
9.6. Key Diversity
In using TLS, the central key schedule of TLS is used. As a result of the TLS
handshake messages being integrated into the calculation of secrets, the
inclusion of the QUIC transport parameters extension ensures that the handshake
and 1-RTT keys are not the same as those that might be produced by a server
running TLS over TCP. To avoid the possibility of cross-protocol key
synchronization
The QUIC packet protection keys and IVs are derived using a different label than the equivalent keys in TLS.¶
To preserve this separation, a new version of QUIC SHOULD define new labels for
key derivation for packet protection key and IV, plus the header protection
keys. This version of QUIC uses the string "quic". Other versions can use a
version
The initial secrets use a key that is specific to the negotiated QUIC version. New QUIC versions SHOULD define a new salt value used in calculating initial secrets.¶
9.7. Randomness
QUIC depends on endpoints being able to generate secure random numbers, both directly for protocol values such as the connection ID, and transitively via TLS. See [RFC4086] for guidance on secure random number generation.¶
10. IANA Considerations
IANA has registered a codepoint of 57 (or 0x39) for the
quic
The Recommended column for this extension is marked Yes. The TLS 1.3 Column
includes CH (ClientHello) and EE
11. References
11.1. Normative References
- [AEAD]
-
McGrew, D., "An Interface and Algorithms for Authenticated Encryption", RFC 5116, DOI 10
.17487 , , <https:///RFC5116 www >..rfc -editor .org /info /rfc5116 - [AES]
-
"Advanced encryption standard (AES)", National Institute of Standards and Technology report, DOI 10
.6028 , , <https:///nist .fips .197 doi >..org /10 .6028 /nist .fips .197 - [ALPN]
-
Friedl, S., Popov, A., Langley, A., and E. Stephan, "Transport Layer Security (TLS) Application
-Layer , RFC 7301, DOI 10Protocol Negotiation Extension" .17487 , , <https:///RFC7301 www >..rfc -editor .org /info /rfc7301 - [CHACHA]
-
Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF Protocols", RFC 8439, DOI 10
.17487 , , <https:///RFC8439 www >..rfc -editor .org /info /rfc8439 - [HKDF]
-
Krawczyk, H. and P. Eronen, "HMAC-based Extract
-and , RFC 5869, DOI 10-Expand Key Derivation Function (HKDF)" .17487 , , <https:///RFC5869 www >..rfc -editor .org /info /rfc5869 - [QUIC-RECOVERY]
-
Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection and Congestion Control", RFC 9002, DOI 10
.17487 , , <https:///RFC9002 www >..rfc -editor .org /info /rfc9002 - [QUIC-TRANSPORT]
-
Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based Multiplexed and Secure Transport", RFC 9000, DOI 10
.17487 , , <https:///RFC9000 www >..rfc -editor .org /info /rfc9000 - [RFC2119]
-
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10
.17487 , , <https:///RFC2119 www >..rfc -editor .org /info /rfc2119 - [RFC4086]
-
Eastlake 3rd, D., Schiller, J., and S. Crocker, "Randomness Requirements for Security", BCP 106, RFC 4086, DOI 10
.17487 , , <https:///RFC4086 www >..rfc -editor .org /info /rfc4086 - [RFC8174]
-
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10
.17487 , , <https:///RFC8174 www >..rfc -editor .org /info /rfc8174 - [SHA]
-
Dang, Q., "Secure Hash Standard", National Institute of Standards and Technology report, DOI 10
.6028 , , <https:///nist .fips .180 -4 doi >..org /10 .6028 /nist .fips .180 -4 - [TLS-REGISTRIES]
-
Salowey, J. and S. Turner, "IANA Registry Updates for TLS and DTLS", RFC 8447, DOI 10
.17487 , , <https:///RFC8447 www >..rfc -editor .org /info /rfc8447 - [TLS13]
-
Rescorla, E., "The Transport Layer Security (TLS) Protocol Version 1.3", RFC 8446, DOI 10
.17487 , , <https:///RFC8446 www >..rfc -editor .org /info /rfc8446
11.2. Informative References
- [AEBounds]
-
Luykx, A. and K. Paterson, "Limits on Authenticated Encryption Use in TLS", , <https://
www >..isg .rhul .ac .uk /~kp /TLS -AEbounds .pdf - [ASCII]
-
Cerf, V., "ASCII format for network interchange", STD 80, RFC 20, DOI 10
.17487 , , <https:///RFC0020 www >..rfc -editor .org /info /rfc20 - [CCM-ANALYSIS]
-
Jonsson, J., "On the Security of CTR + CBC-MAC", Selected Areas in Cryptography, SAC 2002, Lecture Notes in Computer Science, vol 2595, pp. 76-93, DOI 10
.1007 , , <https:///3 -540 -36492 -7 _7 doi >..org /10 .1007 /3 -540 -36492 -7 _7 - [COMPRESS]
-
Ghedini, A. and V. Vasiliev, "TLS Certificate Compression", RFC 8879, DOI 10
.17487 , , <https:///RFC8879 www >..rfc -editor .org /info /rfc8879 - [GCM-MU]
-
Hoang, V., Tessaro, S., and A. Thiruvengadam, "The Multi-user Security of GCM, Revisited: Tight Bounds for Nonce Randomization", CCS '18: Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security, pp. 1429-1440, DOI 10
.1145 , , <https:///3243734 .3243816 doi >..org /10 .1145 /3243734 .3243816 - [HTTP-REPLAY]
-
Thomson, M., Nottingham, M., and W. Tarreau, "Using Early Data in HTTP", RFC 8470, DOI 10
.17487 , , <https:///RFC8470 www >..rfc -editor .org /info /rfc8470 - [HTTP2-TLS13]
-
Benjamin, D., "Using TLS 1.3 with HTTP/2", RFC 8740, DOI 10
.17487 , , <https:///RFC8740 www >..rfc -editor .org /info /rfc8740 - [IMC]
- Katz, J. and Y. Lindell, "Introduction to Modern Cryptography, Second Edition", ISBN 978-1466570269, .
- [NAN]
-
Bellare, M., Ng, R., and B. Tackmann, "Nonces Are Noticed: AEAD Revisited", Advances in Cryptology - CRYPTO 2019, Lecture Notes in Computer Science, vol 11692, pp. 235-265, DOI 10
.1007 , , <https:///978 -3 -030 -26948 -7 _9 doi >..org /10 .1007 /978 -3 -030 -26948 -7 _9 - [QUIC-HTTP]
-
Bishop, M., Ed., "Hypertext Transfer Protocol Version 3 (HTTP/3)", Work in Progress, Internet-Draft, draft
-ietf , , <https://-quic -http -34 tools >..ietf .org /html /draft -ietf -quic -http -34 - [RFC2818]
-
Rescorla, E., "HTTP Over TLS", RFC 2818, DOI 10
.17487 , , <https:///RFC2818 www >..rfc -editor .org /info /rfc2818 - [RFC5280]
-
Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, "Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile", RFC 5280, DOI 10
.17487 , , <https:///RFC5280 www >..rfc -editor .org /info /rfc5280 - [ROBUST]
-
Fischlin, M., Günther, F., and C. Janson, "Robust Channels: Handling Unreliable Networks in the Record Layers of QUIC and DTLS 1.3", , <https://
eprint >..iacr .org /2020 /718
Appendix A. Sample Packet Protection
This section shows examples of packet protection so that implementations can be
verified incrementally. Samples of Initial packets from both client and server
plus a Retry packet are defined. These packets use an 8-byte client-chosen
Destination Connection ID of 0x8394c8f03e515
A.1. Keys
The labels generated during the execution of the HKDF
- client in:
-
00200f746c733133
20636c69656e7420 696e00 ¶ - server in:
-
00200f746c733133
2073657276657220 696e00 ¶ - quic key:
-
00100e746c733133
2071756963206b65 7900 ¶ - quic iv:
-
000c0d746c733133
2071756963206976 00 ¶ - quic hp:
-
00100d746c733133
2071756963206870 00 ¶
The initial secret is common:¶
The secrets for protecting client packets are:¶
The secrets for protecting server packets are:¶
A.2. Client Initial
The client sends an Initial packet. The unprotected payload of this packet contains the following CRYPTO frame, plus enough PADDING frames to make a 1162-byte payload:¶
The unprotected header indicates a length of 1182 bytes: the 4-byte packet number, 1162 bytes of frames, and the 16-byte authentication tag. The header includes the connection ID and a packet number of 2:¶
Protecting the payload produces output that is sampled for header protection. Because the header uses a 4-byte packet number encoding, the first 16 bytes of the protected payload is sampled and then applied to the header as follows:¶
The resulting protected packet is:¶
A.3. Server Initial
The server sends the following payload in response, including an ACK frame, a CRYPTO frame, and no PADDING frames:¶
The header from the server includes a new connection ID and a 2-byte packet number encoding for a packet number of 1:¶
As a result, after protection, the header protection sample is taken starting from the third protected byte:¶
The final protected packet is then:¶
A.4. Retry
This shows a Retry packet that might be sent in response to the Initial packet
in Appendix A.2. The integrity check includes the client-chosen
connection ID value of 0x8394c8f03e515
A.5. ChaCha20-Poly1305 Short Header Packet
This example shows some of the steps required to protect a packet with
a short header. This example uses AEAD
In this example, TLS produces an application write secret from which a server
uses HKDF
The following shows the steps involved in protecting a minimal packet with an empty Destination Connection ID. This packet contains a single PING frame (that is, a payload of just 0x01) and has a packet number of 654360564. In this example, using a packet number of length 3 (that is, 49140 is encoded) avoids having to pad the payload of the packet; PADDING frames would be needed if the packet number is encoded on fewer bytes.¶
The resulting ciphertext is the minimum size possible. One byte is skipped to produce the sample for header protection.¶
The protected packet is the smallest possible packet size of 21 bytes.¶
Appendix B. AEAD Algorithm Analysis
This section documents analyses used in deriving AEAD algorithm limits for
AEAD
- t:
-
The size of the authentication tag in bits. For these ciphers, t is 128.¶
- n:
-
The size of the block function in bits. For these ciphers, n is 128.¶
- k:
-
The size of the key in bits. This is 128 for AEAD
_AES _128 _GCM and AEAD _AES _128 _CCM; 256 for AEAD _AES _256 _GCM . ¶ - l:
-
The number of blocks in each packet (see below).¶
- q:
-
The number of genuine packets created and protected by endpoints. This value is the bound on the number of packets that can be protected before updating keys.¶
- v:
-
The number of forged packets that endpoints will accept. This value is the bound on the number of forged packets that an endpoint can reject before updating keys.¶
- o:
-
The amount of offline ideal cipher queries made by an adversary.¶
The analyses that follow rely on a count of the number of block operations involved in producing each message. This analysis is performed for packets of size up to 211 (l = 27) and 216 (l = 212). A size of 211 is expected to be a limit that matches common deployment patterns, whereas the 216 is the maximum possible size of a QUIC packet. Only endpoints that strictly limit packet size can use the larger confidentiality and integrity limits that are derived using the smaller packet size.¶
For AEAD
For AEAD2l = 28 for packets that are limited to
211 bytes, or 2l = 213 otherwise). This
simplification is based on the packet containing all of the associated data and
ciphertext. This results in a one to three block overestimation of the number of
operations per packet.¶
B.1. Analysis of AEAD_AES_128_GCM and AEAD_AES_256_GCM Usage Limits
[GCM-MU] specifies concrete bounds for AEAD
The bounds in [GCM-MU] are tighter and more complete than those used in [AEBounds], which allows for larger limits than those described in [TLS13].¶
B.1.1. Confidentiality Limit
For confidentiality
For a target advantage of 2-57, this results in the relation:¶
Thus, endpoints that do not send packets larger than 211 bytes cannot protect more than 228 packets in a single connection without causing an attacker to gain a more significant advantage than the target of 2-57. The limit for endpoints that allow for the packet size to be as large as 216 is instead 223.¶
B.1.2. Integrity Limit
For integrity, Theorem (4.3) in [GCM-MU] establishes that an attacker gains an advantage in successfully forging a packet of no more than the following:¶
The goal is to limit this advantage to 2-57. For AEAD
Endpoints that do not attempt to remove protection from packets larger than 211 bytes can attempt to remove protection from at most 257 packets. Endpoints that do not restrict the size of processed packets can attempt to remove protection from at most 252 packets.¶
For AEAD
This is substantially larger than the limit for AEAD
B.2. Analysis of AEAD_AES_128_CCM Usage Limits
TLS [TLS13] and [AEBounds] do not specify limits on usage
for AEAD
[CCM-ANALYSIS] is used as the basis of this analysis. The results of that analysis are used to derive usage limits that are based on those chosen in [TLS13].¶
For confidentiality
The integrity limit in Theorem 1 in [CCM-ANALYSIS] provides an attacker a strictly higher advantage for the same number of messages. As the targets for the confidentiality advantage and the integrity advantage are the same, only Theorem 1 needs to be considered.¶
Theorem 1 establishes that an attacker gains an advantage over an ideal PRP of no more than the following:¶
As t and n are both 128, the first term is negligible relative to the
second, so that term can be removed without a significant effect on the result.¶
This produces a relation that combines both encryption and decryption attempts with the same limit as that produced by the theorem for confidentiality alone. For a target advantage of 2-57, this results in the following:¶
By setting q = v, values for both confidentiality and integrity limits can be
produced. Endpoints that limit packets to 211 bytes therefore have
both confidentiality and integrity limits of 226.5 packets. Endpoints
that do not restrict packet size have a limit of 221.5.¶
Contributors
The IETF QUIC Working Group received an enormous amount of support from many people. The following people provided substantive contributions to this document:¶