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