RFC 9146 PROPOSED STANDARD SECURITY · DTLS · TRANSPORT

DTLS Connection ID: Connection Identifier for DTLS 1.2

A connection identifier in the DTLS 1.2 record header, so a session survives a change of IP address or port.

On rfc-editor.org ↗
PUBLISHED
March 2022
AUTHORS
E. Rescorla, H. Tschofenig, T. Fossati, A. Kraus
STREAM
IETF
BUILDS ON
RFC 6347 — DTLS 1.2
UPDATED BY
RFC 9853 — DTLS return routability
EXTENSION TYPE
connection_id (54)
CONTENT TYPE
tls12_cid (25)
CID LENGTH
0 to 2^8-1 bytes
SEQUENCE PLACEHOLDER
8 bytes of 0xff
MAXIMUM INNER PLAINTEXT
2^14 bytes
APPLIES TO
DTLS 1.2 only
DOI
10.17487/RFC9146

RFC text

Contents
Original text · RFC Editor View on rfc-editor.org ↗
Internet Engineering Task Force (IETF)                  E. Rescorla, Ed.
Request for Comments: 9146                                       Mozilla
Updates: 6347                                         H. Tschofenig, Ed.
Category: Standards Track                                     T. Fossati
ISSN: 2070-1721                                              Arm Limited
                                                                A. Kraus
                                                           Bosch.IO GmbH
                                                              March 2022


                   Connection Identifier for DTLS 1.2

Abstract

   This document specifies the Connection ID (CID) construct for the
   Datagram Transport Layer Security (DTLS) protocol version 1.2.

   A CID is an identifier carried in the record layer header that gives
   the recipient additional information for selecting the appropriate
   security association.  In "classical" DTLS, selecting a security
   association of an incoming DTLS record is accomplished with the help
   of the 5-tuple.  If the source IP address and/or source port changes
   during the lifetime of an ongoing DTLS session, then the receiver
   will be unable to locate the correct security context.

   The new ciphertext record format with the CID also provides content
   type encryption and record layer padding.

   This document updates RFC 6347.

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://www.rfc-editor.org/info/rfc9146.

Copyright Notice

   Copyright (c) 2022 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://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Revised BSD License text as described in Section 4.e of the
   Trust Legal Provisions and are provided without warranty as described
   in the Revised BSD License.

   This document may contain material from IETF Documents or IETF
   Contributions published or made publicly available before November
   10, 2008.  The person(s) controlling the copyright in some of this
   material may not have granted the IETF Trust the right to allow
   modifications of such material outside the IETF Standards Process.
   Without obtaining an adequate license from the person(s) controlling
   the copyright in such materials, this document may not be modified
   outside the IETF Standards Process, and derivative works of it may
   not be created outside the IETF Standards Process, except to format
   it for publication as an RFC or to translate it into languages other
   than English.

Table of Contents

   1.  Introduction
   2.  Conventions and Terminology
   3.  The "connection_id" Extension
   4.  Record Layer Extensions
   5.  Record Payload Protection
     5.1.  Block Ciphers
     5.2.  Block Ciphers with Encrypt-then-MAC Processing
     5.3.  AEAD Ciphers
   6.  Peer Address Update
   7.  Example
   8.  Privacy Considerations
   9.  Security Considerations
   10. IANA Considerations
     10.1.  Extra Column Added to the TLS ExtensionType Values
            Registry
     10.2.  New Entry in the TLS ExtensionType Values Registry
     10.3.  New Entry in the TLS ContentType Registry
   11. References
     11.1.  Normative References
     11.2.  Informative References
   Acknowledgements
   Contributors
   Authors' Addresses

1.  Introduction

   The Datagram Transport Layer Security (DTLS) protocol [RFC6347] was
   designed for securing data sent over datagram transports (e.g., UDP).
   DTLS, like TLS, starts with a handshake, which can be computationally
   demanding (particularly when public key cryptography is used).  After
   a successful handshake, symmetric key cryptography is used to apply
   data origin authentication, integrity, and confidentiality
   protection.  This two-step approach allows endpoints to amortize the
   cost of the initial handshake across subsequent application data
   protection.  Ideally, the second phase where application data is
   protected lasts over a long period of time, since the established
   keys will only need to be updated once the key lifetime expires.

   In DTLS as specified in RFC 6347, the IP address and port of the peer
   are used to identify the DTLS association.  Unfortunately, in some
   cases, such as NAT rebinding, these values are insufficient.  This is
   a particular issue in the Internet of Things when devices enter
   extended sleep periods to increase their battery lifetime.  The NAT
   rebinding leads to connection failure, with the resulting cost of a
   new handshake.

   This document defines an extension to DTLS 1.2 to add a Connection ID
   (CID) to the DTLS record layer.  The presence of the CID is
   negotiated via a DTLS extension.

   Adding a CID to the ciphertext record format presents an opportunity
   to make other changes to the record format.  In keeping with the best
   practices established by TLS 1.3, the type of the record is
   encrypted, and a mechanism is provided for adding padding to
   obfuscate the plaintext length.

2.  Conventions and Terminology

   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 assumes familiarity with DTLS 1.2 [RFC6347].  The
   presentation language used in this document is described in Section 3
   of [RFC8446].

3.  The "connection_id" Extension

   This document defines the "connection_id" extension, which is used in
   ClientHello and ServerHello messages.

   The extension type is specified as follows.

     enum {
        connection_id(54), (65535)
     } ExtensionType;

   The extension_data field of this extension, when included in the
   ClientHello, MUST contain the ConnectionId structure.  This structure
   contains the CID value the client wishes the server to use when
   sending messages to the client.  A zero-length CID value indicates
   that the client is prepared to send using a CID but does not wish the
   server to use one when sending.

     struct {
         opaque cid<0..2^8-1>;
     } ConnectionId;

   A server willing to use CIDs will respond with a "connection_id"
   extension in the ServerHello, containing the CID it wishes the client
   to use when sending messages towards it.  A zero-length value
   indicates that the server will send using the client's CID but does
   not wish the client to include a CID when sending.

   Because each party sends the value in the "connection_id" extension
   it wants to receive as a CID in encrypted records, it is possible for
   an endpoint to use a deployment-specific constant length for such
   connection identifiers.  This can in turn ease parsing and connection
   lookup -- for example, by having the length in question be a compile-
   time constant.  Such implementations MUST still be able to send CIDs
   of different lengths to other parties.  Since the CID length
   information is not included in the record itself, implementations
   that want to use variable-length CIDs are responsible for
   constructing the CID in such a way that its length can be determined
   on reception.

   In DTLS 1.2, CIDs are exchanged at the beginning of the DTLS session
   only.  There is no dedicated "CID update" message that allows new
   CIDs to be established mid-session, because DTLS 1.2 in general does
   not allow TLS 1.3-style post-handshake messages that do not
   themselves begin other handshakes.  When a DTLS session is resumed or
   renegotiated, the "connection_id" extension is negotiated afresh.

   If DTLS peers have not negotiated the use of CIDs, or a zero-length
   CID has been advertised for a given direction, then the record format
   and content type defined in RFC 6347 MUST be used to send in the
   indicated direction(s).

   If DTLS peers have negotiated the use of a non-zero-length CID for a
   given direction, then once encryption is enabled, they MUST send with
   the record format defined in Figure 3 (see Section 4) with the new
   Message Authentication Code (MAC) computation defined in Section 5
   and the content type tls12_cid.  Plaintext payloads never use the new
   record format or the CID content type.

   When receiving, if the tls12_cid content type is set, then the CID is
   used to look up the connection and the security association.  If the
   tls12_cid content type is not set, then the connection and the
   security association are looked up by the 5-tuple and a check MUST be
   made to determine whether a non-zero-length CID is expected.  If a
   non-zero-length CID is expected for the retrieved association, then
   the datagram MUST be treated as invalid, as described in
   Section 4.1.2.1 of [RFC6347].

   When receiving a datagram with the tls12_cid content type, the new
   MAC computation defined in Section 5 MUST be used.  When receiving a
   datagram with the record format defined in RFC 6347, the MAC
   calculation defined in Section 4.1.2 of [RFC6347] MUST be used.

4.  Record Layer Extensions

   This specification defines the CID-enhanced record layer format for
   DTLS 1.2, and [DTLS13] specifies how to carry the CID in DTLS 1.3.

   To allow a receiver to determine whether a record has a CID or not,
   connections that have negotiated this extension use a distinguished
   record type tls12_cid(25).  The use of this content type has the
   following three implications:

   *  The CID field is present and contains one or more bytes.

   *  The MAC calculation follows the process described in Section 5.

   *  The real content type is inside the encryption envelope, as
      described below.

   Plaintext records are not impacted by this extension.  Hence, the
   format of the DTLSPlaintext structure is left unchanged, as shown in
   Figure 1.

        struct {
            ContentType type;
            ProtocolVersion version;
            uint16 epoch;
            uint48 sequence_number;
            uint16 length;
            opaque fragment[DTLSPlaintext.length];
        } DTLSPlaintext;

                Figure 1: DTLS 1.2 Plaintext Record Payload

   When CIDs are being used, the content to be sent is first wrapped
   along with its content type and optional padding into a
   DTLSInnerPlaintext structure.  This newly introduced structure is
   shown in Figure 2.

        struct {
            opaque content[length];
            ContentType real_type;
            uint8 zeros[length_of_padding];
        } DTLSInnerPlaintext;

             Figure 2: New DTLSInnerPlaintext Payload Structure

   content:  Corresponds to the fragment of a given length.

   real_type:  The content type describing the cleartext payload.

   zeros:  An arbitrary-length run of zero-valued bytes may appear in
      the cleartext after the type field.  This provides an opportunity
      for senders to pad any DTLS record by a chosen amount as long as
      the total stays within record size limits.  See Section 5.4 of
      [RFC8446] for more details.  (Note that the term TLSInnerPlaintext
      in RFC 8446 refers to DTLSInnerPlaintext in this specification.)

   The DTLSInnerPlaintext byte sequence is then encrypted.  To create
   the DTLSCiphertext structure shown in Figure 3, the CID is added.

        struct {
            ContentType outer_type = tls12_cid;
            ProtocolVersion version;
            uint16 epoch;
            uint48 sequence_number;
            opaque cid[cid_length];               // New field
            uint16 length;
            opaque enc_content[DTLSCiphertext.length];
        } DTLSCiphertext;

             Figure 3: DTLS 1.2 CID-Enhanced Ciphertext Record

   outer_type:  The outer content type of a DTLSCiphertext record
      carrying a CID is always set to tls12_cid(25).  The real content
      type of the record is found in DTLSInnerPlaintext.real_type after
      decryption.

   cid:  The CID value, cid_length bytes long, as agreed at the time the
      extension has been negotiated.  Recall that each peer chooses the
      CID value it will receive and use to identify the connection, so
      an implementation can choose to always receive CIDs of a fixed
      length.  If, however, an implementation chooses to receive CIDs of
      different lengths, the assigned CID values must be self-
      delineating, since there is no other mechanism available to
      determine what connection (and thus, what CID length) is in use.

   enc_content:  The encrypted form of the serialized DTLSInnerPlaintext
      structure.

   All other fields are as defined in RFC 6347.

5.  Record Payload Protection

   Several types of ciphers have been defined for use with TLS and DTLS,
   and the MAC calculations for those ciphers differ slightly.

   This specification modifies the MAC calculation as defined in
   [RFC6347] and [RFC7366], as well as the definition of the additional
   data used with Authenticated Encryption with Associated Data (AEAD)
   ciphers provided in [RFC6347], for records with content type
   tls12_cid.  The modified algorithm MUST NOT be applied to records
   that do not carry a CID, i.e., records with content type other than
   tls12_cid.

   The following fields are defined in this document; all other fields
   are as defined in the cited documents.

   cid:  Value of the negotiated CID (variable length).

   cid_length:  The length (in bytes) of the negotiated CID (one-byte
      integer).

   length_of_DTLSInnerPlaintext:  The length (in bytes) of the
      serialized DTLSInnerPlaintext (two-byte integer).  The length MUST
      NOT exceed 2^14.

   seq_num_placeholder:  8 bytes of 0xff.

   Note that "+" denotes concatenation.

5.1.  Block Ciphers

   The following MAC algorithm applies to block ciphers that do not use
   the Encrypt-then-MAC processing described in [RFC7366].

       MAC(MAC_write_key,
           seq_num_placeholder +
           tls12_cid +
           cid_length +
           tls12_cid +
           DTLSCiphertext.version +
           epoch +
           sequence_number +
           cid +
           length_of_DTLSInnerPlaintext +
           DTLSInnerPlaintext.content +
           DTLSInnerPlaintext.real_type +
           DTLSInnerPlaintext.zeros
       );

   The rationale behind this construction is to separate the MAC input
   for DTLS without the connection ID from the MAC input with the
   connection ID.  The former always consists of a sequence number
   followed by some content type other than tls12_cid; the latter always
   consists of the seq_num_placeholder followed by tls12_cid.  Although
   2^64-1 is potentially a valid sequence number, tls12_cid will never
   be a valid content type when the connection ID is not in use.  In
   addition, the epoch and sequence_number are now fed into the MAC in
   the same order as they appear on the wire.

5.2.  Block Ciphers with Encrypt-then-MAC Processing

   The following MAC algorithm applies to block ciphers that use the
   Encrypt-then-MAC processing described in [RFC7366].

       MAC(MAC_write_key,
           seq_num_placeholder +
           tls12_cid +
           cid_length +
           tls12_cid +
           DTLSCiphertext.version +
           epoch +
           sequence_number +
           cid +
           DTLSCiphertext.length +
           IV +
           ENC(content + padding + padding_length)
       );

5.3.  AEAD Ciphers

   For ciphers utilizing AEAD, the following modification is made to the
   additional data calculation.

       additional_data = seq_num_placeholder +
                         tls12_cid +
                         cid_length +
                         tls12_cid +
                         DTLSCiphertext.version +
                         epoch +
                         sequence_number +
                         cid +
                         length_of_DTLSInnerPlaintext;

6.  Peer Address Update

   When a record with a CID is received that has a source address
   different from the one currently associated with the DTLS connection,
   the receiver MUST NOT replace the address it uses for sending records
   to its peer with the source address specified in the received
   datagram, unless the following three conditions are met:

   *  The received datagram has been cryptographically verified using
      the DTLS record layer processing procedures.

   *  The received datagram is "newer" (in terms of both epoch and
      sequence number) than the newest datagram received.  Reordered
      datagrams that are sent prior to a change in a peer address might
      otherwise cause a valid address change to be reverted.  This also
      limits the ability of an attacker to use replayed datagrams to
      force a spurious address change, which could result in denial of
      service.  An attacker might be able to succeed in changing a peer
      address if they are able to rewrite source addresses and if
      replayed packets are able to arrive before any original.

   *  There is a strategy for ensuring that the new peer address is able
      to receive and process DTLS records.  No strategy is mandated by
      this specification, but see note (*) below.

   The conditions above are necessary to protect against attacks that
   use datagrams with spoofed addresses or replayed datagrams to trigger
   attacks.  Note that there is no requirement for the use of the anti-
   replay window mechanism defined in Section 4.1.2.6 of [RFC6347].
   Both solutions, the "anti-replay window" or "newer" algorithm, will
   prevent address updates from replay attacks while the latter will
   only apply to peer address updates and the former applies to any
   application layer traffic.

   Note that datagrams that pass the DTLS cryptographic verification
   procedures but do not trigger a change of peer address are still
   valid DTLS records and are still to be passed to the application.

      (*) Note: Application protocols that implement protection against
      spoofed addresses depend on being aware of changes in peer
      addresses so that they can engage the necessary mechanisms.  When
      delivered such an event, an address validation mechanism specific
      to the application layer can be triggered -- for example, one that
      is based on successful exchange of a minimal amount of ping-pong
      traffic with the peer.  Alternatively, a DTLS-specific mechanism
      may be used, as described in [DTLS-RRC].

   DTLS implementations MUST silently discard records with bad MACs or
   that are otherwise invalid.

7.  Example

   Figure 4 shows an example exchange where a CID is used
   unidirectionally from the client to the server.  To indicate that a
   zero-length CID is present in the "connection_id" extension, we use
   the notation 'connection_id=empty'.

   Client                                             Server
   ------                                             ------

   ClientHello                 -------->
   (connection_id=empty)


                               <--------      HelloVerifyRequest
                                                        (cookie)

   ClientHello                 -------->
   (connection_id=empty)
   (cookie)

                                                     ServerHello
                                             (connection_id=100)
                                                     Certificate
                                               ServerKeyExchange
                                              CertificateRequest
                               <--------         ServerHelloDone

   Certificate
   ClientKeyExchange
   CertificateVerify
   [ChangeCipherSpec]
   Finished                    -------->
   <CID=100>

                                              [ChangeCipherSpec]
                               <--------                Finished


   Application Data            ========>
   <CID=100>

                               <========        Application Data

   Legend:

   <...> indicates that a connection ID is used in the record layer
   (...) indicates an extension
   [...] indicates a payload other than a handshake message

                Figure 4: Example DTLS 1.2 Exchange with CID

      Note: In the example exchange, the CID is included in the record
      layer once encryption is enabled.  In DTLS 1.2, only one handshake
      message is encrypted, namely the Finished message.  Since the
      example shows how to use the CID for payloads sent from the client
      to the server, only the record layer payloads containing the
      Finished message or application data include a CID.

8.  Privacy Considerations

   The CID replaces the previously used 5-tuple and, as such, introduces
   an identifier that remains persistent during the lifetime of a DTLS
   connection.  Every identifier introduces the risk of linkability, as
   explained in [RFC6973].

   An on-path adversary observing the DTLS protocol exchanges between
   the DTLS client and the DTLS server is able to link the observed
   payloads to all subsequent payloads carrying the same ID pair (for
   bidirectional communication).  Without multihoming or mobility, the
   use of the CID exposes the same information as the 5-tuple.

   With multihoming, a passive attacker is able to correlate the
   communication interaction over the two paths.  The lack of a CID
   update mechanism in DTLS 1.2 makes this extension unsuitable for
   mobility scenarios where correlation must be considered.  Deployments
   that use DTLS in multihoming environments and are concerned about
   these aspects SHOULD refuse to use CIDs in DTLS 1.2 and switch to
   DTLS 1.3 where a CID update mechanism is provided and sequence number
   encryption is available.

   This specification introduces record padding for the CID-enhanced
   record layer, which is a privacy feature not available with the
   original DTLS 1.2 specification.  Padding allows the size of the
   ciphertext to be inflated, making traffic analysis more difficult.
   More details about record padding can be found in Section 5.4 and
   Appendix E.3 of [RFC8446].

   Finally, endpoints can use the CID to attach arbitrary per-connection
   metadata to each record they receive on a given connection.  This may
   be used as a mechanism to communicate per-connection information to
   on-path observers.  There is no straightforward way to address this
   concern with CIDs that contain arbitrary values.  Implementations
   concerned about this aspect SHOULD refuse to use CIDs.

9.  Security Considerations

   An on-path adversary can create reflection attacks against third
   parties because a DTLS peer has no means to distinguish a genuine
   address update event (for example, due to a NAT rebinding) from one
   that is malicious.  This attack is of particular concern when the
   request is small and the response large.  See Section 6 for more on
   address updates.

   Additionally, an attacker able to observe the data traffic exchanged
   between two DTLS peers is able to replay datagrams with modified IP
   addresses / port numbers.

   The topic of peer address updates is discussed in Section 6.

10.  IANA Considerations

   This document implements three IANA updates.

10.1.  Extra Column Added to the TLS ExtensionType Values Registry

   IANA has added an extra column named "DTLS-Only" to the "TLS
   ExtensionType Values" registry to indicate whether an extension is
   only applicable to DTLS and to include this document as an additional
   reference for the registry.

10.2.  New Entry in the TLS ExtensionType Values Registry

   IANA has allocated an entry in the existing "TLS ExtensionType
   Values" registry for connection_id(54), as described in the table
   below.  Although the value 53 had been allocated by early allocation
   for a previous version of this document, it is incompatible with this
   document.  Therefore, the early allocation has been deprecated in
   favor of this assignment.

   +=======+===============+=====+===========+=============+===========+
   | Value |Extension Name | TLS | DTLS-Only | Recommended | Reference |
   |       |               | 1.3 |           |             |           |
   +=======+===============+=====+===========+=============+===========+
   | 54    |connection_id  | CH, | Y         | N           | RFC 9146  |
   |       |               | SH  |           |             |           |
   +-------+---------------+-----+-----------+-------------+-----------+

                                  Table 1

   A new column, "DTLS-Only", has been added to the registry.  The valid
   entries are "Y" if the extension is only applicable to DTLS, "N"
   otherwise.  All the pre-existing entries are given the value "N".

      Note: The value "N" in the "Recommended" column is set because
      this extension is intended only for specific use cases.  This
      document describes the behavior of this extension for DTLS 1.2
      only; it is not applicable to TLS, and its usage for DTLS 1.3 is
      described in [DTLS13].

10.3.  New Entry in the TLS ContentType Registry

   IANA has allocated tls12_cid(25) in the "TLS ContentType" registry.
   The tls12_cid content type is only applicable to DTLS 1.2.

11.  References

11.1.  Normative References

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC6347]  Rescorla, E. and N. Modadugu, "Datagram Transport Layer
              Security Version 1.2", RFC 6347, DOI 10.17487/RFC6347,
              January 2012, <https://www.rfc-editor.org/info/rfc6347>.

   [RFC7366]  Gutmann, P., "Encrypt-then-MAC for Transport Layer
              Security (TLS) and Datagram Transport Layer Security
              (DTLS)", RFC 7366, DOI 10.17487/RFC7366, September 2014,
              <https://www.rfc-editor.org/info/rfc7366>.

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

   [RFC8446]  Rescorla, E., "The Transport Layer Security (TLS) Protocol
              Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018,
              <https://www.rfc-editor.org/info/rfc8446>.

11.2.  Informative References

   [DTLS-RRC] Tschofenig, H., Ed. and T. Fossati, "Return Routability
              Check for DTLS 1.2 and DTLS 1.3", Work in Progress,
              Internet-Draft, draft-ietf-tls-dtls-rrc-05, 7 March 2022,
              <https://datatracker.ietf.org/doc/html/draft-ietf-tls-
              dtls-rrc-05>.

   [DTLS13]   Rescorla, E., Tschofenig, H., and N. Modadugu, "The
              Datagram Transport Layer Security (DTLS) Protocol Version
              1.3", Work in Progress, Internet-Draft, draft-ietf-tls-
              dtls13-43, 30 April 2021,
              <https://datatracker.ietf.org/doc/html/draft-ietf-tls-
              dtls13-43>.

   [RFC6973]  Cooper, A., Tschofenig, H., Aboba, B., Peterson, J.,
              Morris, J., Hansen, M., and R. Smith, "Privacy
              Considerations for Internet Protocols", RFC 6973,
              DOI 10.17487/RFC6973, July 2013,
              <https://www.rfc-editor.org/info/rfc6973>.

Acknowledgements

   We would like to thank Hanno Becker, Martin Duke, Lars Eggert, Ben
   Kaduk, Warren Kumari, Francesca Palombini, Tom Petch, John Scudder,
   Sean Turner, Éric Vyncke, and Robert Wilton for their review
   comments.

   Finally, we want to thank the IETF TLS Working Group chairs, Chris
   Wood, Joseph Salowey, and Sean Turner, for their patience, support,
   and feedback.

Contributors

   Many people have contributed to this specification, and we would like
   to thank the following individuals for their contributions:

   Yin Xinxing
   Huawei
   Email: yinxinxing@huawei.com


   Nikos Mavrogiannopoulos
   RedHat
   Email: nmav@redhat.com


   Tobias Gondrom
   Email: tobias.gondrom@gondrom.org


   Additionally, we would like to thank the Connection ID task force
   team members:

   *  Martin Thomson (Mozilla)

   *  Christian Huitema (Private Octopus Inc.)

   *  Jana Iyengar (Google)

   *  Daniel Kahn Gillmor (ACLU)

   *  Patrick McManus (Mozilla)

   *  Ian Swett (Google)

   *  Mark Nottingham (Fastly)

   The task force team discussed various design ideas, including
   cryptographically generated session IDs using hash chains and public
   key encryption, but dismissed them due to their inefficiency.  The
   approach described in this specification is the simplest possible
   design that works, given the limitations of DTLS 1.2.  DTLS 1.3
   provides better privacy features, and developers are encouraged to
   switch to the new version of DTLS.

Authors' Addresses

   Eric Rescorla (editor)
   Mozilla
   Email: ekr@rtfm.com


   Hannes Tschofenig (editor)
   Arm Limited
   Email: hannes.tschofenig@arm.com


   Thomas Fossati
   Arm Limited
   Email: thomas.fossati@arm.com


   Achim Kraus
   Bosch.IO GmbH
   Email: achim.kraus@bosch.io

ISO Plain Language

On this page
PROBLEMDTLS 1.2 finds the right security context from the sender's address and port. If the source address or port changes during a session, for example after a NAT rebinding, the receiver cannot find the session and a costly new handshake is needed.
MECHANISMBoth sides negotiate a connection_id extension in the hello messages. Afterwards each encrypted record carries the CID the receiver asked for, in a new record format with content type tls12_cid(25), a changed MAC computation, an encrypted real content type and optional padding.
THE CATCHThe receiver can look up the session by CID, while strict rules on peer address updates limit spoofing and replay. The RFC warns that a persistent identifier adds linkability, and recommends DTLS 1.3 where the identifier can be changed.

§1Why DTLS Needs a Connection ID

Datagram Transport Layer Security (DTLS), defined in RFC 6347, protects data sent over datagram transports such as UDP. Like TLS, it starts with a handshake that can be expensive, particularly when public key cryptography is used. After the handshake, symmetric key cryptography protects the data, and the second phase should last as long as possible so that the handshake cost is spread over many packets.

In DTLS as specified in RFC 6347, the IP address and port of the peer identify the DTLS association. In some cases those values are not enough. A NAT rebinding is the clearest example: the address changes and the connection fails, and the price is a new handshake. This matters most in the Internet of Things, where devices sleep for long periods to save battery and so are more likely to see their address change.

This RFC therefore adds a Connection ID (CID) to the DTLS record layer, negotiated through a DTLS extension. Adding a CID to the ciphertext record format also opens the door to other changes, and this RFC takes two of them from TLS 1.3: the real record type is encrypted, and a padding mechanism lets a sender hide the length of the plaintext.

DTLS labels a session by the address and port the data comes from. When a NAT changes that address, the session is lost and the two ends have to shake hands again. A short identifier in each record solves that.

§3The connection_id Extension

The connection_id extension, type 54, is carried in the ClientHello and the ServerHello. In the ClientHello the extension data must contain the ConnectionId structure, an opaque value of up to 255 bytes, and it holds the CID the client wants the server to use when sending to the client. A zero-length value means the client is willing to send using a CID but does not want the server to use one.

A server willing to use CIDs answers with a connection_id extension in the ServerHello holding the CID it wants the client to use when sending to it. A zero-length value means the server will send using the client's CID but does not want the client to include one.

Because each side sends the value it wants to receive, a deployment can fix the length of the CIDs it uses, which makes parsing and connection lookup easier. Implementations must still be able to send CIDs of different lengths to other parties, and since the record itself does not say how long the CID is, an implementation that uses variable-length CIDs must build them so that their length can be worked out on arrival.

In DTLS 1.2 the CIDs are exchanged only at the start of a session. There is no message for changing a CID in the middle of a session, because DTLS 1.2 does not allow TLS 1.3 style post-handshake messages that do not themselves start another handshake. A resumed or renegotiated session negotiates the extension afresh.

Each side says which identifier it wants to receive, and the other side puts that identifier on the records it sends. The length can be fixed by configuration, which makes it easy to look up the session.

The two new code points this RFC registers
  • 54connection_id — TLS extension used in ClientHello and ServerHello. DTLS only, and marked as not recommended.
  • 25tls12_cid — TLS content type that marks a DTLS 1.2 record as carrying a connection ID.

§4The CID-Enhanced Record Format

Connections that have negotiated the extension use a distinguished record type, tls12_cid(25), so the receiver can tell at once whether a record carries a CID. When that content type is set, the CID field is present with one or more bytes, the MAC follows the calculation in Section 5, and the real content type is inside the encryption envelope.

The plaintext structure is unchanged. The content to be sent is first wrapped, together with its real content type and optional padding, into a new DTLSInnerPlaintext structure with three parts: the content, the real type describing the cleartext payload, and a run of zero bytes used as padding. The padding lets a sender pad any record by a chosen amount as long as the total stays within the record size limits, which hides the length of the plaintext from an observer.

The DTLSInnerPlaintext is then encrypted, and the CID is added to make the DTLSCiphertext structure. Its outer type is always tls12_cid, and the new cid field holds the CID value, of the length agreed during the handshake. The real content type is found in the real_type field after decryption. All other fields are as defined in RFC 6347. When the peers have not negotiated a CID, or a zero-length CID was agreed for a direction, the record format of RFC 6347 must be used in that direction, and plaintext payloads never use the new format or the new content type.

Encrypted records that carry a CID get a new marker, a new field for the identifier, and an encrypted record type. The sender can also add padding so that the length of the message is not visible.

THE CID-ENHANCED CIPHERTEXT RECORD (RFC 9146 FIGURE 3), SHOWN WITH A ONE-BYTE CID
DTLS 1.2 CID-Enhanced Ciphertext Record
FieldNameSizeValueDescription
OUTER-TYPEOuter Type1 byte25Always tls12_cid(25) for a record that carries a CID.
VERSIONVersion2 bytesProtocol version, as in RFC 6347.
EPOCHEpoch2 bytesEpoch of the connection, as in RFC 6347.
SEQUENCE-NUMBERSequence Number6 bytesRecord sequence number, as in RFC 6347.
CIDCID1 byteThe connection ID, cid_length bytes long as agreed in the handshake; shown here as one byte.
LENGTHLength2 bytesLength of the encrypted content, as in RFC 6347.

§5Record Payload Protection

The MAC calculation changes for records with the content type tls12_cid, and the modified algorithm must not be applied to records without a CID. The construction keeps the two cases apart: a record without a CID is covered by a sequence number followed by some other content type, while a record with a CID is covered by a placeholder of eight bytes of 0xff followed by tls12_cid. Since tls12_cid is never a valid content type when the CID is not in use, the two MAC inputs can never be confused. The epoch and the sequence number now enter the MAC in the same order as they appear on the wire.

Three variants are given. For block ciphers that do not use Encrypt-then-MAC, the MAC covers the placeholder, the content type, the CID length, the version, the epoch, the sequence number, the CID, the length of the inner plaintext, and then the content, the real type and the padding. For block ciphers that do use Encrypt-then-MAC, the MAC covers the same fields but with the ciphertext length and the encrypted content instead. For AEAD ciphers, the same fields form the additional data. The length of the serialized inner plaintext is a two-byte integer and must not exceed 2^14.

The way the record is signed changes so that the identifier is covered by the signature, and so that a record with an identifier can never be mistaken for one without.

What changes on the wire once a CID is in use
  • New content typetls12_cid(25) marks a record that carries a CID.
  • Encrypted record typeThe real content type moves inside the encryption envelope.
  • PaddingA run of zero bytes can be added to hide the plaintext length.
  • New MAC inputThe identifier is covered by the signature, with a placeholder that keeps old and new records apart.

§6Updating the Peer Address

When a record with a CID arrives from an address other than the one currently associated with the DTLS connection, the receiver must not start sending to that new address unless three conditions are met. The datagram must have been cryptographically verified using the record layer procedures. It must be newer, in both epoch and sequence number, than the newest datagram received, because a reordered datagram from before an address change could otherwise revert a valid change, and because this limits what an attacker can do with replayed datagrams. And there must be a strategy for making sure the new address can receive and process DTLS records; no strategy is mandated, but the RFC points to a return routability check.

Datagrams that pass the cryptographic checks but do not cause an address change are still valid records and must still be passed to the application. DTLS implementations must silently discard records with bad MACs or that are otherwise invalid.

A session may follow its peer to a new address, but only when the record is correctly signed, is newer than anything seen before, and there is a plan for reaching the new address.

§7Example Exchange

The RFC's example shows a CID used in one direction only, from the client to the server. The client sends a ClientHello with a zero-length connection_id, receives a HelloVerifyRequest with a cookie, and repeats the ClientHello with the cookie. The server's ServerHello carries connection_id=100, and the server's other handshake messages follow. The client's Finished message and its application data then carry the CID 100 in the record layer, while the server's application data uses the ordinary record format.

The example also shows when the CID appears. In DTLS 1.2 only one handshake message is encrypted, the Finished message, so the CID is only on the records that carry the Finished message or application data.

In the example, the client asks to receive the identifier 100 and then puts that identifier on the records it sends. The server keeps using the ordinary format.

THE EXAMPLE EXCHANGE OF RFC 9146, WITH A CID FROM CLIENT TO SERVER
ClientServer
  1. ClientHello (connection_id=empty)The client offers to receive a CID.
  2. HelloVerifyRequest (cookie)
  3. ServerHello (connection_id=100)The server names the CID the client should use.
  4. Application Data with CID=100The client puts the CID on its encrypted records.

§8Privacy Considerations

The CID replaces the 5-tuple, and it stays the same for the life of the DTLS connection. Every identifier carries a risk of linkability, as explained in RFC 6973. An on-path observer can link the payloads it sees to all later payloads that carry the same pair of identifiers. Without multihoming or mobility, the CID exposes the same information as the 5-tuple did.

With multihoming, a passive attacker can correlate the communication over the two paths, and because DTLS 1.2 has no way to update a CID, this extension is unsuitable for mobility situations where correlation matters. A deployment that uses DTLS with multihoming and cares about this should refuse to use CIDs in DTLS 1.2 and move to DTLS 1.3, where a CID update mechanism and sequence number encryption are available.

Padding is a privacy feature that the original DTLS 1.2 did not have, because it lets a sender inflate the ciphertext and make traffic analysis harder. Endpoints can also attach arbitrary per-connection metadata to the records they receive, which may leak information to on-path observers, and implementations worried about that should refuse to use CIDs.

A CID stays the same for the whole session, so anyone watching the network can tell that two packets belong to the same conversation. Padding hides the size of messages, but the identifier itself is a lasting mark.

§9Security Considerations

An on-path adversary can mount reflection attacks against third parties, because a DTLS peer has no way to tell a genuine address update, such as one caused by a NAT rebinding, from a malicious one. The attack is worst when the request is small and the response is large. An attacker who can observe the traffic between two DTLS peers can also replay datagrams with modified IP addresses and port numbers.

Both problems are addressed by the rules on peer address updates in Section 6: an address change has to be backed by a cryptographically verified, newer datagram, so a replayed or spoofed datagram cannot move the session to an address of the attacker's choosing.

Someone on the path could try to move the session to an address they control. The rules about when an address change is allowed are what stop that, and they also stop replayed packets from doing it.

§9References