<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.2.9 -->
<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc docmapping="yes"?>
<?rfc-ext html-pretty-print="prettyprint https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"?>
<rfc xmlns:x="http://purl.org/net/xml2rfc/ext"
     category="std"
     docName="draft-ietf-quic-invariants-07"
     ipr="trust200902"
     submissionType="IETF">
   <x:feedback template="mailto:quic@ietf.org?subject={docname},%20%22{section}%22\&amp;amp;body=%3c{ref}%3e:"/>
   <front>
      <title abbrev="QUIC Invariants">Version-Independent Properties of QUIC</title>
      <author fullname="Martin Thomson" initials="M." surname="Thomson">
         <organization>Mozilla</organization>
         <address>
            <email>mt@lowentropy.net</email>
         </address>
      </author>
      <date year="2019" month="9" day="12"/>
      <area>Transport</area>
      <workgroup>QUIC</workgroup>
      <abstract>
         <t>This document defines the properties of the QUIC transport protocol that are expected to remain unchanged over time as new versions of the protocol are developed.</t>
      </abstract>
      <note title="Note to Readers">
         <t>Discussion of this draft takes place on the QUIC working group mailing list (quic@ietf.org), which is archived at <eref target="https://mailarchive.ietf.org/arch/search/?email_list=quic">https://mailarchive.ietf.org/arch/search/?email_list=quic</eref>.</t>
         <t>Working Group information can be found at <eref target="https://github.com/quicwg">https://github.com/quicwg</eref>; source code and issues list for this draft can be found at <eref target="https://github.com/quicwg/base-drafts/labels/-invariants">https://github.com/quicwg/base-drafts/labels/-invariants</eref>.</t>
      </note>
   </front>
   <middle>
      <section anchor="introduction" title="Introduction">
         <t>In addition to providing secure, multiplexed transport, QUIC <xref target="QUIC-TRANSPORT"/> includes the ability to negotiate a version. This allows the protocol to change over time in response to new requirements. Many characteristics of the protocol will change between versions.</t>
         <t>This document describes the subset of QUIC that is intended to remain stable as new versions are developed and deployed. All of these invariants are IP-version-independent.</t>
         <t>The primary goal of this document is to ensure that it is possible to deploy new versions of QUIC. By documenting the properties that can’t change, this document aims to preserve the ability to change any other aspect of the protocol. Thus, unless specifically described in this document, any aspect of the protocol can change between different versions.</t>
         <t>
            <xref target="bad-assumptions"/> is a non-exhaustive list of some incorrect assumptions that might be made based on knowledge of QUIC version 1; these do not apply to every version of QUIC.</t>
      </section>
      <section anchor="conventions-and-definitions"
               title="Conventions and Definitions">
         <t>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 <xref target="RFC2119"/>
            <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
         <t>This document uses terms and notational conventions from <xref target="QUIC-TRANSPORT"/>.</t>
      </section>
      <section anchor="an-extremely-abstract-description-of-quic"
               title="An Extremely Abstract Description of QUIC">
         <t>QUIC is a connection-oriented protocol between two endpoints. Those endpoints exchange UDP datagrams. These UDP datagrams contain QUIC packets. QUIC endpoints use QUIC packets to establish a QUIC connection, which is shared protocol state between those endpoints.</t>
      </section>
      <section anchor="quic-packet-headers" title="QUIC Packet Headers">
         <t>A QUIC packet is the content of the UDP datagrams exchanged by QUIC endpoints. This document describes the contents of those datagrams.</t>
         <t>QUIC defines two types of packet header: long and short. Packets with long headers are identified by the most significant bit of the first byte being set; packets with a short header have that bit cleared.</t>
         <t>Aside from the values described here, the payload of QUIC packets is version-specific and of arbitrary length.</t>
         <section anchor="long-header" title="Long Header">
            <t>Long headers take the form described in <xref target="fig-long"/>. Bits that have version-specific semantics are marked with an X.</t>
            <figure anchor="fig-long" title="QUIC Long Header">
               <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+
|1|X X X X X X X|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Version (32)                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| DCID Len (8)  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               Destination Connection ID (0..2040)           ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SCID Len (8)  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Source Connection ID (0..2040)              ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X  ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
            </figure>
            <t>A QUIC packet with a long header has the high bit of the first byte set to 1. All other bits in that byte are version specific.</t>
            <t>The next four bytes include a 32-bit Version field (see <xref target="version"/>).</t>
            <t>The next byte contains the length in bytes of the Destination Connection ID (see <xref target="connection-id"/>) field that follows it. This length is encoded as an 8-bit unsigned integer. The Destination Connection ID field follows the DCID Len field and is between 0 and 255 bytes in length.</t>
            <t>The next byte contains the length in bytes of the Source Connection ID field that follows it. This length is encoded as a 8-bit unsigned integer. The Source Connection ID field follows the SCID Len field and is between 0 and 255 bytes in length.</t>
            <t>The remainder of the packet contains version-specific content.</t>
         </section>
         <section anchor="short-header" title="Short Header">
            <t>Short headers take the form described in <xref target="fig-short"/>. Bits that have version-specific semantics are marked with an X.</t>
            <figure anchor="fig-short" title="QUIC Short Header">
               <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+
|0|X X X X X X X|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Destination Connection ID (*)               ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X  ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
            </figure>
            <t>A QUIC packet with a short header has the high bit of the first byte set to 0.</t>
            <t>A QUIC packet with a short header includes a Destination Connection ID immediately following the first byte. The short header does not include the Connection ID Lengths, Source Connection ID, or Version fields. The length of the Destination Connection ID is not specified in packets with a short header and is not constrained by this specification.</t>
            <t>The remainder of the packet has version-specific semantics.</t>
         </section>
         <section anchor="connection-id" title="Connection ID">
            <t>A connection ID is an opaque field of arbitrary length.</t>
            <t>The primary function of a connection ID is to ensure that changes in addressing at lower protocol layers (UDP, IP, and below) don’t cause packets for a QUIC connection to be delivered to the wrong endpoint. The connection ID is used by endpoints and the intermediaries that support them to ensure that each QUIC packet can be delivered to the correct instance of an endpoint. At the endpoint, the connection ID is used to identify which QUIC connection the packet is intended for.</t>
            <t>The connection ID is chosen by each endpoint using version-specific methods. Packets for the same QUIC connection might use different connection ID values.</t>
         </section>
         <section anchor="version" title="Version">
            <t>QUIC versions are identified with a 32-bit integer, encoded in network byte order. Version 0 is reserved for version negotiation (see <xref target="version-negotiation"/>). All other version numbers are potentially valid.</t>
            <t>The properties described in this document apply to all versions of QUIC. A protocol that does not conform to the properties described in this document is not QUIC. Future documents might describe additional properties which apply to a specific QUIC version, or to a range of QUIC versions.</t>
         </section>
      </section>
      <section anchor="version-negotiation" title="Version Negotiation">
         <t>A QUIC endpoint that receives a packet with a long header and a version it either does not understand or does not support might send a Version Negotiation packet in response. Packets with a short header do not trigger version negotiation.</t>
         <t>A Version Negotiation packet sets the high bit of the first byte, and thus it conforms with the format of a packet with a long header as defined in <xref target="long-header"/>. A Version Negotiation packet is identifiable as such by the Version field, which is set to 0x00000000.</t>
         <figure anchor="version-negotiation-format" title="Version Negotiation Packet">
            <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+
|1|X X X X X X X|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Version (32) = 0                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| DCID Len (8)  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               Destination Connection ID (0..2040)           ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SCID Len (8)  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Source Connection ID (0..2040)              ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Supported Version 1 (32)                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   [Supported Version 2 (32)]                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                               ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   [Supported Version N (32)]                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
         </figure>
         <t>The Version Negotiation packet contains a list of Supported Version fields, each identifying a version that the endpoint sending the packet supports. The Supported Version fields follow the Version field. A Version Negotiation packet contains no other fields. An endpoint MUST ignore a packet that contains no Supported Version fields, or a truncated Supported Version.</t>
         <t>Version Negotiation packets do not use integrity or confidentiality protection. A specific QUIC version might authenticate the packet as part of its connection establishment process.</t>
         <t>An endpoint MUST include the value from the Source Connection ID field of the packet it receives in the Destination Connection ID field. The value for Source Connection ID MUST be copied from the Destination Connection ID of the received packet, which is initially randomly selected by a client. Echoing both connection IDs gives clients some assurance that the server received the packet and that the Version Negotiation packet was not generated by an off-path attacker.</t>
         <t>An endpoint that receives a Version Negotiation packet might change the version that it decides to use for subsequent packets. The conditions under which an endpoint changes QUIC version will depend on the version of QUIC that it chooses.</t>
         <t>See <xref target="QUIC-TRANSPORT"/> for a more thorough description of how an endpoint that supports QUIC version 1 generates and consumes a Version Negotiation packet.</t>
      </section>
      <section anchor="security-and-privacy-considerations"
               title="Security and Privacy Considerations">
         <t>It is possible that middleboxes could use traits of a specific version of QUIC and assume that when other versions of QUIC exhibit similar traits the same underlying semantic is being expressed. There are potentially many such traits (see <xref target="bad-assumptions"/>). Some effort has been made to either eliminate or obscure some observable traits in QUIC version 1, but many of these remain. Other QUIC versions might make different design decisions and so exhibit different traits.</t>
         <t>The QUIC version number does not appear in all QUIC packets, which means that reliably extracting information from a flow based on version-specific traits requires that middleboxes retain state for every connection ID they see.</t>
         <t>The Version Negotiation packet described in this document is not integrity-protected; it only has modest protection against insertion by off-path attackers. QUIC versions MUST define a mechanism that authenticates the values it contains.</t>
      </section>
      <section anchor="iana-considerations" title="IANA Considerations">
         <t>This document makes no request of IANA.</t>
      </section>
   </middle>
   <back>
      <references title="Normative References">
         <reference anchor="QUIC-TRANSPORT">
            <front>
               <title>QUIC: A UDP-Based Multiplexed and Secure Transport</title>
               <author fullname="Jana Iyengar"
                       initials="J."
                       role="editor"
                       surname="Iyengar">
                  <organization>Google</organization>
               </author>
               <author fullname="Martin Thomson"
                       initials="M."
                       role="editor"
                       surname="Thomson">
                  <organization>Mozilla</organization>
               </author>
               <date/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-quic-transport-23"/>
            <x:source basename="draft-ietf-quic-transport-23"
                      href="draft-ietf-quic-transport-23.xml"/>
         </reference>
         <reference anchor="RFC2119">
            <front>
               <title>Key words for use in RFCs to Indicate Requirement Levels</title>
               <author fullname="S. Bradner" initials="S." surname="Bradner"/>
               <date month="March" year="1997"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="2119"/>
            <seriesInfo name="DOI" value="10.17487/RFC2119"/>
         </reference>
         <reference anchor="RFC8174">
            <front>
               <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
               <author fullname="B. Leiba" initials="B." surname="Leiba"/>
               <date month="May" year="2017"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="8174"/>
            <seriesInfo name="DOI" value="10.17487/RFC8174"/>
         </reference>
      </references>
      <references title="Informative References">
         <reference anchor="QUIC-TLS">
            <front>
               <title>Using Transport Layer Security (TLS) to Secure QUIC</title>
               <author fullname="Martin Thomson"
                       initials="M."
                       role="editor"
                       surname="Thomson">
                  <organization>Mozilla</organization>
               </author>
               <author fullname="Sean Turner"
                       initials="S."
                       role="editor"
                       surname="Turner">
                  <organization>sn3rd</organization>
               </author>
               <date/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-quic-tls-23"/>
            <x:source basename="draft-ietf-quic-tls-23"
                      href="draft-ietf-quic-tls-23.xml"/>
         </reference>
         <reference anchor="RFC5116">
            <front>
               <title>An Interface and Algorithms for Authenticated Encryption</title>
               <author fullname="D. McGrew" initials="D." surname="McGrew"/>
               <date month="January" year="2008"/>
            </front>
            <seriesInfo name="RFC" value="5116"/>
            <seriesInfo name="DOI" value="10.17487/RFC5116"/>
         </reference>
      </references>
      <section anchor="bad-assumptions" title="Incorrect Assumptions">
         <t>There are several traits of QUIC version 1 <xref target="QUIC-TRANSPORT"/> that are not protected from observation, but are nonetheless considered to be changeable when a new version is deployed.</t>
         <t>This section lists a sampling of incorrect assumptions that might be made based on knowledge of QUIC version 1. Some of these statements are not even true for QUIC version 1. This is not an exhaustive list, it is intended to be illustrative only.</t>
         <t>The following statements are NOT guaranteed to be true for every QUIC version:</t>
         <t>
            <list style="symbols">
               <t>QUIC uses TLS <xref target="QUIC-TLS"/> and some TLS messages are visible on the wire</t>
               <t>QUIC long headers are only exchanged during connection establishment</t>
               <t>Every flow on a given 5-tuple will include a connection establishment phase</t>
               <t>The first packets exchanged on a flow use the long header</t>
               <t>QUIC forbids acknowledgments of packets that only contain ACK frames, therefore the last packet before a long period of quiescence might be assumed to contain an acknowledgment</t>
               <t>QUIC uses an AEAD (AEAD_AES_128_GCM <xref target="RFC5116"/>) to protect the packets it exchanges during connection establishment</t>
               <t>QUIC packet numbers appear after the Version field</t>
               <t>QUIC packet numbers increase by one for every packet sent</t>
               <t>QUIC has a minimum size for the first handshake packet sent by a client</t>
               <t>QUIC stipulates that a client speaks first</t>
               <t>A QUIC Version Negotiation packet is only sent by a server</t>
               <t>A QUIC connection ID changes infrequently</t>
               <t>QUIC endpoints change the version they speak if they are sent a Version Negotiation packet</t>
               <t>The version field in a QUIC long header is the same in both directions</t>
               <t>Only one connection at a time is established between any pair of QUIC endpoints</t>
            </list>
         </t>
      </section>
   </back>
</rfc>
