idnits 2.17.00 (12 Aug 2021) /tmp/idnits58350/draft-ietf-ipsecme-rfc8229bis-04.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 (23 March 2022) is 59 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 974, but not defined == Missing Reference: 'CERTREQ' is mentioned on line 1172, but not defined == Missing Reference: 'CERT' is mentioned on line 1177, but not defined == Missing Reference: 'CP' is mentioned on line 1224, 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: 24 September 2022 23 March 2022 8 TCP Encapsulation of IKE and IPsec Packets 9 draft-ietf-ipsecme-rfc8229bis-04 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 24 September 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 . . . . . . . . . . . . . . . . . . . . . . 16 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 . . . . . . . . . . . . . . . . . . . . . . . . . 21 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 . . . . . . . . . . . . . . . . . 26 103 B.3. Re-establishing an IKE Session . . . . . . . . . . . . . 27 104 B.4. Using MOBIKE between UDP and TCP Encapsulation . . . . . 28 105 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 30 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 new Initiator's SPI and with recalculated content of 394 NAT_DETECTION_SOURCE_IP notification. 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 more 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. 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 request a Cookie, with the 543 exception of Puzzles or in rare cases like preventing TCP Sequence 544 Number attacks. 546 * if the Responder chooses to send Cookie request (possibly along 547 with Puzzle request), then the TCP connection that the IKE_SA_INIT 548 request message was received over SHOULD be closed after the 549 Responder sends its reply and no repeated requests are received 550 within some short period of time to keep the Responder stateless 551 (see Section 7.3.1). Note that the Responder MUST NOT include the 552 Initiator's TCP port into the Cookie calculation (*), since the 553 Cookie can be returned over a new TCP connection with a different 554 port. 556 * the exchange Initiator acts as described in Section 2.6 of 557 [RFC7296] and Section 7 of [RFC8019], i.e. using TCP encapsulation 558 doesn't change the Initiator's behavior. 560 (*) Examples of Cookie calculation methods are given in Section 2.6 561 of [RFC7296] and in Section 7.1.1.3 of [RFC8019] and they don't 562 include transport protocol ports. However these examples are given 563 for illustrative purposes, since Cookie generation algorithm is a 564 local matter and some implementations might include port numbers, 565 that won't work with TCP encapsulation. Note also that these 566 examples include the Initiator's IP address in Cookie calculation. 567 In general this address may change between two initial requests (with 568 and without Cookies). This may happen due to NATs, since NATs have 569 more freedom to change change source IP addresses for new TCP 570 connections than for UDP. In such cases cookie verification might 571 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 Besides, 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 If the TCP transport was used for the previous network connection, 711 the old TCP connection SHOULD be closed by the Initiator once MOBIKE 712 finishes migration to a new connection (either TCP or UDP). 714 Since switching from UDP to TCP can happen during a single 715 INFORMATIONAL message exchange, the content of the 716 NAT_DETECTION_SOURCE_IP notification will in most cases be incorrect 717 (since UDP and TCP source ports will most likely be different), and 718 the peer may incorrectly detect the presence of a NAT. Section 3.5 719 of [RFC4555] states that a new INFORMATIONAL exchange with the 720 UPDATE_SA_ADDRESSES notify is initiated in case the address (or 721 transport) is changed while waiting for a response. 723 Section 3.5 of [RFC4555] also states that once an IKE SA is switched 724 to a new IP address, all outstanding requests in this SA are 725 immediately retransmitted using this address. See also Section 7.2. 727 The MOBIKE protocol defines the NO_NATS_ALLOWED notification that can 728 be used to detect the presence of NAT between peer and to refuse to 729 communicate in this situation. In case of TCP the NO_NATS_ALLOWED 730 notification SHOULD be ignored because TCP generally has no problems 731 with NAT boxes. 733 Section 3.7 of [RFC4555] describes an additional optional step in the 734 process of changing IP addresses called Return Routability Check. It 735 is performed by Responders in order to be sure that the new 736 initiator's address is in fact routable. In case of TCP 737 encapsulation this check has little value, since TCP handshake proves 738 routability of the TCP Originator's address. So, in case of TCP 739 encapsulation the Return Routability Check SHOULD NOT be performed. 741 8.2. IKE Redirect 743 A redirect mechanism for IKEv2 is defined in [RFC5685]. This 744 mechanism allows security gateways to redirect clients to another 745 gateway either during IKE SA establishment or after session setup. 746 If a client is connecting to a security gateway using TCP and then is 747 redirected to another security gateway, the client needs to reset its 748 transport selection. In other words, the client MUST again try first 749 UDP and then fall back to TCP while establishing a new IKE SA, 750 regardless of the transport of the SA the redirect notification was 751 received over (unless the client's configuration instructs it to 752 instantly use TCP for the gateway it is redirected to). 754 8.3. IKEv2 Session Resumption 756 Session resumption for IKEv2 is defined in [RFC5723]. Once an IKE SA 757 is established, the server creates a resumption ticket where 758 information about this SA is stored, and transfers this ticket to the 759 client. The ticket may be later used to resume the IKE SA after it 760 is deleted. In the event of resumption the client presents the 761 ticket in a new exchange, called IKE_SESSION_RESUME. Some parameters 762 in the new SA are retrieved from the ticket and others are re- 763 negotiated (more details are given in Section 5 of [RFC5723]). 765 Since network conditions may change while the client is incative, the 766 fact that TCP encapsulation was used in an old SA SHOULD NOT affect 767 which transport is used during session resumption. In other words, 768 the transport should be selected as if the IKE SA is being created 769 from scratch. 771 8.4. IKEv2 Protocol Support for High Availability 773 [RFC6311] defines a support for High Availability in IKEv2. In case 774 of cluster failover, a new active node must immediately initiate a 775 special INFORMATION exchange containing the IKEV2_MESSAGE_ID_SYNC 776 notification, which instructs the client to skip some number of 777 Message IDs that might not be synchronized yet between nodes at the 778 time of failover. 780 Synchronizing states when using TCP encapsulation is much harder than 781 when using UDP; doing so requires access to TCP/IP stack internals, 782 which is not always available from an IKE/IPsec implementation. If a 783 cluster implementation doesn't synchronize TCP states between nodes, 784 then after failover event the new active node will not have any TCP 785 connection with the client, so the node cannot initiate the 786 INFORMATIONAL exchange as required by [RFC6311]. Since the cluster 787 usually acts as TCP Responder, the new active node cannot re- 788 establish TCP connection, since only the TCP Originator can do it. 789 For the client, the cluster failover event may remain undetected for 790 long time if it has no IKE or ESP traffic to send. Once the client 791 sends an ESP or IKEv2 packet, the cluster node will reply with TCP 792 RST and the client (as TCP Originator) will reestablish the TCP 793 connection so that the node will be able to initiate the 794 INFORMATIONAL exchange informing the client about the cluster 795 failover. 797 This document makes the following recommendation: if support for High 798 Availability in IKEv2 is negotiated and TCP transport is used, a 799 client that is a TCP Originator SHOULD periodically send IKEv2 800 messages (e.g. by initiating liveness check exchange) whenever there 801 is no IKEv2 or ESP traffic. This differs from the recommendations 802 given in Section 2.4 of [RFC7296] in the following: the liveness 803 check should be periodically performed even if the client has nothing 804 to send over ESP. The frequency of sending such messages should be 805 high enough to allow quick detection and restoring of broken TCP 806 connection. 808 8.5. IKEv2 Fragmentation 810 IKE message fragmentation [RFC7383] is not required when using TCP 811 encapsulation, since a TCP stream already handles the fragmentation 812 of its contents across packets. Since fragmentation is redundant in 813 this case, implementations might choose to not negotiate IKE 814 fragmentation. Even if fragmentation is negotiated, an 815 implementation SHOULD NOT send fragments when going over a TCP 816 connection, although it MUST support receiving fragments. 818 If an implementation supports both MOBIKE and IKE fragmentation, it 819 SHOULD negotiate IKE fragmentation over a TCP-encapsulated session in 820 case the session switches to UDP encapsulation on another network. 822 9. Middlebox Considerations 824 Many security networking devices, such as firewalls or intrusion 825 prevention systems, network optimization/acceleration devices, and 826 NAT devices, keep the state of sessions that traverse through them. 828 These devices commonly track the transport-layer and/or application- 829 layer data to drop traffic that is anomalous or malicious in nature. 830 While many of these devices will be more likely to pass TCP- 831 encapsulated traffic as opposed to UDP-encapsulated traffic, some may 832 still block or interfere with TCP-encapsulated IKE and IPsec traffic. 834 A network device that monitors the transport layer will track the 835 state of TCP sessions, such as TCP sequence numbers. TCP 836 encapsulation of IKE should therefore use standard TCP behaviors to 837 avoid being dropped by middleboxes. 839 10. Performance Considerations 841 Several aspects of TCP encapsulation for IKE and IPsec packets may 842 negatively impact the performance of connections within a tunnel-mode 843 IPsec SA. Implementations should be aware of these performance 844 impacts and take these into consideration when determining when to 845 use TCP encapsulation. Implementations SHOULD favor using direct ESP 846 or UDP encapsulation over TCP encapsulation whenever possible. 848 10.1. TCP-in-TCP 850 If the outer connection between IKE peers is over TCP, inner TCP 851 connections may suffer negative effects from using TCP within TCP. 852 Running TCP within TCP is discouraged, since the TCP algorithms 853 generally assume that they are running over an unreliable datagram 854 layer. 856 If the outer (tunnel) TCP connection experiences packet loss, this 857 loss will be hidden from any inner TCP connections, since the outer 858 connection will retransmit to account for the losses. Since the 859 outer TCP connection will deliver the inner messages in order, any 860 messages after a lost packet may have to wait until the loss is 861 recovered. This means that loss on the outer connection will be 862 interpreted only as delay by inner connections. The burstiness of 863 inner traffic can increase, since a large number of inner packets may 864 be delivered across the tunnel at once. The inner TCP connection may 865 interpret a long period of delay as a transmission problem, 866 triggering a retransmission timeout, which will cause spurious 867 retransmissions. The sending rate of the inner connection may be 868 unnecessarily reduced if the retransmissions are not detected as 869 spurious in time. 871 The inner TCP connection's round-trip-time estimation will be 872 affected by the burstiness of the outer TCP connection if there are 873 long delays when packets are retransmitted by the outer TCP 874 connection. This will make the congestion control loop of the inner 875 TCP traffic less reactive, potentially permanently leading to a lower 876 sending rate than the outer TCP would allow for. 878 TCP-in-TCP can also lead to increased buffering, or bufferbloat. 879 This can occur when the window size of the outer TCP connection is 880 reduced and becomes smaller than the window sizes of the inner TCP 881 connections. This can lead to packets backing up in the outer TCP 882 connection's send buffers. In order to limit this effect, the outer 883 TCP connection should have limits on its send buffer size and on the 884 rate at which it reduces its window size. 886 Note that any negative effects will be shared between all flows going 887 through the outer TCP connection. This is of particular concern for 888 any latency-sensitive or real-time applications using the tunnel. If 889 such traffic is using a TCP-encapsulated IPsec connection, it is 890 recommended that the number of inner connections sharing the tunnel 891 be limited as much as possible. 893 10.2. Added Reliability for Unreliable Protocols 895 Since ESP is an unreliable protocol, transmitting ESP packets over a 896 TCP connection will change the fundamental behavior of the packets. 897 Some application-level protocols that prefer packet loss to delay 898 (such as Voice over IP or other real-time protocols) may be 899 negatively impacted if their packets are retransmitted by the TCP 900 connection due to packet loss. 902 10.3. Quality-of-Service Markings 904 Quality-of-Service (QoS) markings, such as the Differentiated 905 Services Code Point (DSCP) and Traffic Class, should be used with 906 care on TCP connections used for encapsulation. Individual packets 907 SHOULD NOT use different markings than the rest of the connection, 908 since packets with different priorities may be routed differently and 909 cause unnecessary delays in the connection. 911 10.4. Maximum Segment Size 913 A TCP connection used for IKE encapsulation SHOULD negotiate its MSS 914 in order to avoid unnecessary fragmentation of packets. 916 10.5. Tunneling ECN in TCP 918 Since there is not a one-to-one relationship between outer IP packets 919 and inner ESP/IP messages when using TCP encapsulation, the markings 920 for Explicit Congestion Notification (ECN) [RFC3168] cannot be simply 921 mapped. However, any ECN Congestion Experienced (CE) marking on 922 inner headers should be preserved through the tunnel. 924 Implementations SHOULD follow the ECN compatibility mode for tunnel 925 ingress as described in [RFC6040]. In compatibility mode, the outer 926 tunnel TCP connection marks its packet headers as not ECN-capable. 927 If upon egress, the arriving outer header is marked with CE, the 928 implementation will drop the inner packet, since there is not a 929 distinct inner packet header onto which to translate the ECN 930 markings. 932 11. Security Considerations 934 IKE Responders that support TCP encapsulation may become vulnerable 935 to new Denial-of-Service (DoS) attacks that are specific to TCP, such 936 as SYN-flooding attacks. TCP Responders should be aware of this 937 additional attack surface. 939 TCP Responders should be careful to ensure that (1) the stream prefix 940 "IKETCP" uniquely identifies incoming streams as streams that use the 941 TCP encapsulation protocol and (2) they are not running any other 942 protocols on the same listening port (to avoid potential conflicts). 944 Attackers may be able to disrupt the TCP connection by sending 945 spurious TCP Reset packets. Therefore, implementations SHOULD make 946 sure that IKE session state persists even if the underlying TCP 947 connection is torn down. 949 If MOBIKE is being used, all of the security considerations outlined 950 for MOBIKE apply [RFC4555]. 952 Similarly to MOBIKE, TCP encapsulation requires a TCP Responder to 953 handle changes to source address and port due to network or 954 connection disruption. The successful delivery of valid IKE or ESP 955 messages over a new TCP connection is used by the TCP Responder to 956 determine where to send subsequent responses. If an attacker is able 957 to send packets on a new TCP connection that pass the validation 958 checks of the TCP Responder, it can influence which path future 959 packets will take. For this reason, the validation of messages on 960 the TCP Responder must include decryption, authentication, and replay 961 checks. 963 12. IANA Considerations 965 TCP port 4500 is already allocated to IPsec for NAT traversal. This 966 port SHOULD be used for TCP-encapsulated IKE and ESP as described in 967 this document. 969 This document updates the reference for TCP port 4500 from RFC 8229 970 to itself: 972 Keyword Decimal Description Reference 973 ----------- -------- ------------------- --------- 974 ipsec-nat-t 4500/tcp IPsec NAT-Traversal [RFCXXXX] 976 Figure 4 978 13. References 979 13.1. Normative References 981 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 982 Requirement Levels", BCP 14, RFC 2119, 983 DOI 10.17487/RFC2119, March 1997, 984 . 986 [RFC3948] Huttunen, A., Swander, B., Volpe, V., DiBurro, L., and M. 987 Stenberg, "UDP Encapsulation of IPsec ESP Packets", 988 RFC 3948, DOI 10.17487/RFC3948, January 2005, 989 . 991 [RFC4301] Kent, S. and K. Seo, "Security Architecture for the 992 Internet Protocol", RFC 4301, DOI 10.17487/RFC4301, 993 December 2005, . 995 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 996 RFC 4303, DOI 10.17487/RFC4303, December 2005, 997 . 999 [RFC6040] Briscoe, B., "Tunnelling of Explicit Congestion 1000 Notification", RFC 6040, DOI 10.17487/RFC6040, November 1001 2010, . 1003 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 1004 Kivinen, "Internet Key Exchange Protocol Version 2 1005 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 1006 2014, . 1008 [RFC8019] Nir, Y. and V. Smyslov, "Protecting Internet Key Exchange 1009 Protocol Version 2 (IKEv2) Implementations from 1010 Distributed Denial-of-Service Attacks", RFC 8019, 1011 DOI 10.17487/RFC8019, November 2016, 1012 . 1014 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1015 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1016 May 2017, . 1018 13.2. Informative References 1020 [I-D.ietf-ipsecme-ike-tcp] 1021 Nir, Y., "A TCP transport for the Internet Key Exchange", 1022 Work in Progress, Internet-Draft, draft-ietf-ipsecme-ike- 1023 tcp-01, 3 December 2012, . 1026 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 1027 Communication Layers", STD 3, RFC 1122, 1028 DOI 10.17487/RFC1122, October 1989, 1029 . 1031 [RFC2817] Khare, R. and S. Lawrence, "Upgrading to TLS Within 1032 HTTP/1.1", RFC 2817, DOI 10.17487/RFC2817, May 2000, 1033 . 1035 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 1036 of Explicit Congestion Notification (ECN) to IP", 1037 RFC 3168, DOI 10.17487/RFC3168, September 2001, 1038 . 1040 [RFC4555] Eronen, P., "IKEv2 Mobility and Multihoming Protocol 1041 (MOBIKE)", RFC 4555, DOI 10.17487/RFC4555, June 2006, 1042 . 1044 [RFC4621] Kivinen, T. and H. Tschofenig, "Design of the IKEv2 1045 Mobility and Multihoming (MOBIKE) Protocol", RFC 4621, 1046 DOI 10.17487/RFC4621, August 2006, 1047 . 1049 [RFC4987] Eddy, W., "TCP SYN Flooding Attacks and Common 1050 Mitigations", RFC 4987, DOI 10.17487/RFC4987, August 2007, 1051 . 1053 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1054 (TLS) Protocol Version 1.2", RFC 5246, 1055 DOI 10.17487/RFC5246, August 2008, 1056 . 1058 [RFC5685] Devarapalli, V. and K. Weniger, "Redirect Mechanism for 1059 the Internet Key Exchange Protocol Version 2 (IKEv2)", 1060 RFC 5685, DOI 10.17487/RFC5685, November 2009, 1061 . 1063 [RFC5723] Sheffer, Y. and H. Tschofenig, "Internet Key Exchange 1064 Protocol Version 2 (IKEv2) Session Resumption", RFC 5723, 1065 DOI 10.17487/RFC5723, January 2010, 1066 . 1068 [RFC6311] Singh, R., Ed., Kalyani, G., Nir, Y., Sheffer, Y., and D. 1069 Zhang, "Protocol Support for High Availability of IKEv2/ 1070 IPsec", RFC 6311, DOI 10.17487/RFC6311, July 2011, 1071 . 1073 [RFC6520] Seggelmann, R., Tuexen, M., and M. Williams, "Transport 1074 Layer Security (TLS) and Datagram Transport Layer Security 1075 (DTLS) Heartbeat Extension", RFC 6520, 1076 DOI 10.17487/RFC6520, February 2012, 1077 . 1079 [RFC6528] Gont, F. and S. Bellovin, "Defending against Sequence 1080 Number Attacks", RFC 6528, DOI 10.17487/RFC6528, February 1081 2012, . 1083 [RFC7383] Smyslov, V., "Internet Key Exchange Protocol Version 2 1084 (IKEv2) Message Fragmentation", RFC 7383, 1085 DOI 10.17487/RFC7383, November 2014, 1086 . 1088 [RFC8229] Pauly, T., Touati, S., and R. Mantha, "TCP Encapsulation 1089 of IKE and IPsec Packets", RFC 8229, DOI 10.17487/RFC8229, 1090 August 2017, . 1092 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1093 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1094 . 1096 Appendix A. Using TCP Encapsulation with TLS 1098 This section provides recommendations on how to use TLS in addition 1099 to TCP encapsulation. 1101 When using TCP encapsulation, implementations may choose to use TLS 1102 1.2 [RFC5246] or TLS 1.3 [RFC8446] on the TCP connection to be able 1103 to traverse middleboxes, which may otherwise block the traffic. 1105 If a web proxy is applied to the ports used for the TCP connection 1106 and TLS is being used, the TCP Originator can send an HTTP CONNECT 1107 message to establish an SA through the proxy [RFC2817]. 1109 The use of TLS should be configurable on the peers, and may be used 1110 as the default when using TCP encapsulation or may be used as a 1111 fallback when basic TCP encapsulation fails. The TCP Responder may 1112 expect to read encapsulated IKE and ESP packets directly from the TCP 1113 connection, or it may expect to read them from a stream of TLS data 1114 packets. The TCP Originator should be pre-configured to use TLS or 1115 not when communicating with a given port on the TCP Responder. 1117 When new TCP connections are re-established due to a broken 1118 connection, TLS must be renegotiated. TLS session resumption is 1119 recommended to improve efficiency in this case. 1121 The security of the IKE session is entirely derived from the IKE 1122 negotiation and key establishment and not from the TLS session (which 1123 in this context is only used for encapsulation purposes); therefore, 1124 when TLS is used on the TCP connection, both the TCP Originator and 1125 the TCP Responder SHOULD allow the NULL cipher to be selected for 1126 performance reasons. Note, that TLS 1.3 only supports AEAD 1127 algorithms and at the time of writing this document there was no 1128 recommended cipher suite for TLS 1.3 with the NULL cipher. 1130 Implementations should be aware that the use of TLS introduces 1131 another layer of overhead requiring more bytes to transmit a given 1132 IKE and IPsec packet. For this reason, direct ESP, UDP 1133 encapsulation, or TCP encapsulation without TLS should be preferred 1134 in situations in which TLS is not required in order to traverse 1135 middleboxes. 1137 Appendix B. Example Exchanges of TCP Encapsulation with TLS 1.3 1139 B.1. Establishing an IKE Session 1141 Client Server 1142 ---------- ---------- 1143 1) -------------------- TCP Connection ------------------- 1144 (IP_I:Port_I -> IP_R:Port_R) 1145 TcpSyn ----------> 1146 <---------- TcpSyn,Ack 1147 TcpAck ----------> 1149 2) --------------------- TLS Session --------------------- 1150 ClientHello ----------> 1151 ServerHello 1152 {EncryptedExtensions} 1153 {Certificate*} 1154 {CertificateVerify*} 1155 <---------- {Finished} 1156 {Finished} ----------> 1158 3) ---------------------- Stream Prefix -------------------- 1159 "IKETCP" ----------> 1160 4) ----------------------- IKE Session --------------------- 1161 Length + Non-ESP Marker ----------> 1162 IKE_SA_INIT 1163 HDR, SAi1, KEi, Ni, 1164 [N(NAT_DETECTION_*_IP)] 1165 <------ Length + Non-ESP Marker 1166 IKE_SA_INIT 1167 HDR, SAr1, KEr, Nr, 1168 [N(NAT_DETECTION_*_IP)] 1170 Length + Non-ESP Marker ----------> 1171 first IKE_AUTH 1172 HDR, SK {IDi, [CERTREQ] 1173 CP(CFG_REQUEST), IDr, 1174 SAi2, TSi, TSr, ...} 1175 <------ Length + Non-ESP Marker 1176 first IKE_AUTH 1177 HDR, SK {IDr, [CERT], AUTH, 1178 EAP, SAr2, TSi, TSr} 1180 Length + Non-ESP Marker ----------> 1181 IKE_AUTH + EAP 1182 repeat 1..N times 1183 <------ Length + Non-ESP Marker 1184 IKE_AUTH + EAP 1185 Length + Non-ESP Marker ----------> 1186 final IKE_AUTH 1187 HDR, SK {AUTH} 1188 <------ Length + Non-ESP Marker 1189 final IKE_AUTH 1190 HDR, SK {AUTH, CP(CFG_REPLY), 1191 SA, TSi, TSr, ...} 1192 -------------- IKE and IPsec SAs Established ------------ 1193 Length + ESP Frame ----------> 1195 Figure 5 1197 1. The client establishes a TCP connection with the server on port 1198 4500 or on an alternate pre-configured port that the server is 1199 listening on. 1201 2. If configured to use TLS, the client initiates a TLS handshake. 1202 During the TLS handshake, the server SHOULD NOT request the 1203 client's certificate, since authentication is handled as part of 1204 IKE negotiation. 1206 3. The client sends the stream prefix for TCP-encapsulated IKE 1207 (Section 5) traffic to signal the beginning of IKE negotiation. 1209 4. The client and server establish an IKE connection. This example 1210 shows EAP-based authentication, although any authentication type 1211 may be used. 1213 B.2. Deleting an IKE Session 1214 Client Server 1215 ---------- ---------- 1216 1) ----------------------- IKE Session --------------------- 1217 Length + Non-ESP Marker ----------> 1218 INFORMATIONAL 1219 HDR, SK {[N,] [D,] 1220 [CP,] ...} 1221 <------ Length + Non-ESP Marker 1222 INFORMATIONAL 1223 HDR, SK {[N,] [D,] 1224 [CP], ...} 1226 2) --------------------- TLS Session --------------------- 1227 close_notify ----------> 1228 <---------- close_notify 1229 3) -------------------- TCP Connection ------------------- 1230 TcpFin ----------> 1231 <---------- Ack 1232 <---------- TcpFin 1233 Ack ----------> 1234 -------------------- IKE SA Deleted ------------------- 1236 Figure 6 1238 1. The client and server exchange informational messages to notify 1239 IKE SA deletion. 1241 2. The client and server negotiate TLS session deletion using TLS 1242 CLOSE_NOTIFY. 1244 3. The TCP connection is torn down. 1246 The deletion of the IKE SA should lead to the disposal of the 1247 underlying TLS and TCP state. 1249 B.3. Re-establishing an IKE Session 1250 Client Server 1251 ---------- ---------- 1252 1) -------------------- TCP Connection ------------------- 1253 (IP_I:Port_I -> IP_R:Port_R) 1254 TcpSyn ----------> 1255 <---------- TcpSyn,Ack 1256 TcpAck ----------> 1257 2) --------------------- TLS Session --------------------- 1258 ClientHello ----------> 1259 ServerHello 1260 {EncryptedExtensions} 1261 <---------- {Finished} 1262 {Finished} ----------> 1263 3) ---------------------- Stream Prefix -------------------- 1264 "IKETCP" ----------> 1265 4) <---------------------> IKE/ESP Flow <------------------> 1267 Figure 7 1269 1. If a previous TCP connection was broken (for example, due to a 1270 TCP Reset), the client is responsible for re-initiating the TCP 1271 connection. The TCP Originator's address and port (IP_I and 1272 Port_I) may be different from the previous connection's address 1273 and port. 1275 2. The client SHOULD attempt TLS session resumption if it has 1276 previously established a session with the server. 1278 3. After TCP and TLS are complete, the client sends the stream 1279 prefix for TCP-encapsulated IKE traffic (Section 5). 1281 4. The IKE and ESP packet flow can resume. If MOBIKE is being used, 1282 the Initiator SHOULD send an UPDATE_SA_ADDRESSES message. 1284 B.4. Using MOBIKE between UDP and TCP Encapsulation 1286 Client Server 1287 ---------- ---------- 1288 (IP_I1:UDP500 -> IP_R:UDP500) 1289 1) ----------------- IKE_SA_INIT Exchange ----------------- 1290 (IP_I1:UDP4500 -> IP_R:UDP4500) 1291 Non-ESP Marker -----------> 1292 Initial IKE_AUTH 1293 HDR, SK { IDi, CERT, AUTH, 1294 CP(CFG_REQUEST), 1295 SAi2, TSi, TSr, 1296 N(MOBIKE_SUPPORTED) } 1297 <----------- Non-ESP Marker 1298 Initial IKE_AUTH 1299 HDR, SK { IDr, CERT, AUTH, 1300 EAP, SAr2, TSi, TSr, 1301 N(MOBIKE_SUPPORTED) } 1302 <------------------ IKE SA Establishment ---------------> 1304 2) ------------ MOBIKE Attempt on New Network -------------- 1305 (IP_I2:UDP4500 -> IP_R:UDP4500) 1306 Non-ESP Marker -----------> 1307 INFORMATIONAL 1308 HDR, SK { N(UPDATE_SA_ADDRESSES), 1309 N(NAT_DETECTION_SOURCE_IP), 1310 N(NAT_DETECTION_DESTINATION_IP) } 1312 3) -------------------- TCP Connection ------------------- 1313 (IP_I2:Port_I -> IP_R:Port_R) 1314 TcpSyn -----------> 1315 <----------- TcpSyn,Ack 1316 TcpAck -----------> 1318 4) --------------------- TLS Session --------------------- 1319 ClientHello ----------> 1320 ServerHello 1321 {EncryptedExtensions} 1322 {Certificate*} 1323 {CertificateVerify*} 1324 <---------- {Finished} 1325 {Finished} ----------> 1327 5) ---------------------- Stream Prefix -------------------- 1328 "IKETCP" ----------> 1330 6) ------------ Retransmit Message from step 2 ------------- 1331 Length + Non-ESP Marker -----------> 1332 INFORMATIONAL 1333 HDR, SK { N(UPDATE_SA_ADDRESSES), 1334 N(NAT_DETECTION_SOURCE_IP), 1335 N(NAT_DETECTION_DESTINATION_IP) } 1337 <------- Length + Non-ESP Marker 1338 HDR, SK { N(NAT_DETECTION_SOURCE_IP), 1339 N(NAT_DETECTION_DESTINATION_IP) } 1341 7) ---- New Exchange with recalculated NAT_DETECTION_* ---- 1342 Length + Non-ESP Marker -----------> 1343 INFORMATIONAL 1344 HDR, SK { N(UPDATE_SA_ADDRESSES), 1345 N(NAT_DETECTION_SOURCE_IP), 1346 N(NAT_DETECTION_DESTINATION_IP) } 1348 <------- Length + Non-ESP Marker 1349 HDR, SK { N(NAT_DETECTION_SOURCE_IP), 1350 N(NAT_DETECTION_DESTINATION_IP) } 1352 8) <---------------------> IKE/ESP Flow <------------------> 1354 Figure 8 1356 1. During the IKE_SA_INIT exchange, the client and server exchange 1357 MOBIKE_SUPPORTED notify payloads to indicate support for MOBIKE. 1359 2. The client changes its point of attachment to the network and 1360 receives a new IP address. The client attempts to re-establish 1361 the IKE session using the UPDATE_SA_ADDRESSES notify payload, but 1362 the server does not respond because the network blocks UDP 1363 traffic. 1365 3. The client brings up a TCP connection to the server in order to 1366 use TCP encapsulation. 1368 4. The client initiates a TLS handshake with the server. 1370 5. The client sends the stream prefix for TCP-encapsulated IKE 1371 traffic (Section 5). 1373 6. The client sends the UPDATE_SA_ADDRESSES notify payload on the 1374 TCP-encapsulated connection. Note that this IKE message is the 1375 same as the one sent over UDP in step 2; it should have the same 1376 message ID and contents. 1378 7. Once the client receives a response on the TCP-encapsulated 1379 connection, it immediately starts a new INFORMATIONAL exchange 1380 with an UPDATE_SA_ADDRESSES notify payload and a recalculated 1381 NAT_DETECTION_SOURCE_IP notify payload in order to get correct 1382 information about the presence of NATs. 1384 8. The IKE and ESP packet flow can resume. 1386 Acknowledgments 1388 Thanks to the original authors of RFC 8229, Tommy Pauly, Samy Touati, 1389 and Ravi Mantha. Since this document updates and obsoletes RFC 8229, 1390 most of its text was borrowed from the original document. 1392 The following people provided valuable feedback and advices while 1393 preparing RFC8229: Stuart Cheshire, Delziel Fernandes, Yoav Nir, 1394 Christoph Paasch, Yaron Sheffer, David Schinazi, Graham Bartlett, 1395 Byju Pularikkal, March Wu, Kingwel Xie, Valery Smyslov, Jun Hu, and 1396 Tero Kivinen. Special thanks to Eric Kinnear for his implementation 1397 work. 1399 The authors would like to thank Tero Kivinen and Paul Wouters for 1400 their valuable comments while preparing this document. 1402 Authors' Addresses 1404 Valery Smyslov 1405 ELVIS-PLUS 1406 PO Box 81 1407 Moscow (Zelenograd) 1408 124460 1409 Russian Federation 1410 Phone: +7 495 276 0211 1411 Email: svan@elvis.ru 1413 Tommy Pauly 1414 Apple Inc. 1415 1 Infinite Loop 1416 Cupertino, California 95014, 1417 United States of America 1418 Email: tpauly@apple.com