idnits 2.17.1 draft-ietf-ipsecme-rfc8229bis-06.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (17 May 2022) is 708 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'RFCXXXX' is mentioned on line 981, but not defined == Missing Reference: 'CERTREQ' is mentioned on line 1192, but not defined == Missing Reference: 'CERT' is mentioned on line 1197, but not defined == Missing Reference: 'CP' is mentioned on line 1245, but not defined == Outdated reference: A later version (-11) exists of draft-ietf-uta-rfc7525bis-06 -- Obsolete informational reference (is this intentional?): RFC 5246 (Obsoleted by RFC 8446) -- Obsolete informational reference (is this intentional?): RFC 6528 (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 8229 (Obsoleted by RFC 9329) Summary: 0 errors (**), 0 flaws (~~), 6 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group T. Pauly 3 Internet-Draft Apple Inc. 4 Obsoletes: 8229 (if approved) V. Smyslov 5 Intended status: Standards Track ELVIS-PLUS 6 Expires: 18 November 2022 17 May 2022 8 TCP Encapsulation of IKE and IPsec Packets 9 draft-ietf-ipsecme-rfc8229bis-06 11 Abstract 13 This document describes a method to transport Internet Key Exchange 14 Protocol (IKE) and IPsec packets over a TCP connection for traversing 15 network middleboxes that may block IKE negotiation over UDP. This 16 method, referred to as "TCP encapsulation", involves sending both IKE 17 packets for Security Association establishment and Encapsulating 18 Security Payload (ESP) packets over a TCP connection. This method is 19 intended to be used as a fallback option when IKE cannot be 20 negotiated over UDP. 22 TCP encapsulation for IKE and IPsec was defined in RFC 8229. This 23 document updates the specification for TCP encapsulation by including 24 additional clarifications obtained during implementation and 25 deployment of this method. This documents obsoletes RFC 8229. 27 Status of This Memo 29 This Internet-Draft is submitted in full conformance with the 30 provisions of BCP 78 and BCP 79. 32 Internet-Drafts are working documents of the Internet Engineering 33 Task Force (IETF). Note that other groups may also distribute 34 working documents as Internet-Drafts. The list of current Internet- 35 Drafts is at https://datatracker.ietf.org/drafts/current/. 37 Internet-Drafts are draft documents valid for a maximum of six months 38 and may be updated, replaced, or obsoleted by other documents at any 39 time. It is inappropriate to use Internet-Drafts as reference 40 material or to cite them other than as "work in progress." 42 This Internet-Draft will expire on 18 November 2022. 44 Copyright Notice 46 Copyright (c) 2022 IETF Trust and the persons identified as the 47 document authors. All rights reserved. 49 This document is subject to BCP 78 and the IETF Trust's Legal 50 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 51 license-info) in effect on the date of publication of this document. 52 Please review these documents carefully, as they describe your rights 53 and restrictions with respect to this document. Code Components 54 extracted from this document must include Revised BSD License text as 55 described in Section 4.e of the Trust Legal Provisions and are 56 provided without warranty as described in the Revised BSD License. 58 Table of Contents 60 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 61 1.1. Prior Work and Motivation . . . . . . . . . . . . . . . . 4 62 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 5 63 3. Configuration . . . . . . . . . . . . . . . . . . . . . . . . 5 64 4. TCP-Encapsulated Header Formats . . . . . . . . . . . . . . . 6 65 4.1. TCP-Encapsulated IKE Header Format . . . . . . . . . . . 6 66 4.2. TCP-Encapsulated ESP Header Format . . . . . . . . . . . 7 67 5. TCP-Encapsulated Stream Prefix . . . . . . . . . . . . . . . 7 68 6. Applicability . . . . . . . . . . . . . . . . . . . . . . . . 8 69 6.1. Recommended Fallback from UDP . . . . . . . . . . . . . . 8 70 7. Using TCP Encapsulation . . . . . . . . . . . . . . . . . . . 9 71 7.1. Connection Establishment and Teardown . . . . . . . . . . 9 72 7.2. Retransmissions . . . . . . . . . . . . . . . . . . . . . 11 73 7.3. Cookies and Puzzles . . . . . . . . . . . . . . . . . . . 11 74 7.3.1. Statelessness versus Delay of SA Establishment . . . 13 75 7.4. Error Handling in IKE_SA_INIT . . . . . . . . . . . . . . 13 76 7.5. NAT Detection Payloads . . . . . . . . . . . . . . . . . 14 77 7.6. Keep-Alives and Dead Peer Detection . . . . . . . . . . . 14 78 7.7. Implications of TCP Encapsulation on IPsec SA 79 Processing . . . . . . . . . . . . . . . . . . . . . . . 15 80 8. Interaction with IKEv2 Extensions . . . . . . . . . . . . . . 15 81 8.1. MOBIKE Protocol . . . . . . . . . . . . . . . . . . . . . 15 82 8.2. IKE Redirect . . . . . . . . . . . . . . . . . . . . . . 17 83 8.3. IKEv2 Session Resumption . . . . . . . . . . . . . . . . 17 84 8.4. IKEv2 Protocol Support for High Availability . . . . . . 17 85 8.5. IKEv2 Fragmentation . . . . . . . . . . . . . . . . . . . 18 86 9. Middlebox Considerations . . . . . . . . . . . . . . . . . . 18 87 10. Performance Considerations . . . . . . . . . . . . . . . . . 19 88 10.1. TCP-in-TCP . . . . . . . . . . . . . . . . . . . . . . . 19 89 10.2. Added Reliability for Unreliable Protocols . . . . . . . 20 90 10.3. Quality-of-Service Markings . . . . . . . . . . . . . . 20 91 10.4. Maximum Segment Size . . . . . . . . . . . . . . . . . . 20 92 10.5. Tunneling ECN in TCP . . . . . . . . . . . . . . . . . . 20 93 11. Security Considerations . . . . . . . . . . . . . . . . . . . 21 94 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 21 95 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 22 96 13.1. Normative References . . . . . . . . . . . . . . . . . . 22 97 13.2. Informative References . . . . . . . . . . . . . . . . . 22 98 Appendix A. Using TCP Encapsulation with TLS . . . . . . . . . . 24 99 Appendix B. Example Exchanges of TCP Encapsulation with TLS 100 1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 101 B.1. Establishing an IKE Session . . . . . . . . . . . . . . . 25 102 B.2. Deleting an IKE Session . . . . . . . . . . . . . . . . . 27 103 B.3. Re-establishing an IKE Session . . . . . . . . . . . . . 28 104 B.4. Using MOBIKE between UDP and TCP Encapsulation . . . . . 28 105 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 31 106 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 31 108 1. Introduction 110 The Internet Key Exchange Protocol version 2 (IKEv2) [RFC7296] is a 111 protocol for establishing IPsec Security Associations (SAs), using 112 IKE messages over UDP for control traffic, and using Encapsulating 113 Security Payload (ESP) [RFC4303] messages for encrypted data traffic. 114 Many network middleboxes that filter traffic on public hotspots block 115 all UDP traffic, including IKE and IPsec, but allow TCP connections 116 through because they appear to be web traffic. Devices on these 117 networks that need to use IPsec (to access private enterprise 118 networks, to route Voice over IP calls to carrier networks, or 119 because of security policies) are unable to establish IPsec SAs. 120 This document defines a method for encapsulating IKE control messages 121 as well as IPsec data messages within a TCP connection. 123 Using TCP as a transport for IPsec packets adds a third option to the 124 list of traditional IPsec transports: 126 1. Direct. Currently, IKE negotiations begin over UDP port 500. If 127 no Network Address Translation (NAT) device is detected between 128 the Initiator and the Responder, then subsequent IKE packets are 129 sent over UDP port 500, and IPsec data packets are sent using 130 ESP. 132 2. UDP Encapsulation [RFC3948]. If a NAT is detected between the 133 Initiator and the Responder, then subsequent IKE packets are sent 134 over UDP port 4500 with four bytes of zero at the start of the 135 UDP payload, and ESP packets are sent out over UDP port 4500. 136 Some peers default to using UDP encapsulation even when no NAT is 137 detected on the path, as some middleboxes do not support IP 138 protocols other than TCP and UDP. 140 3. TCP Encapsulation. If the other two methods are not available or 141 appropriate, IKE negotiation packets as well as ESP packets can 142 be sent over a single TCP connection to the peer. 144 Direct use of ESP or UDP encapsulation should be preferred by IKE 145 implementations due to performance concerns when using TCP 146 encapsulation (Section 10). Most implementations should use TCP 147 encapsulation only on networks where negotiation over UDP has been 148 attempted without receiving responses from the peer or if a network 149 is known to not support UDP. 151 1.1. Prior Work and Motivation 153 Encapsulating IKE connections within TCP streams is a common approach 154 to solve the problem of UDP packets being blocked by network 155 middleboxes. The specific goals of this document are as follows: 157 * To promote interoperability by defining a standard method of 158 framing IKE and ESP messages within TCP streams. 160 * To be compatible with the current IKEv2 standard without requiring 161 modifications or extensions. 163 * To use IKE over UDP by default to avoid the overhead of other 164 alternatives that always rely on TCP or Transport Layer Security 165 (TLS) [RFC5246][RFC8446]. 167 Some previous alternatives include: 169 Cellular Network Access 170 Interworking Wireless LAN (IWLAN) uses IKEv2 to create secure 171 connections to cellular carrier networks for making voice calls 172 and accessing other network services over Wi-Fi networks. 3GPP has 173 recommended that IKEv2 and ESP packets be sent within a TLS 174 connection to be able to establish connections on restrictive 175 networks. 177 ISAKMP over TCP 178 Various non-standard extensions to the Internet Security 179 Association and Key Management Protocol (ISAKMP) have been 180 deployed that send IPsec traffic over TCP or TCP-like packets. 182 Secure Sockets Layer (SSL) VPNs 183 Many proprietary VPN solutions use a combination of TLS and IPsec 184 in order to provide reliability. These often run on TCP port 443. 186 IKEv2 over TCP 187 IKEv2 over TCP as described in [I-D.ietf-ipsecme-ike-tcp] is used 188 to avoid UDP fragmentation. 190 TCP encapsulation for IKE and IPsec was defined in [RFC8229]. This 191 document updates the specification for TCP encapsulation by including 192 additional clarifications obtained during implementation and 193 deployment of this method. 195 2. Terminology and Notation 197 This document distinguishes between the IKE peer that initiates TCP 198 connections to be used for TCP encapsulation and the roles of 199 Initiator and Responder for particular IKE messages. During the 200 course of IKE exchanges, the role of IKE Initiator and Responder may 201 swap for a given SA (as with IKE SA rekeys), while the Initiator of 202 the TCP connection is still responsible for tearing down the TCP 203 connection and re-establishing it if necessary. For this reason, 204 this document will use the term "TCP Originator" to indicate the IKE 205 peer that initiates TCP connections. The peer that receives TCP 206 connections will be referred to as the "TCP Responder". If an IKE SA 207 is rekeyed one or more times, the TCP Originator MUST remain the peer 208 that originally initiated the first IKE SA. 210 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 211 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 212 "OPTIONAL" in this document are to be interpreted as described in BCP 213 14 [RFC2119] [RFC8174] when, and only when, they appear in all 214 capitals, as shown here. 216 3. Configuration 218 One of the main reasons to use TCP encapsulation is that UDP traffic 219 may be entirely blocked on a network. Because of this, support for 220 TCP encapsulation is not specifically negotiated in the IKE exchange. 221 Instead, support for TCP encapsulation must be pre-configured on both 222 the TCP Originator and the TCP Responder. 224 Implementations MUST support TCP encapsulation on TCP port 4500, 225 which is reserved for IPsec NAT traversal. 227 Beyond a flag indicating support for TCP encapsulation, the 228 configuration for each peer can include the following optional 229 parameters: 231 * Alternate TCP ports on which the specific TCP Responder listens 232 for incoming connections. Note that the TCP Originator may 233 initiate TCP connections to the TCP Responder from any local port. 235 * An extra framing protocol to use on top of TCP to further 236 encapsulate the stream of IKE and IPsec packets. See Appendix B 237 for a detailed discussion. 239 Since TCP encapsulation of IKE and IPsec packets adds overhead and 240 has potential performance trade-offs compared to direct or UDP- 241 encapsulated SAs (as described in Section 10), implementations SHOULD 242 prefer ESP direct or UDP-encapsulated SAs over TCP-encapsulated SAs 243 when possible. 245 4. TCP-Encapsulated Header Formats 247 Like UDP encapsulation, TCP encapsulation uses the first four bytes 248 of a message to differentiate IKE and ESP messages. TCP 249 encapsulation also adds a 16-bit Length field that precedes every 250 message to define the boundaries of messages within a stream. The 251 value in this field is equal to the length of the original message 252 plus the length of the field itself, in octets. If the first 32 bits 253 of the message are zeros (a non-ESP marker), then the contents 254 comprise an IKE message. Otherwise, the contents comprise an ESP 255 message. Authentication Header (AH) messages are not supported for 256 TCP encapsulation. 258 Although a TCP stream may be able to send very long messages, 259 implementations SHOULD limit message lengths to typical UDP datagram 260 ESP payload lengths. The maximum message length is used as the 261 effective MTU for connections that are being encrypted using ESP, so 262 the maximum message length will influence characteristics of inner 263 connections, such as the TCP Maximum Segment Size (MSS). 265 Note that this method of encapsulation will also work for placing IKE 266 and ESP messages within any protocol that presents a stream 267 abstraction, beyond TCP. 269 4.1. TCP-Encapsulated IKE Header Format 271 1 2 3 272 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 273 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 274 | Length | 275 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 276 | Non-ESP Marker | 277 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 278 | | 279 ~ IKE header [RFC7296] ~ 280 | | 281 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 283 Figure 1 285 The IKE header is preceded by a 16-bit Length field in network byte 286 order that specifies the length of the IKE message (including the 287 non-ESP marker) within the TCP stream. As with IKE over UDP port 288 4500, a zeroed 32-bit non-ESP marker is inserted before the start of 289 the IKE header in order to differentiate the traffic from ESP traffic 290 between the same addresses and ports. 292 * Length (2 octets, unsigned integer) - Length of the IKE packet, 293 including the Length field and non-ESP marker. The value in the 294 Length field MUST NOT be 0 or 1. The receiver MUST treat these 295 values as fatal errors and MUST close TCP connection. 297 4.2. TCP-Encapsulated ESP Header Format 299 1 2 3 300 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 301 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 302 | Length | 303 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 304 | | 305 ~ ESP header [RFC4303] ~ 306 | | 307 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 309 Figure 2 311 The ESP header is preceded by a 16-bit Length field in network byte 312 order that specifies the length of the ESP packet within the TCP 313 stream. 315 The Security Parameter Index (SPI) field [RFC7296] in the ESP header 316 MUST NOT be a zero value. 318 * Length (2 octets, unsigned integer) - Length of the ESP packet, 319 including the Length field. The value in the Length field MUST 320 NOT be 0 or 1. The receiver MUST treat these values as fatal 321 errors and MUST close TCP connection. 323 5. TCP-Encapsulated Stream Prefix 325 Each stream of bytes used for IKE and IPsec encapsulation MUST begin 326 with a fixed sequence of six bytes as a magic value, containing the 327 characters "IKETCP" as ASCII values. This value is intended to 328 identify and validate that the TCP connection is being used for TCP 329 encapsulation as defined in this document, to avoid conflicts with 330 the prevalence of previous non-standard protocols that used TCP port 331 4500. This value is only sent once, by the TCP Originator only, at 332 the beginning of any stream of IKE and ESP messages. 334 If other framing protocols are used within TCP to further encapsulate 335 or encrypt the stream of IKE and ESP messages, the stream prefix must 336 be at the start of the TCP Originator's IKE and ESP message stream 337 within the added protocol layer (Appendix B). Although some framing 338 protocols do support negotiating inner protocols, the stream prefix 339 should always be used in order for implementations to be as generic 340 as possible and not rely on other framing protocols on top of TCP. 342 0 1 2 3 4 5 343 +------+------+------+------+------+------+ 344 | 0x49 | 0x4b | 0x45 | 0x54 | 0x43 | 0x50 | 345 +------+------+------+------+------+------+ 347 Figure 3 349 6. Applicability 351 TCP encapsulation is applicable only when it has been configured to 352 be used with specific IKE peers. If a Responder is configured to use 353 TCP encapsulation, it MUST listen on the configured port(s) in case 354 any peers will initiate new IKE sessions. Initiators MAY use TCP 355 encapsulation for any IKE session to a peer that is configured to 356 support TCP encapsulation, although it is recommended that Initiators 357 should only use TCP encapsulation when traffic over UDP is blocked. 359 Since the support of TCP encapsulation is a configured property, not 360 a negotiated one, it is recommended that if there are multiple IKE 361 endpoints representing a single peer (such as multiple machines with 362 different IP addresses when connecting by Fully Qualified Domain 363 Name, or endpoints used with IKE redirection), all of the endpoints 364 equally support TCP encapsulation. 366 If TCP encapsulation is being used for a specific IKE SA, all 367 messages for that IKE SA and its Child SAs MUST be sent over a TCP 368 connection until the SA is deleted or IKEv2 Mobility and Multihoming 369 (MOBIKE) is used to change the SA endpoints and/or the encapsulation 370 protocol. See Section 8.1 for more details on using MOBIKE to 371 transition between encapsulation modes. 373 6.1. Recommended Fallback from UDP 375 Since UDP is the preferred method of transport for IKE messages, 376 implementations that use TCP encapsulation should have an algorithm 377 for deciding when to use TCP after determining that UDP is unusable. 378 If an Initiator implementation has no prior knowledge about the 379 network it is on and the status of UDP on that network, it SHOULD 380 always attempt to negotiate IKE over UDP first. IKEv2 defines how to 381 use retransmission timers with IKE messages and, specifically, 382 IKE_SA_INIT messages [RFC7296]. Generally, this means that the 383 implementation will define a frequency of retransmission and the 384 maximum number of retransmissions allowed before marking the IKE SA 385 as failed. An implementation can attempt negotiation over TCP once 386 it has hit the maximum retransmissions over UDP, or slightly before 387 to reduce connection setup delays. It is recommended that the 388 initial message over UDP be retransmitted at least once before 389 falling back to TCP, unless the Initiator knows beforehand that the 390 network is likely to block UDP. 392 When switching from UDP to TCP, a new IKE_SA_INIT exchange MUST be 393 initiated with the Initiator's new SPI and with recalculated content 394 of NAT_DETECTION_*_IP notifications. 396 7. Using TCP Encapsulation 398 7.1. Connection Establishment and Teardown 400 When the IKE Initiator uses TCP encapsulation, it will initiate a TCP 401 connection to the Responder using the configured TCP port. The first 402 bytes sent on the stream MUST be the stream prefix value (Section 5). 403 After this prefix, encapsulated IKE messages will negotiate the IKE 404 SA and initial Child SA [RFC7296]. After this point, both 405 encapsulated IKE (Figure 1) and ESP (Figure 2) messages will be sent 406 over the TCP connection. The TCP Responder MUST wait for the entire 407 stream prefix to be received on the stream before trying to parse out 408 any IKE or ESP messages. The stream prefix is sent only once, and 409 only by the TCP Originator. 411 In order to close an IKE session, either the Initiator or Responder 412 SHOULD gracefully tear down IKE SAs with DELETE payloads. Once the 413 SA has been deleted, the TCP Originator SHOULD close the TCP 414 connection if it does not intend to use the connection for another 415 IKE session to the TCP Responder. If the TCP connection is no longer 416 associated with any active IKE SA, the TCP Responder MAY close the 417 connection to clean up resources if TCP Originator didn't close it 418 within some reasonable period of time (e.g., a few seconds). 420 An unexpected FIN or a TCP Reset on the TCP connection may indicate a 421 loss of connectivity, an attack, or some other error. If a DELETE 422 payload has not been sent, both sides SHOULD maintain the state for 423 their SAs for the standard lifetime or timeout period. The TCP 424 Originator is responsible for re-establishing the TCP connection if 425 it is torn down for any unexpected reason. Since new TCP connections 426 may use different ports due to NAT mappings or local port allocations 427 changing, the TCP Responder MUST allow packets for existing SAs to be 428 received from new source ports. 430 A peer MUST discard a partially received message due to a broken 431 connection. 433 Whenever the TCP Originator opens a new TCP connection to be used for 434 an existing IKE SA, it MUST send the stream prefix first, before any 435 IKE or ESP messages. This follows the same behavior as the initial 436 TCP connection. 438 If a TCP connection is being used to resume a previous IKE session, 439 the TCP Responder can recognize the session using either the IKE SPI 440 from an encapsulated IKE message or the ESP SPI from an encapsulated 441 ESP message. If the session had been fully established previously, 442 it is suggested that the TCP Originator send an UPDATE_SA_ADDRESSES 443 message if MOBIKE is supported, or an informational message (a keep- 444 alive) otherwise. 446 The TCP Responder MUST NOT accept any messages for the existing IKE 447 session on a new incoming connection, unless that connection begins 448 with the stream prefix. If either the TCP Originator or TCP 449 Responder detects corruption on a connection that was started with a 450 valid stream prefix, it SHOULD close the TCP connection. The 451 connection can be determined to be corrupted if there are too many 452 subsequent messages that cannot be parsed as valid IKE messages or 453 ESP messages with known SPIs, or if the authentication check for an 454 ESP message with a known SPI fails. Implementations SHOULD NOT tear 455 down a connection if only a single ESP message has an unknown SPI, 456 since the SPI databases may be momentarily out of sync. If there is 457 instead a syntax issue within an IKE message, an implementation MUST 458 send the INVALID_SYNTAX notify payload and tear down the IKE SA as 459 usual, rather than tearing down the TCP connection directly. 461 A TCP Originator SHOULD only open one TCP connection per IKE SA, over 462 which it sends all of the corresponding IKE and ESP messages. This 463 helps ensure that any firewall or NAT mappings allocated for the TCP 464 connection apply to all of the traffic associated with the IKE SA 465 equally. 467 Similarly, a TCP Responder SHOULD at any given time send packets for 468 an IKE SA and its Child SAs over only one TCP connection. It SHOULD 469 choose the TCP connection on which it last received a valid and 470 decryptable IKE or ESP message. In order to be considered valid for 471 choosing a TCP connection, an IKE message must be successfully 472 decrypted and authenticated, not be a retransmission of a previously 473 received message, and be within the expected window for IKE message 474 IDs. Similarly, an ESP message must pass authentication checks and 475 be decrypted, and must not be a replay of a previous message. 477 Since a connection may be broken and a new connection re-established 478 by the TCP Originator without the TCP Responder being aware, a TCP 479 Responder SHOULD accept receiving IKE and ESP messages on both old 480 and new connections until the old connection is closed by the TCP 481 Originator. A TCP Responder MAY close a TCP connection that it 482 perceives as idle and extraneous (one previously used for IKE and ESP 483 messages that has been replaced by a new connection). 485 Multiple IKE SAs MUST NOT share a single TCP connection, unless one 486 is a rekey of an existing IKE SA, in which case there will 487 temporarily be two IKE SAs on the same TCP connection. 489 7.2. Retransmissions 491 Section 2.1 of [RFC7296] describes how IKEv2 deals with the 492 unreliability of the UDP protocol. In brief, the exchange Initiator 493 is responsible for retransmissions and must retransmit requests 494 message until response message is received. If no reply is received 495 after several retransmissions, the SA is deleted. The Responder 496 never initiates retransmission, but must send a response message 497 again in case it receives a retransmitted request. 499 When IKEv2 uses a reliable transport protocol, like TCP, the 500 retransmission rules are as follows: 502 * The exchange Initiator SHOULD NOT retransmit request message; if 503 no response is received within some reasonable period of time, the 504 IKE SA is deleted. 506 * If a new TCP connection for the IKE SA is established while the 507 exchange Initiator is waiting for a response, the Initiator MUST 508 retransmit its request over this connection and continue to wait 509 for a response. 511 * The exchange Responder does not change its behavior, but acts as 512 described in Section 2.1 of [RFC7296]. 514 7.3. Cookies and Puzzles 516 IKEv2 provides a DoS attack protection mechanism through Cookies, 517 which is described in Section 2.6 of [RFC7296]. [RFC8019] extends 518 this mechanism for protection against DDoS attacks by means of Client 519 Puzzles. Both mechanisms allow the Responder to avoid keeping state 520 until the Initiator proves its IP address is legitimate (and after 521 solving a puzzle if required). 523 The connection-oriented nature of TCP transport brings additional 524 considerations for using these mechanisms. In general, Cookies 525 provide less value in case of TCP encapsulation, since by the time a 526 Responder receives the IKE_SA_INIT request, the TCP session has 527 already been established and the Initiator's IP address has been 528 verified. Moreover, a TCP/IP stack creates state once a TCP SYN 529 packet is received (unless SYN Cookies described in [RFC4987] are 530 employed), which contradicts the statelessness of IKEv2 Cookies. In 531 particular, with TCP, an attacker is able to mount a SYN flooding DoS 532 attack which an IKEv2 Responder cannot prevent using stateless IKEv2 533 Cookies. Thus, when using TCP encapsulation, it makes little sense 534 to send Cookie requests without Puzzles unless the Responder is 535 concerned with a possibility of TCP Sequence Number attacks (see 536 [RFC6528] for details). Puzzles, on the other hand, still remain 537 useful (and their use requires using Cookies). 539 The following considerations are applicable for using Cookie and 540 Puzzle mechanisms in case of TCP encapsulation: 542 * the exchange Responder SHOULD NOT send an IKEv2 Cookie request 543 without an accompanied Puzzle; implementations might choose to 544 have exceptions to this for cases like mitigating TCP Sequence 545 Number attacks. 547 * if the Responder chooses to send Cookie request (possibly along 548 with Puzzle request), then the TCP connection that the IKE_SA_INIT 549 request message was received over SHOULD be closed after the 550 Responder sends its reply and no repeated requests are received 551 within some short period of time to keep the Responder stateless 552 (see Section 7.3.1). Note that the Responder MUST NOT include the 553 Initiator's TCP port into the Cookie calculation (*), since the 554 Cookie can be returned over a new TCP connection with a different 555 port. 557 * the exchange Initiator acts as described in Section 2.6 of 558 [RFC7296] and Section 7 of [RFC8019], i.e. using TCP encapsulation 559 doesn't change the Initiator's behavior. 561 (*) Examples of Cookie calculation methods are given in Section 2.6 562 of [RFC7296] and in Section 7.1.1.3 of [RFC8019] and they don't 563 include transport protocol ports. However these examples are given 564 for illustrative purposes, since Cookie generation algorithm is a 565 local matter and some implementations might include port numbers, 566 that won't work with TCP encapsulation. Note also that these 567 examples include the Initiator's IP address in Cookie calculation. 568 In general this address may change between two initial requests (with 569 and without Cookies). This may happen due to NATs, since NATs have 570 more freedom to change source IP addresses for new TCP connections 571 than for UDP. In such cases cookie verification might fail. 573 7.3.1. Statelessness versus Delay of SA Establishment 575 There is a trade-off in choosing the period of time after which TCP 576 connection is closed. If it is too short, then the proper Initiator 577 which repeats its request would need to re-establish the TCP 578 connection introducing additional delay. On the other hand, if it is 579 too long, then the Responder's resources would be wasted in case the 580 Initiator never comes back. This document doesn't specify the 581 duration of time, because it doesn't affect interoperability, but it 582 is believed that 5-10 seconds is a good compromise. Note also, that 583 if the Responder requests the Initiator to solve a puzzle, then the 584 Responder can estimate how long it would take the Initiator to find a 585 solution and adjust the time interval accordingly. 587 7.4. Error Handling in IKE_SA_INIT 589 Section 2.21.1 of [RFC7296] describes how error notifications are 590 handled in the IKE_SA_INIT exchange. In particular, it is advised 591 that the Initiator should not act immediately after receiving error 592 notification and should instead wait some time for valid response, 593 since the IKE_SA_INIT messages are completely unauthenticated. This 594 advice does not apply equally in case of TCP encapsulation. If the 595 Initiator receives a response message over TCP, then either this 596 message is genuine and was sent by the peer, or the TCP session was 597 hijacked and the message is forged. In this latter case, no genuine 598 messages from the Responder will be received. 600 Thus, in case of TCP encapsulation, an Initiator SHOULD NOT wait for 601 additional messages in case it receives error notification from the 602 Responder in the IKE_SA_INIT exchange. 604 If in the IKE_SA_INIT exchange the Responder returns an error 605 notification that implies a recovery action from the Initiator (such 606 as INVALID_KE_PAYLOAD or INVALID_MAJOR_VERSION, see Section 2.21.1 of 607 [RFC7296]) then the Responder SHOULD NOT close the TCP connection 608 immediately, in anticipation that the Initiator will repeat the 609 request with corrected parameters. See also Section 7.3. 611 7.5. NAT Detection Payloads 613 When negotiating over UDP port 500, IKE_SA_INIT packets include 614 NAT_DETECTION_SOURCE_IP and NAT_DETECTION_DESTINATION_IP payloads to 615 determine if UDP encapsulation of IPsec packets should be used. 616 These payloads contain SHA-1 digests of the SPIs, IP addresses, and 617 ports as defined in [RFC7296]. IKE_SA_INIT packets sent on a TCP 618 connection SHOULD include these payloads with the same content as 619 when sending over UDP and SHOULD use the applicable TCP ports when 620 creating and checking the SHA-1 digests. 622 If a NAT is detected due to the SHA-1 digests not matching the 623 expected values, no change should be made for encapsulation of 624 subsequent IKE or ESP packets, since TCP encapsulation inherently 625 supports NAT traversal. However, for the transport mode IPsec SAs, 626 implementations need to handle TCP and UDP packet checksum fixup 627 during decapsulation, as defined for UDP encapsulation in [RFC3948]. 628 Implementations MAY use the information that a NAT is present to 629 influence keep-alive timer values. 631 7.6. Keep-Alives and Dead Peer Detection 633 Encapsulating IKE and IPsec inside of a TCP connection can impact the 634 strategy that implementations use to detect peer liveness and to 635 maintain middlebox port mappings. Peer liveness should be checked 636 using IKE informational packets [RFC7296]. 638 In general, TCP port mappings are maintained by NATs longer than UDP 639 port mappings, so IPsec ESP NAT keep-alives [RFC3948] SHOULD NOT be 640 sent when using TCP encapsulation. Any implementation using TCP 641 encapsulation MUST silently drop incoming NAT keep-alive packets and 642 not treat them as errors. NAT keep-alive packets over a TCP- 643 encapsulated IPsec connection will be sent as an ESP message with a 644 one-octet-long payload with the value 0xFF. 646 Note that, depending on the configuration of TCP and TLS on the 647 connection, TCP keep-alives [RFC1122] and TLS keep-alives [RFC6520] 648 MAY be used. These MUST NOT be used as indications of IKE peer 649 liveness, for which purpose the standard IKEv2 mechanism of 650 exchanging empty INFORMATIONAL messages is used (see Section 1.4 of 651 [RFC7296]). 653 7.7. Implications of TCP Encapsulation on IPsec SA Processing 655 Using TCP encapsulation affects some aspects of IPsec SA processing. 657 1. Section 8.1 of [RFC4301] requires all tunnel mode IPsec SAs to be 658 able to copy the Don't Fragment (DF) bit from inner IP header to 659 the outer (tunnel) one. With TCP encapsulation this is generally 660 not possible, because TCP/IP stack manages DF bit in the outer IP 661 header, and usually the stack ensures that the DF bit is set for 662 TCP packets to avoid IP fragmentation. 664 2. The other feature that is less applicable with TCP encapsulation 665 is an ability to split traffic of different QoS classes into 666 different IPsec SAs, created by a single IKE SA. In this case 667 the Differentiated Services Code Point (DSCP) field is usually 668 copied from the inner IP header to the outer (tunnel) one, 669 ensuring that IPsec traffic of each SA receives the corresponding 670 level of service. With TCP encapsulation all IPsec SAs created 671 by a single IKE SA will share a single TCP connection and thus 672 will receive the same level of service (see Section 10.3). If 673 this functionality is needed, implementations should create 674 several IKE SAs each over separate TCP connection and assign a 675 corresponding DSCP value to each of them. 677 TCP encapsulation of IPsec packets may have implications on 678 performance of the encapsulated traffic. Performance considerations 679 are discussed in Section 10. 681 8. Interaction with IKEv2 Extensions 683 8.1. MOBIKE Protocol 685 The MOBIKE protocol, which allows SAs to migrate between IP 686 addresses, is defined in [RFC4555], and [RFC4621] further clarifies 687 the details of the protocol. When an IKE session that has negotiated 688 MOBIKE is transitioning between networks, the Initiator of the 689 transition may switch between using TCP encapsulation, UDP 690 encapsulation, or no encapsulation. Implementations that implement 691 both MOBIKE and TCP encapsulation within the same connection 692 configuration MUST support dynamically enabling and disabling TCP 693 encapsulation as interfaces change. 695 When a MOBIKE-enabled Initiator changes networks, the INFORMATIONAL 696 exchange with the UPDATE_SA_ADDRESSES notification SHOULD be 697 initiated first over UDP before attempting over TCP. If there is a 698 response to the request sent over UDP, then the ESP packets should be 699 sent directly over IP or over UDP port 4500 (depending on if a NAT 700 was detected), regardless of if a connection on a previous network 701 was using TCP encapsulation. If no response is received within a 702 certain period of time after several retransmissions, the Initiator 703 ought to change its transport for this exchange from UDP to TCP and 704 resend the request message. A new INFORMATIONAL exchange MUST NOT be 705 started in this situation. If the Responder only responds to the 706 request sent over TCP, then the ESP packets should be sent over the 707 TCP connection, regardless of if a connection on a previous network 708 did not use TCP encapsulation. 710 The value of the timeout and the specific number of retransmissions 711 before switching to TCP can vary depending on the Initiator's 712 configuration. Implementations ought to provide reasonable defaults 713 to ensure that UDP attempts have a chance to succeed, but can shorten 714 the timeout based on historical data or metrics. 716 If the TCP transport was used for the previous network connection, 717 the old TCP connection SHOULD be closed by the Initiator once MOBIKE 718 finishes migration to a new connection (either TCP or UDP). 720 Since switching from UDP to TCP can happen during a single 721 INFORMATIONAL message exchange, the content of the NAT_DETECTION_*_IP 722 notifications will in most cases be incorrect (since UDP and TCP 723 ports will most likely be different), and the peer may incorrectly 724 detect the presence of a NAT. Section 3.5 of [RFC4555] states that a 725 new INFORMATIONAL exchange with the UPDATE_SA_ADDRESSES notify is 726 initiated in case the address (or transport) is changed while waiting 727 for a response. 729 Section 3.5 of [RFC4555] also states that once an IKE SA is switched 730 to a new IP address, all outstanding requests in this SA are 731 immediately retransmitted using this address. See also Section 7.2. 733 The MOBIKE protocol defines the NO_NATS_ALLOWED notification that can 734 be used to detect the presence of NAT between peer and to refuse to 735 communicate in this situation. In case of TCP the NO_NATS_ALLOWED 736 notification SHOULD be ignored because TCP generally has no problems 737 with NAT boxes. 739 Section 3.7 of [RFC4555] describes an additional optional step in the 740 process of changing IP addresses called Return Routability Check. It 741 is performed by Responders in order to be sure that the new 742 initiator's address is in fact routable. In case of TCP 743 encapsulation this check has little value, since TCP handshake proves 744 routability of the TCP Originator's address. So, in case of TCP 745 encapsulation the Return Routability Check SHOULD NOT be performed. 747 8.2. IKE Redirect 749 A redirect mechanism for IKEv2 is defined in [RFC5685]. This 750 mechanism allows security gateways to redirect clients to another 751 gateway either during IKE SA establishment or after session setup. 752 If a client is connecting to a security gateway using TCP and then is 753 redirected to another security gateway, the client needs to reset its 754 transport selection. In other words, the client MUST again try first 755 UDP and then fall back to TCP while establishing a new IKE SA, 756 regardless of the transport of the SA the redirect notification was 757 received over (unless the client's configuration instructs it to 758 instantly use TCP for the gateway it is redirected to). 760 8.3. IKEv2 Session Resumption 762 Session resumption for IKEv2 is defined in [RFC5723]. Once an IKE SA 763 is established, the server creates a resumption ticket where 764 information about this SA is stored, and transfers this ticket to the 765 client. The ticket may be later used to resume the IKE SA after it 766 is deleted. In the event of resumption the client presents the 767 ticket in a new exchange, called IKE_SESSION_RESUME. Some parameters 768 in the new SA are retrieved from the ticket and others are re- 769 negotiated (more details are given in Section 5 of [RFC5723]). 771 Since network conditions may change while the client is inactive, the 772 fact that TCP encapsulation was used in an old SA SHOULD NOT affect 773 which transport is used during session resumption. In other words, 774 the transport should be selected as if the IKE SA is being created 775 from scratch. 777 8.4. IKEv2 Protocol Support for High Availability 779 [RFC6311] defines a support for High Availability in IKEv2. In case 780 of cluster failover, a new active node must immediately initiate a 781 special INFORMATION exchange containing the IKEV2_MESSAGE_ID_SYNC 782 notification, which instructs the client to skip some number of 783 Message IDs that might not be synchronized yet between nodes at the 784 time of failover. 786 Synchronizing states when using TCP encapsulation is much harder than 787 when using UDP; doing so requires access to TCP/IP stack internals, 788 which is not always available from an IKE/IPsec implementation. If a 789 cluster implementation doesn't synchronize TCP states between nodes, 790 then after failover event the new active node will not have any TCP 791 connection with the client, so the node cannot initiate the 792 INFORMATIONAL exchange as required by [RFC6311]. Since the cluster 793 usually acts as TCP Responder, the new active node cannot re- 794 establish TCP connection, since only the TCP Originator can do it. 796 For the client, the cluster failover event may remain undetected for 797 long time if it has no IKE or ESP traffic to send. Once the client 798 sends an ESP or IKEv2 packet, the cluster node will reply with TCP 799 RST and the client (as TCP Originator) will reestablish the TCP 800 connection so that the node will be able to initiate the 801 INFORMATIONAL exchange informing the client about the cluster 802 failover. 804 This document makes the following recommendation: if support for High 805 Availability in IKEv2 is negotiated and TCP transport is used, a 806 client that is a TCP Originator SHOULD periodically send IKEv2 807 messages (e.g. by initiating liveness check exchange) whenever there 808 is no IKEv2 or ESP traffic. This differs from the recommendations 809 given in Section 2.4 of [RFC7296] in the following: the liveness 810 check should be periodically performed even if the client has nothing 811 to send over ESP. The frequency of sending such messages should be 812 high enough to allow quick detection and restoring of broken TCP 813 connection. 815 8.5. IKEv2 Fragmentation 817 IKE message fragmentation [RFC7383] is not required when using TCP 818 encapsulation, since a TCP stream already handles the fragmentation 819 of its contents across packets. Since fragmentation is redundant in 820 this case, implementations might choose to not negotiate IKE 821 fragmentation. Even if fragmentation is negotiated, an 822 implementation SHOULD NOT send fragments when going over a TCP 823 connection, although it MUST support receiving fragments. 825 If an implementation supports both MOBIKE and IKE fragmentation, it 826 SHOULD negotiate IKE fragmentation over a TCP-encapsulated session in 827 case the session switches to UDP encapsulation on another network. 829 9. Middlebox Considerations 831 Many security networking devices, such as firewalls or intrusion 832 prevention systems, network optimization/acceleration devices, and 833 NAT devices, keep the state of sessions that traverse through them. 835 These devices commonly track the transport-layer and/or application- 836 layer data to drop traffic that is anomalous or malicious in nature. 837 While many of these devices will be more likely to pass TCP- 838 encapsulated traffic as opposed to UDP-encapsulated traffic, some may 839 still block or interfere with TCP-encapsulated IKE and IPsec traffic. 841 A network device that monitors the transport layer will track the 842 state of TCP sessions, such as TCP sequence numbers. TCP 843 encapsulation of IKE should therefore use standard TCP behaviors to 844 avoid being dropped by middleboxes. 846 10. Performance Considerations 848 Several aspects of TCP encapsulation for IKE and IPsec packets may 849 negatively impact the performance of connections within a tunnel-mode 850 IPsec SA. Implementations should be aware of these performance 851 impacts and take these into consideration when determining when to 852 use TCP encapsulation. Implementations SHOULD favor using direct ESP 853 or UDP encapsulation over TCP encapsulation whenever possible. 855 10.1. TCP-in-TCP 857 If the outer connection between IKE peers is over TCP, inner TCP 858 connections may suffer negative effects from using TCP within TCP. 859 Running TCP within TCP is discouraged, since the TCP algorithms 860 generally assume that they are running over an unreliable datagram 861 layer. 863 If the outer (tunnel) TCP connection experiences packet loss, this 864 loss will be hidden from any inner TCP connections, since the outer 865 connection will retransmit to account for the losses. Since the 866 outer TCP connection will deliver the inner messages in order, any 867 messages after a lost packet may have to wait until the loss is 868 recovered. This means that loss on the outer connection will be 869 interpreted only as delay by inner connections. The burstiness of 870 inner traffic can increase, since a large number of inner packets may 871 be delivered across the tunnel at once. The inner TCP connection may 872 interpret a long period of delay as a transmission problem, 873 triggering a retransmission timeout, which will cause spurious 874 retransmissions. The sending rate of the inner connection may be 875 unnecessarily reduced if the retransmissions are not detected as 876 spurious in time. 878 The inner TCP connection's round-trip-time estimation will be 879 affected by the burstiness of the outer TCP connection if there are 880 long delays when packets are retransmitted by the outer TCP 881 connection. This will make the congestion control loop of the inner 882 TCP traffic less reactive, potentially permanently leading to a lower 883 sending rate than the outer TCP would allow for. 885 TCP-in-TCP can also lead to increased buffering, or bufferbloat. 886 This can occur when the window size of the outer TCP connection is 887 reduced and becomes smaller than the window sizes of the inner TCP 888 connections. This can lead to packets backing up in the outer TCP 889 connection's send buffers. In order to limit this effect, the outer 890 TCP connection should have limits on its send buffer size and on the 891 rate at which it reduces its window size. 893 Note that any negative effects will be shared between all flows going 894 through the outer TCP connection. This is of particular concern for 895 any latency-sensitive or real-time applications using the tunnel. If 896 such traffic is using a TCP-encapsulated IPsec connection, it is 897 recommended that the number of inner connections sharing the tunnel 898 be limited as much as possible. 900 10.2. Added Reliability for Unreliable Protocols 902 Since ESP is an unreliable protocol, transmitting ESP packets over a 903 TCP connection will change the fundamental behavior of the packets. 904 Some application-level protocols that prefer packet loss to delay 905 (such as Voice over IP or other real-time protocols) may be 906 negatively impacted if their packets are retransmitted by the TCP 907 connection due to packet loss. 909 10.3. Quality-of-Service Markings 911 Quality-of-Service (QoS) markings, such as the Differentiated 912 Services Code Point (DSCP) and Traffic Class, should be used with 913 care on TCP connections used for encapsulation. Individual packets 914 SHOULD NOT use different markings than the rest of the connection, 915 since packets with different priorities may be routed differently and 916 cause unnecessary delays in the connection. 918 10.4. Maximum Segment Size 920 A TCP connection used for IKE encapsulation SHOULD negotiate its MSS 921 in order to avoid unnecessary fragmentation of packets. 923 10.5. Tunneling ECN in TCP 925 Since there is not a one-to-one relationship between outer IP packets 926 and inner ESP/IP messages when using TCP encapsulation, the markings 927 for Explicit Congestion Notification (ECN) [RFC3168] cannot be simply 928 mapped. However, any ECN Congestion Experienced (CE) marking on 929 inner headers should be preserved through the tunnel. 931 Implementations SHOULD follow the ECN compatibility mode for tunnel 932 ingress as described in [RFC6040]. In compatibility mode, the outer 933 tunnel TCP connection marks its packet headers as not ECN-capable. 934 If upon egress, the arriving outer header is marked with CE, the 935 implementation will drop the inner packet, since there is not a 936 distinct inner packet header onto which to translate the ECN 937 markings. 939 11. Security Considerations 941 IKE Responders that support TCP encapsulation may become vulnerable 942 to new Denial-of-Service (DoS) attacks that are specific to TCP, such 943 as SYN-flooding attacks. TCP Responders should be aware of this 944 additional attack surface. 946 TCP Responders should be careful to ensure that (1) the stream prefix 947 "IKETCP" uniquely identifies incoming streams as streams that use the 948 TCP encapsulation protocol and (2) they are not running any other 949 protocols on the same listening port (to avoid potential conflicts). 951 Attackers may be able to disrupt the TCP connection by sending 952 spurious TCP Reset packets. Therefore, implementations SHOULD make 953 sure that IKE session state persists even if the underlying TCP 954 connection is torn down. 956 If MOBIKE is being used, all of the security considerations outlined 957 for MOBIKE apply [RFC4555]. 959 Similarly to MOBIKE, TCP encapsulation requires a TCP Responder to 960 handle changes to source address and port due to network or 961 connection disruption. The successful delivery of valid IKE or ESP 962 messages over a new TCP connection is used by the TCP Responder to 963 determine where to send subsequent responses. If an attacker is able 964 to send packets on a new TCP connection that pass the validation 965 checks of the TCP Responder, it can influence which path future 966 packets will take. For this reason, the validation of messages on 967 the TCP Responder must include decryption, authentication, and replay 968 checks. 970 12. IANA Considerations 972 TCP port 4500 is already allocated to IPsec for NAT traversal. This 973 port SHOULD be used for TCP-encapsulated IKE and ESP as described in 974 this document. 976 This document updates the reference for TCP port 4500 from RFC 8229 977 to itself: 979 Keyword Decimal Description Reference 980 ----------- -------- ------------------- --------- 981 ipsec-nat-t 4500/tcp IPsec NAT-Traversal [RFCXXXX] 983 Figure 4 985 13. References 987 13.1. Normative References 989 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 990 Requirement Levels", BCP 14, RFC 2119, 991 DOI 10.17487/RFC2119, March 1997, 992 . 994 [RFC3948] Huttunen, A., Swander, B., Volpe, V., DiBurro, L., and M. 995 Stenberg, "UDP Encapsulation of IPsec ESP Packets", 996 RFC 3948, DOI 10.17487/RFC3948, January 2005, 997 . 999 [RFC4301] Kent, S. and K. Seo, "Security Architecture for the 1000 Internet Protocol", RFC 4301, DOI 10.17487/RFC4301, 1001 December 2005, . 1003 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 1004 RFC 4303, DOI 10.17487/RFC4303, December 2005, 1005 . 1007 [RFC6040] Briscoe, B., "Tunnelling of Explicit Congestion 1008 Notification", RFC 6040, DOI 10.17487/RFC6040, November 1009 2010, . 1011 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 1012 Kivinen, "Internet Key Exchange Protocol Version 2 1013 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 1014 2014, . 1016 [RFC8019] Nir, Y. and V. Smyslov, "Protecting Internet Key Exchange 1017 Protocol Version 2 (IKEv2) Implementations from 1018 Distributed Denial-of-Service Attacks", RFC 8019, 1019 DOI 10.17487/RFC8019, November 2016, 1020 . 1022 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1023 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1024 May 2017, . 1026 13.2. Informative References 1028 [I-D.ietf-ipsecme-ike-tcp] 1029 Nir, Y., "A TCP transport for the Internet Key Exchange", 1030 Work in Progress, Internet-Draft, draft-ietf-ipsecme-ike- 1031 tcp-01, 3 December 2012, . 1034 [I-D.ietf-uta-rfc7525bis] 1035 Sheffer, Y., Saint-Andre, P., and T. Fossati, 1036 "Recommendations for Secure Use of Transport Layer 1037 Security (TLS) and Datagram Transport Layer Security 1038 (DTLS)", Work in Progress, Internet-Draft, draft-ietf-uta- 1039 rfc7525bis-06, 24 March 2022, 1040 . 1043 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 1044 Communication Layers", STD 3, RFC 1122, 1045 DOI 10.17487/RFC1122, October 1989, 1046 . 1048 [RFC2817] Khare, R. and S. Lawrence, "Upgrading to TLS Within 1049 HTTP/1.1", RFC 2817, DOI 10.17487/RFC2817, May 2000, 1050 . 1052 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 1053 of Explicit Congestion Notification (ECN) to IP", 1054 RFC 3168, DOI 10.17487/RFC3168, September 2001, 1055 . 1057 [RFC4555] Eronen, P., "IKEv2 Mobility and Multihoming Protocol 1058 (MOBIKE)", RFC 4555, DOI 10.17487/RFC4555, June 2006, 1059 . 1061 [RFC4621] Kivinen, T. and H. Tschofenig, "Design of the IKEv2 1062 Mobility and Multihoming (MOBIKE) Protocol", RFC 4621, 1063 DOI 10.17487/RFC4621, August 2006, 1064 . 1066 [RFC4987] Eddy, W., "TCP SYN Flooding Attacks and Common 1067 Mitigations", RFC 4987, DOI 10.17487/RFC4987, August 2007, 1068 . 1070 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1071 (TLS) Protocol Version 1.2", RFC 5246, 1072 DOI 10.17487/RFC5246, August 2008, 1073 . 1075 [RFC5685] Devarapalli, V. and K. Weniger, "Redirect Mechanism for 1076 the Internet Key Exchange Protocol Version 2 (IKEv2)", 1077 RFC 5685, DOI 10.17487/RFC5685, November 2009, 1078 . 1080 [RFC5723] Sheffer, Y. and H. Tschofenig, "Internet Key Exchange 1081 Protocol Version 2 (IKEv2) Session Resumption", RFC 5723, 1082 DOI 10.17487/RFC5723, January 2010, 1083 . 1085 [RFC6311] Singh, R., Ed., Kalyani, G., Nir, Y., Sheffer, Y., and D. 1086 Zhang, "Protocol Support for High Availability of IKEv2/ 1087 IPsec", RFC 6311, DOI 10.17487/RFC6311, July 2011, 1088 . 1090 [RFC6520] Seggelmann, R., Tuexen, M., and M. Williams, "Transport 1091 Layer Security (TLS) and Datagram Transport Layer Security 1092 (DTLS) Heartbeat Extension", RFC 6520, 1093 DOI 10.17487/RFC6520, February 2012, 1094 . 1096 [RFC6528] Gont, F. and S. Bellovin, "Defending against Sequence 1097 Number Attacks", RFC 6528, DOI 10.17487/RFC6528, February 1098 2012, . 1100 [RFC7383] Smyslov, V., "Internet Key Exchange Protocol Version 2 1101 (IKEv2) Message Fragmentation", RFC 7383, 1102 DOI 10.17487/RFC7383, November 2014, 1103 . 1105 [RFC8229] Pauly, T., Touati, S., and R. Mantha, "TCP Encapsulation 1106 of IKE and IPsec Packets", RFC 8229, DOI 10.17487/RFC8229, 1107 August 2017, . 1109 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1110 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1111 . 1113 Appendix A. Using TCP Encapsulation with TLS 1115 This section provides recommendations on how to use TLS in addition 1116 to TCP encapsulation. 1118 When using TCP encapsulation, implementations may choose to use TLS 1119 1.2 [RFC5246] or TLS 1.3 [RFC8446] on the TCP connection to be able 1120 to traverse middleboxes, which may otherwise block the traffic. 1122 If a web proxy is applied to the ports used for the TCP connection 1123 and TLS is being used, the TCP Originator can send an HTTP CONNECT 1124 message to establish an SA through the proxy [RFC2817]. 1126 The use of TLS should be configurable on the peers, and may be used 1127 as the default when using TCP encapsulation or may be used as a 1128 fallback when basic TCP encapsulation fails. The TCP Responder may 1129 expect to read encapsulated IKE and ESP packets directly from the TCP 1130 connection, or it may expect to read them from a stream of TLS data 1131 packets. The TCP Originator should be pre-configured to use TLS or 1132 not when communicating with a given port on the TCP Responder. 1134 When new TCP connections are re-established due to a broken 1135 connection, TLS must be renegotiated. TLS session resumption is 1136 recommended to improve efficiency in this case. 1138 The security of the IKE session is entirely derived from the IKE 1139 negotiation and key establishment and not from the TLS session (which 1140 in this context is only used for encapsulation purposes); therefore, 1141 when TLS is used on the TCP connection, both the TCP Originator and 1142 the TCP Responder SHOULD allow the NULL cipher to be selected for 1143 performance reasons. Note, that TLS 1.3 only supports AEAD 1144 algorithms and at the time of writing this document there was no 1145 recommended cipher suite for TLS 1.3 with the NULL cipher. It is 1146 RECOMMENDED to follow [I-D.ietf-uta-rfc7525bis] when selecting 1147 parameters for TLS. 1149 Implementations should be aware that the use of TLS introduces 1150 another layer of overhead requiring more bytes to transmit a given 1151 IKE and IPsec packet. For this reason, direct ESP, UDP 1152 encapsulation, or TCP encapsulation without TLS should be preferred 1153 in situations in which TLS is not required in order to traverse 1154 middleboxes. 1156 Appendix B. Example Exchanges of TCP Encapsulation with TLS 1.3 1158 B.1. Establishing an IKE Session 1160 Client Server 1161 ---------- ---------- 1162 1) -------------------- TCP Connection ------------------- 1163 (IP_I:Port_I -> IP_R:Port_R) 1164 TcpSyn ----------> 1165 <---------- TcpSyn,Ack 1166 TcpAck ----------> 1168 2) --------------------- TLS Session --------------------- 1169 ClientHello ----------> 1170 ServerHello 1171 {EncryptedExtensions} 1172 {Certificate*} 1173 {CertificateVerify*} 1174 <---------- {Finished} 1175 {Finished} ----------> 1177 3) ---------------------- Stream Prefix -------------------- 1178 "IKETCP" ----------> 1179 4) ----------------------- IKE Session --------------------- 1180 Length + Non-ESP Marker ----------> 1181 IKE_SA_INIT 1182 HDR, SAi1, KEi, Ni, 1183 [N(NAT_DETECTION_SOURCE_IP)], 1184 [N(NAT_DETECTION_DESTINATION_IP)] 1185 <------ Length + Non-ESP Marker 1186 IKE_SA_INIT 1187 HDR, SAr1, KEr, Nr, 1188 [N(NAT_DETECTION_SOURCE_IP)], 1189 [N(NAT_DETECTION_DESTINATION_IP)] 1190 Length + Non-ESP Marker ----------> 1191 first IKE_AUTH 1192 HDR, SK {IDi, [CERTREQ] 1193 CP(CFG_REQUEST), IDr, 1194 SAi2, TSi, TSr, ...} 1195 <------ Length + Non-ESP Marker 1196 first IKE_AUTH 1197 HDR, SK {IDr, [CERT], AUTH, 1198 EAP, SAr2, TSi, TSr} 1200 Length + Non-ESP Marker ----------> 1201 IKE_AUTH + EAP 1202 repeat 1..N times 1203 <------ Length + Non-ESP Marker 1204 IKE_AUTH + EAP 1205 Length + Non-ESP Marker ----------> 1206 final IKE_AUTH 1207 HDR, SK {AUTH} 1208 <------ Length + Non-ESP Marker 1209 final IKE_AUTH 1210 HDR, SK {AUTH, CP(CFG_REPLY), 1211 SA, TSi, TSr, ...} 1212 -------------- IKE and IPsec SAs Established ------------ 1213 Length + ESP Frame ----------> 1215 Figure 5 1217 1. The client establishes a TCP connection with the server on port 1218 4500 or on an alternate pre-configured port that the server is 1219 listening on. 1221 2. If configured to use TLS, the client initiates a TLS handshake. 1222 During the TLS handshake, the server SHOULD NOT request the 1223 client's certificate, since authentication is handled as part of 1224 IKE negotiation. 1226 3. The client sends the stream prefix for TCP-encapsulated IKE 1227 (Section 5) traffic to signal the beginning of IKE negotiation. 1229 4. The client and server establish an IKE connection. This example 1230 shows EAP-based authentication, although any authentication type 1231 may be used. 1233 B.2. Deleting an IKE Session 1235 Client Server 1236 ---------- ---------- 1237 1) ----------------------- IKE Session --------------------- 1238 Length + Non-ESP Marker ----------> 1239 INFORMATIONAL 1240 HDR, SK {[N,] [D,] 1241 [CP,] ...} 1242 <------ Length + Non-ESP Marker 1243 INFORMATIONAL 1244 HDR, SK {[N,] [D,] 1245 [CP], ...} 1247 2) --------------------- TLS Session --------------------- 1248 close_notify ----------> 1249 <---------- close_notify 1250 3) -------------------- TCP Connection ------------------- 1251 TcpFin ----------> 1252 <---------- Ack 1253 <---------- TcpFin 1254 Ack ----------> 1255 -------------------- IKE SA Deleted ------------------- 1257 Figure 6 1259 1. The client and server exchange informational messages to notify 1260 IKE SA deletion. 1262 2. The client and server negotiate TLS session deletion using TLS 1263 CLOSE_NOTIFY. 1265 3. The TCP connection is torn down. 1267 The deletion of the IKE SA should lead to the disposal of the 1268 underlying TLS and TCP state. 1270 B.3. Re-establishing an IKE Session 1272 Client Server 1273 ---------- ---------- 1274 1) -------------------- TCP Connection ------------------- 1275 (IP_I:Port_I -> IP_R:Port_R) 1276 TcpSyn ----------> 1277 <---------- TcpSyn,Ack 1278 TcpAck ----------> 1279 2) --------------------- TLS Session --------------------- 1280 ClientHello ----------> 1281 ServerHello 1282 {EncryptedExtensions} 1283 <---------- {Finished} 1284 {Finished} ----------> 1285 3) ---------------------- Stream Prefix -------------------- 1286 "IKETCP" ----------> 1287 4) <---------------------> IKE/ESP Flow <------------------> 1289 Figure 7 1291 1. If a previous TCP connection was broken (for example, due to a 1292 TCP Reset), the client is responsible for re-initiating the TCP 1293 connection. The TCP Originator's address and port (IP_I and 1294 Port_I) may be different from the previous connection's address 1295 and port. 1297 2. The client SHOULD attempt TLS session resumption if it has 1298 previously established a session with the server. 1300 3. After TCP and TLS are complete, the client sends the stream 1301 prefix for TCP-encapsulated IKE traffic (Section 5). 1303 4. The IKE and ESP packet flow can resume. If MOBIKE is being used, 1304 the Initiator SHOULD send an UPDATE_SA_ADDRESSES message. 1306 B.4. Using MOBIKE between UDP and TCP Encapsulation 1307 Client Server 1308 ---------- ---------- 1309 (IP_I1:UDP500 -> IP_R:UDP500) 1310 1) ----------------- IKE_SA_INIT Exchange ----------------- 1311 (IP_I1:UDP4500 -> IP_R:UDP4500) 1312 Non-ESP Marker -----------> 1313 Initial IKE_AUTH 1314 HDR, SK { IDi, CERT, AUTH, 1315 CP(CFG_REQUEST), 1316 SAi2, TSi, TSr, 1317 N(MOBIKE_SUPPORTED) } 1318 <----------- Non-ESP Marker 1319 Initial IKE_AUTH 1320 HDR, SK { IDr, CERT, AUTH, 1321 EAP, SAr2, TSi, TSr, 1322 N(MOBIKE_SUPPORTED) } 1323 <------------------ IKE SA Establishment ---------------> 1325 2) ------------ MOBIKE Attempt on New Network -------------- 1326 (IP_I2:UDP4500 -> IP_R:UDP4500) 1327 Non-ESP Marker -----------> 1328 INFORMATIONAL 1329 HDR, SK { N(UPDATE_SA_ADDRESSES), 1330 N(NAT_DETECTION_SOURCE_IP), 1331 N(NAT_DETECTION_DESTINATION_IP) } 1333 3) -------------------- TCP Connection ------------------- 1334 (IP_I2:Port_I -> IP_R:Port_R) 1335 TcpSyn -----------> 1336 <----------- TcpSyn,Ack 1337 TcpAck -----------> 1339 4) --------------------- TLS Session --------------------- 1340 ClientHello ----------> 1341 ServerHello 1342 {EncryptedExtensions} 1343 {Certificate*} 1344 {CertificateVerify*} 1345 <---------- {Finished} 1346 {Finished} ----------> 1348 5) ---------------------- Stream Prefix -------------------- 1349 "IKETCP" ----------> 1351 6) ------------ Retransmit Message from step 2 ------------- 1352 Length + Non-ESP Marker -----------> 1353 INFORMATIONAL 1354 HDR, SK { N(UPDATE_SA_ADDRESSES), 1355 N(NAT_DETECTION_SOURCE_IP), 1356 N(NAT_DETECTION_DESTINATION_IP) } 1358 <------- Length + Non-ESP Marker 1359 HDR, SK { N(NAT_DETECTION_SOURCE_IP), 1360 N(NAT_DETECTION_DESTINATION_IP) } 1362 7) -- New Exchange with recalculated NAT_DETECTION_*_IP --- 1363 Length + Non-ESP Marker -----------> 1364 INFORMATIONAL 1365 HDR, SK { N(UPDATE_SA_ADDRESSES), 1366 N(NAT_DETECTION_SOURCE_IP), 1367 N(NAT_DETECTION_DESTINATION_IP) } 1369 <------- Length + Non-ESP Marker 1370 HDR, SK { N(NAT_DETECTION_SOURCE_IP), 1371 N(NAT_DETECTION_DESTINATION_IP) } 1373 8) <---------------------> IKE/ESP Flow <------------------> 1375 Figure 8 1377 1. During the IKE_SA_INIT exchange, the client and server exchange 1378 MOBIKE_SUPPORTED notify payloads to indicate support for MOBIKE. 1380 2. The client changes its point of attachment to the network and 1381 receives a new IP address. The client attempts to re-establish 1382 the IKE session using the UPDATE_SA_ADDRESSES notify payload, but 1383 the server does not respond because the network blocks UDP 1384 traffic. 1386 3. The client brings up a TCP connection to the server in order to 1387 use TCP encapsulation. 1389 4. The client initiates a TLS handshake with the server. 1391 5. The client sends the stream prefix for TCP-encapsulated IKE 1392 traffic (Section 5). 1394 6. The client sends the UPDATE_SA_ADDRESSES notify payload on the 1395 TCP-encapsulated connection. Note that this IKE message is the 1396 same as the one sent over UDP in step 2; it should have the same 1397 message ID and contents. 1399 7. Once the client receives a response on the TCP-encapsulated 1400 connection, it immediately starts a new INFORMATIONAL exchange 1401 with an UPDATE_SA_ADDRESSES notify payload and recalculated 1402 NAT_DETECTION_*_IP notify payloads in order to get correct 1403 information about the presence of NATs. 1405 8. The IKE and ESP packet flow can resume. 1407 Acknowledgments 1409 Thanks to the original authors of RFC 8229, Tommy Pauly, Samy Touati, 1410 and Ravi Mantha. Since this document updates and obsoletes RFC 8229, 1411 most of its text was borrowed from the original document. 1413 The following people provided valuable feedback and advices while 1414 preparing RFC8229: Stuart Cheshire, Delziel Fernandes, Yoav Nir, 1415 Christoph Paasch, Yaron Sheffer, David Schinazi, Graham Bartlett, 1416 Byju Pularikkal, March Wu, Kingwel Xie, Valery Smyslov, Jun Hu, and 1417 Tero Kivinen. Special thanks to Eric Kinnear for his implementation 1418 work. 1420 The authors would like to thank Tero Kivinen and Paul Wouters for 1421 their valuable comments while preparing this document. 1423 Authors' Addresses 1425 Tommy Pauly 1426 Apple Inc. 1427 1 Infinite Loop 1428 Cupertino, California 95014, 1429 United States of America 1430 Email: tpauly@apple.com 1432 Valery Smyslov 1433 ELVIS-PLUS 1434 PO Box 81 1435 Moscow (Zelenograd) 1436 124460 1437 Russian Federation 1438 Phone: +7 495 276 0211 1439 Email: svan@elvis.ru