idnits 2.17.1 draft-smyslov-ipsecme-rfc8229bis-01.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 : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([RFC8229]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. -- The draft header indicates that this document obsoletes RFC8229, but the abstract doesn't seem to directly say this. It does mention RFC8229 though, so this could be OK. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (May 15, 2020) is 1436 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 928, but not defined == Missing Reference: 'ChangeCipherSpec' is mentioned on line 1290, but not defined == Missing Reference: 'CERTREQ' is mentioned on line 1129, but not defined == Missing Reference: 'CERT' is mentioned on line 1134, but not defined == Missing Reference: 'CP' is mentioned on line 1181, but not defined -- Obsolete informational reference (is this intentional?): RFC 5246 (Obsoleted by RFC 8446) -- Obsolete informational reference (is this intentional?): RFC 6528 (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 8229 (Obsoleted by RFC 9329) Summary: 1 error (**), 0 flaws (~~), 6 warnings (==), 5 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: November 16, 2020 May 15, 2020 8 TCP Encapsulation of IKE and IPsec Packets 9 draft-smyslov-ipsecme-rfc8229bis-01 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 [RFC8229]. This 23 document updates specification for TCP encapsulation by including 24 additional calarifications obtained during implementation and 25 deployment of this method. This documents makes RFC8229 obsolete. 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 November 16, 2020. 44 Copyright Notice 46 Copyright (c) 2020 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 . . . . . . . . . . . . . . . . . . 4 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.4. Error Handling in IKE_SA_INIT . . . . . . . . . . . . . . 12 76 7.5. NAT Detection Payloads . . . . . . . . . . . . . . . . . 13 77 7.6. Keep-Alives and Dead Peer Detection . . . . . . . . . . . 13 78 7.7. Implications of TCP Encapsulation on IPsec SA Processing 14 79 8. Interaction with IKEv2 Extensions . . . . . . . . . . . . . . 14 80 8.1. MOBIKE Protocol . . . . . . . . . . . . . . . . . . . . . 14 81 8.2. IKE Redirect . . . . . . . . . . . . . . . . . . . . . . 15 82 8.3. IKEv2 Session Resumption . . . . . . . . . . . . . . . . 15 83 8.4. IKEv2 Protocol Support for High Availability . . . . . . 16 84 8.5. IKEv2 Fragmentation . . . . . . . . . . . . . . . . . . . 16 85 9. Middlebox Considerations . . . . . . . . . . . . . . . . . . 17 86 10. Performance Considerations . . . . . . . . . . . . . . . . . 17 87 10.1. TCP-in-TCP . . . . . . . . . . . . . . . . . . . . . . . 17 88 10.2. Added Reliability for Unreliable Protocols . . . . . . . 18 89 10.3. Quality-of-Service Markings . . . . . . . . . . . . . . 18 90 10.4. Maximum Segment Size . . . . . . . . . . . . . . . . . . 19 91 10.5. Tunneling ECN in TCP . . . . . . . . . . . . . . . . . . 19 92 11. Security Considerations . . . . . . . . . . . . . . . . . . . 19 93 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 20 94 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 20 95 13.1. Normative References . . . . . . . . . . . . . . . . . . 20 96 13.2. Informative References . . . . . . . . . . . . . . . . . 21 98 Appendix A. Using TCP Encapsulation with TLS . . . . . . . . . . 23 99 Appendix B. Example Exchanges of TCP Encapsulation with TLS 1.2 23 100 B.1. Establishing an IKE Session . . . . . . . . . . . . . . . 23 101 B.2. Deleting an IKE Session . . . . . . . . . . . . . . . . . 25 102 B.3. Re-establishing an IKE Session . . . . . . . . . . . . . 26 103 B.4. Using MOBIKE between UDP and TCP Encapsulation . . . . . 27 104 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 29 105 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 29 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 2. Terminology and Notation 191 This document distinguishes between the IKE peer that initiates TCP 192 connections to be used for TCP encapsulation and the roles of 193 Initiator and Responder for particular IKE messages. During the 194 course of IKE exchanges, the role of IKE Initiator and Responder may 195 swap for a given SA (as with IKE SA rekeys), while the Initiator of 196 the TCP connection is still responsible for tearing down the TCP 197 connection and re-establishing it if necessary. For this reason, 198 this document will use the term "TCP Originator" to indicate the IKE 199 peer that initiates TCP connections. The peer that receives TCP 200 connections will be referred to as the "TCP Responder". If an IKE SA 201 is rekeyed one or more times, the TCP Originator MUST remain the peer 202 that originally initiated the first IKE SA. 204 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 205 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 206 "OPTIONAL" in this document are to be interpreted as described in BCP 207 14 [RFC2119] [RFC8174] when, and only when, they appear in all 208 capitals, as shown here. 210 3. Configuration 212 One of the main reasons to use TCP encapsulation is that UDP traffic 213 may be entirely blocked on a network. Because of this, support for 214 TCP encapsulation is not specifically negotiated in the IKE exchange. 215 Instead, support for TCP encapsulation must be pre-configured on both 216 the TCP Originator and the TCP Responder. 218 Implementations MUST support TCP encapsulation on TCP port 4500, 219 which is reserved for IPsec NAT traversal. 221 Beyond a flag indicating support for TCP encapsulation, the 222 configuration for each peer can include the following optional 223 parameters: 225 o Alternate TCP ports on which the specific TCP Responder listens 226 for incoming connections. Note that the TCP Originator may 227 initiate TCP connections to the TCP Responder from any local port. 229 o An extra framing protocol to use on top of TCP to further 230 encapsulate the stream of IKE and IPsec packets. See Appendix B 231 for a detailed discussion. 233 Since TCP encapsulation of IKE and IPsec packets adds overhead and 234 has potential performance trade-offs compared to direct or UDP- 235 encapsulated SAs (as described in Section 10), implementations SHOULD 236 prefer ESP direct or UDP-encapsulated SAs over TCP-encapsulated SAs 237 when possible. 239 4. TCP-Encapsulated Header Formats 241 Like UDP encapsulation, TCP encapsulation uses the first four bytes 242 of a message to differentiate IKE and ESP messages. TCP 243 encapsulation also adds a 16-bit Length field that precedes every 244 message to define the boundaries of messages within a stream. The 245 value in this field is equal to the length of the original message 246 plus the length of the field itself, in octets. If the first 32 bits 247 of the message are zeros (a non-ESP marker), then the contents 248 comprise an IKE message. Otherwise, the contents comprise an ESP 249 message. Authentication Header (AH) messages are not supported for 250 TCP encapsulation. 252 Although a TCP stream may be able to send very long messages, 253 implementations SHOULD limit message lengths to typical UDP datagram 254 ESP payload lengths. The maximum message length is used as the 255 effective MTU for connections that are being encrypted using ESP, so 256 the maximum message length will influence characteristics of inner 257 connections, such as the TCP Maximum Segment Size (MSS). 258 Additionally, since TCP headers are longer than UDP headers, and TCP 259 encapsulation adds a 16-bit Length field, some very long ESP and IKE 260 messages that could be sent over UDP cannot be encapsulated in TCP, 261 because their total length after encapsulation would exceed 65535 and 262 thus could not be represented in Length field. 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 connection is left idle and 415 the TCP Responder needs to clean up resources, the TCP Responder MAY 416 close the TCP connection. 418 An unexpected FIN or a TCP Reset on the TCP connection may indicate a 419 loss of connectivity, an attack, or some other error. If a DELETE 420 payload has not been sent, both sides SHOULD maintain the state for 421 their SAs for the standard lifetime or timeout period. The TCP 422 Originator is responsible for re-establishing the TCP connection if 423 it is torn down for any unexpected reason. Since new TCP connections 424 may use different ports due to NAT mappings or local port allocations 425 changing, the TCP Responder MUST allow packets for existing SAs to be 426 received from new source ports. 428 A peer MUST discard a partially received message due to a broken 429 connection. 431 Whenever the TCP Originator opens a new TCP connection to be used for 432 an existing IKE SA, it MUST send the stream prefix first, before any 433 IKE or ESP messages. This follows the same behavior as the initial 434 TCP connection. 436 If a TCP connection is being used to resume a previous IKE session, 437 the TCP Responder can recognize the session using either the IKE SPI 438 from an encapsulated IKE message or the ESP SPI from an encapsulated 439 ESP message. If the session had been fully established previously, 440 it is suggested that the TCP Originator send an UPDATE_SA_ADDRESSES 441 message if MOBIKE is supported, or an informational message (a keep- 442 alive) otherwise. 444 The TCP Responder MUST NOT accept any messages for the existing IKE 445 session on a new incoming connection, unless that connection begins 446 with the stream prefix. If either the TCP Originator or TCP 447 Responder detects corruption on a connection that was started with a 448 valid stream prefix, it SHOULD close the TCP connection. The 449 connection can be determined to be corrupted if there are too many 450 subsequent messages that cannot be parsed as valid IKE messages or 451 ESP messages with known SPIs, or if the authentication check for an 452 ESP message with a known SPI fails. Implementations SHOULD NOT tear 453 down a connection if only a single ESP message has an unknown SPI, 454 since the SPI databases may be momentarily out of sync. If there is 455 instead a syntax issue within an IKE message, an implementation MUST 456 send the INVALID_SYNTAX notify payload and tear down the IKE SA as 457 usual, rather than tearing down the TCP connection directly. 459 A TCP Originator SHOULD only open one TCP connection per IKE SA, over 460 which it sends all of the corresponding IKE and ESP messages. This 461 helps ensure that any firewall or NAT mappings allocated for the TCP 462 connection apply to all of the traffic associated with the IKE SA 463 equally. 465 Similarly, a TCP Responder SHOULD at any given time send packets for 466 an IKE SA and its Child SAs over only one TCP connection. It SHOULD 467 choose the TCP connection on which it last received a valid and 468 decryptable IKE or ESP message. In order to be considered valid for 469 choosing a TCP connection, an IKE message must be successfully 470 decrypted and authenticated, not be a retransmission of a previously 471 received message, and be within the expected window for IKE message 472 IDs. Similarly, an ESP message must pass authentication checks and 473 be decrypted, and must not be a replay of a previous message. 475 Since a connection may be broken and a new connection re-established 476 by the TCP Originator without the TCP Responder being aware, a TCP 477 Responder SHOULD accept receiving IKE and ESP messages on both old 478 and new connections until the old connection is closed by the TCP 479 Originator. A TCP Responder MAY close a TCP connection that it 480 perceives as idle and extraneous (one previously used for IKE and ESP 481 messages that has been replaced by a new connection). 483 Multiple IKE SAs MUST NOT share a single TCP connection, unless one 484 is a rekey of an existing IKE SA, in which case there will 485 temporarily be two IKE SAs on the same TCP connection. 487 7.2. Retransmissions 489 Section 2.1 of [RFC7296] describes how IKEv2 deals with the 490 unreliability of the UDP protocol. In brief, the exchange Initiator 491 is responsible for retransmissions and must retransmit requests 492 message until response message is received. If no reply is received 493 after several retransmissions, the SA is deleted. The Responder 494 never initiates retransmission, but must send a response message 495 again in case it receives a retransmitted request. 497 When IKEv2 uses a reliable transport protocol, like TCP, the 498 retransmission rules are as follows: 500 o the exchange Initiator SHOULD NOT retransmit request message; if 501 no response is received within some reasonable period of time, the 502 IKE SA is deleted. 504 o if a TCP connection is broken and reestablished while the exchange 505 Initiator is waiting for a response, the Initiator MUST retransmit 506 its request and continue to wait for a response. 508 o the exchange Responder does not change its behavior, but acts as 509 described in Section 2.1 of [RFC7296]. 511 7.3. Cookies and Puzzles 513 IKEv2 provides a DoS attack protection mechanism through Cookies, 514 which is described in Section 2.6 of [RFC7296]. [RFC8019] extends 515 this mechanism for protection against DDoS attacks by means of Client 516 Puzzles. Both mechanisms allow the Responder to avoid keeping state 517 until the Initiator proves its IP address is legitimate (and after 518 solving a puzzle if required). 520 The connection-oriented nature of TCP and transport brings additional 521 considerations for using these mechanisms. In general, Cookies 522 provide less value in case of TCP encapsulation, since by the time a 523 Responder receives the IKE_SA_INIT request, the TCP session has 524 already been established and the Initiator's IP address has been 525 verified. Moreover, a TCP Responder creates state once a SYN packet 526 is received (unless SYN Cookies described in [RFC4987] are employed), 527 which eliminates some of the benefits of IKEv2 Cookies. When using 528 TCP encapsulation, it adds little value to send Cookie requests 529 without Puzzles unless the Responder is concerned with the 530 possibility of TCP Sequence Number attacks (see [RFC6528] for 531 details). Puzzles, on the other hand, still remain useful (and their 532 use requires using Cookies). 534 The following considerations are applicable for using Cookie and 535 Puzzle mechanisms in case of TCP encapsulation: 537 o the exchange Responder SHOULD NOT request a Cookie, with the 538 exception of Puzzles or for rare cases like preventing TCP 539 Sequence Number attacks. 541 o if the Responder chooses to send Cookie request (possibly along 542 with Puzzle request), then the TCP connection that the IKE_SA_INIT 543 request message was received over SHOULD be closed, so that the 544 Responder remains stateless at least until the Cookie (or Puzzle 545 Solution) is returned. Note that if this TCP connection is 546 closed, the Responder MUST NOT include the Initiator's TCP port 547 into the Cookie calculation (*), since the Cookie will be returned 548 over a new TCP connection with a different port. 550 o the exchange Initiator acts as described in Section 2.6 of 551 [RFC7296] and Section 7 of [RFC8019], i.e. using TCP encapsulation 552 doesn't change the Initiator's behavior. 554 (*) Examples of Cookie calculation methods are given in Section 2.6 555 of [RFC7296] and in Section 7.1.1.3 of [RFC8019] and they don't 556 include transport protocol ports. However these examples are given 557 for illustrative purposes, since Cookie generation algorithm is a 558 local matter and some implementations might include port numbers, 559 that won't work with TCP encapsulation. 561 7.4. Error Handling in IKE_SA_INIT 563 Section 2.21.1 of [RFC7296] describes how error notifications are 564 handled in the IKE_SA_INIT exchange. In particular, it is advised 565 that the Initiator should not act immediately after receiving error 566 notification and should instead wait some time for valid response, 567 since the IKE_SA_INIT messages are completely unauthenticated. This 568 advice does not apply equally in case of TCP encapsulation. If the 569 Initiator receives a response message over TCP, then either this 570 message is genuine and was sent by the peer, or the TCP session was 571 hijacked and the message is forged. In this latter case, no genuine 572 messages from the Responder will be received. 574 Thus, in case of TCP encapsulation, an Initiator SHOULD NOT wait for 575 additional messages in case it receives error notification from the 576 Responder in the IKE_SA_INIT exchange. 578 7.5. NAT Detection Payloads 580 When negotiating over UDP port 500, IKE_SA_INIT packets include 581 NAT_DETECTION_SOURCE_IP and NAT_DETECTION_DESTINATION_IP payloads to 582 determine if UDP encapsulation of IPsec packets should be used. 583 These payloads contain SHA-1 digests of the SPIs, IP addresses, and 584 ports as defined in [RFC7296]. IKE_SA_INIT packets sent on a TCP 585 connection SHOULD include these payloads with the same content as 586 when sending over UDP and SHOULD use the applicable TCP ports when 587 creating and checking the SHA-1 digests. 589 If a NAT is detected due to the SHA-1 digests not matching the 590 expected values, no change should be made for encapsulation of 591 subsequent IKE or ESP packets, since TCP encapsulation inherently 592 supports NAT traversal. Implementations MAY use the information that 593 a NAT is present to influence keep-alive timer values. 595 If a NAT is detected, implementations need to handle transport mode 596 TCP and UDP packet checksum fixup as defined for UDP encapsulation in 597 [RFC3948]. 599 7.6. Keep-Alives and Dead Peer Detection 601 Encapsulating IKE and IPsec inside of a TCP connection can impact the 602 strategy that implementations use to detect peer liveness and to 603 maintain middlebox port mappings. Peer liveness should be checked 604 using IKE informational packets [RFC7296]. 606 In general, TCP port mappings are maintained by NATs longer than UDP 607 port mappings, so IPsec ESP NAT keep-alives [RFC3948] SHOULD NOT be 608 sent when using TCP encapsulation. Any implementation using TCP 609 encapsulation MUST silently drop incoming NAT keep-alive packets and 610 not treat them as errors. NAT keep-alive packets over a TCP- 611 encapsulated IPsec connection will be sent as an ESP message with a 612 one-octet-long payload with the value 0xFF. 614 Note that, depending on the configuration of TCP and TLS on the 615 connection, TCP keep-alives [RFC1122] and TLS keep-alives [RFC6520] 616 may be used. These MUST NOT be used as indications of IKE peer 617 liveness. 619 7.7. Implications of TCP Encapsulation on IPsec SA Processing 621 Using TCP encapsulation affects some aspects of IPsec SA processing. 623 1. Section 8.1 of [RFC4301] requires all tunnel mode IPsec SAs to be 624 able to copy the Don't Fragment (DF) bit from inner IP header to 625 the outer (tunnel) one. With TCP encapsulation this is generally 626 not possible, because TCP/IP stack manages DF bit in the outer IP 627 header, and usually the stack ensures that the DF bit is set for 628 TCP packets to avoid IP fragmentation. 630 2. The other feature that is less applicable with TCP encapsulation 631 is an ability to split traffic of different QoS classes into 632 different IPsec SAs, created by a single IKE SA. In this case 633 the Differentiated Services Code Point (DSCP) field is usually 634 copied from the inner IP header to the outer (tunnel) one, 635 ensuring that IPsec traffic of each SA receives the corresponding 636 level of service. With TCP encapsulation all IPsec SAs created 637 by a single IKE SA will share a single TCP connection and thus 638 will receive the same level of service (see Section 10.3). If 639 this functionality is needed, implementations should create 640 several IKE SAs over TCP and assign a corresponding DSCP value to 641 each of them. 643 8. Interaction with IKEv2 Extensions 645 8.1. MOBIKE Protocol 647 MOBIKE protocol, that allows IKEv2 SA to migrate between IP 648 addresses, is defined in [RFC4555], and [RFC4621] further clarifies 649 the details of the protocol. When an IKE session that has negotiated 650 MOBIKE is transitioning between networks, the Initiator of the 651 transition may switch between using TCP encapsulation, UDP 652 encapsulation, or no encapsulation. Implementations that implement 653 both MOBIKE and TCP encapsulation MUST support dynamically enabling 654 and disabling TCP encapsulation as interfaces change. 656 When a MOBIKE-enabled Initiator changes networks, the INFORMATIONAL 657 exchange with the UPDATE_SA_ADDRESSES notification SHOULD be 658 initiated first over UDP before attempting over TCP. If there is a 659 response to the request sent over UDP, then the ESP packets should be 660 sent directly over IP or over UDP port 4500 (depending on if a NAT 661 was detected), regardless of if a connection on a previous network 662 was using TCP encapsulation. If no response is received within a 663 certain period of time after several retransmissions, the Initiator 664 ought to change its transport for this exchange from UDP to TCP and 665 resend the request message. New INFORMATIONAL exchange MUST NOT be 666 started in this situation. If the Responder only responds to the 667 request sent over TCP, then the ESP packets should be sent over the 668 TCP connection, regardless of if a connection on a previous network 669 did not use TCP encapsulation. 671 Since switching from UDP to TCP happens can occur during a single 672 INFORMATIONAL message exchange, the content of the 673 NAT_DETECTION_SOURCE_IP notification will in most cases be incorrect 674 (since UDP and TCP source ports will most likely be different), and 675 the peer may incorrectly detect the presence of a NAT. This should 676 not cause functional issues since all messages will be encapsulated 677 in TCP anyway, and TCP encapsulation does not change based on the 678 presence of NATs. 680 MOBIKE protocol defined the NO_NATS_ALLOWED notification that can be 681 used to detect the presence of NAT between peer and to refuse to 682 communicate in this situation. In case of TCP the NO_NATS_ALLOWED 683 notification SHOULD be ignored because TCP generally has no problems 684 with NAT boxes. 686 Section 3.7 of [RFC4555] describes an additional optional step in the 687 process of changing IP addresses called Return Routability Check. It 688 is performed by the responder in order to be sure that the new 689 initiator's address is in fact routable. In case of TCP 690 encapsulation this check has little value, since TCP handshake proves 691 routability of the TCP Originator's address. So, in case of TCP 692 encapsulation the Return Routability Check SHOULD NOT be performed. 694 8.2. IKE Redirect 696 A redirect mechanism for IKEv2 is defined in [RFC5685]. This 697 mechanism allows security gateways to redirect clients to another 698 gateway either during IKE SA establishment or after session setup. 699 If a client is connecting to a security gateway using TCP and then is 700 redirected to another security gateway, the client needs to reset its 701 transport selection. In other words, the client MUST again try first 702 UDP and then fall back to TCP while establishing a new IKE SA, 703 regardless of the transport of the SA the redirect notification was 704 received over (unless the client's configuration instructs it to 705 instantly use TCP for the gateway it is redirected to). 707 8.3. IKEv2 Session Resumption 709 Session resumption for IKEv2 is defined in [RFC5723]. Once an IKE SA 710 is established, the server creates a resumption ticket where 711 information about this SA is stored, and transfers this ticket to the 712 client. The ticket may be later used to resume the IKE SA after it 713 is deleted. In the event of resumption the client presents the 714 ticket in a new exchange, called IKE_SESSION_RESUME. Some parameters 715 in the new SA are retrieved from the ticket and others are re- 716 negotiated (more details are given in Section 5 of [RFC5723]). If 717 TCP encapsulation was used in an old SA, then the client SHOULD 718 resume this SA using TCP, without first trying to connect over UDP. 720 8.4. IKEv2 Protocol Support for High Availability 722 [RFC6311] defines a support for High Availability in IKEv2. In case 723 of cluster failover, a new active node must immediately initiate a 724 special INFORMATION exchange containing the IKEV2_MESSAGE_ID_SYNC 725 notification, which instructs the client to skip some number of 726 Message IDs that might not be synchronized yet between nodes at the 727 time of failover. 729 Synchronizing states when using TCP encapsulation is much harder than 730 when using UDP; doing so requires access to TCP/IP stack internals, 731 which is not always available from an IKE/IPsec implementation. If a 732 cluster implementation doesn't synchronize TCP states between nodes, 733 then after failover event the new active node will not have any TCP 734 connection with the client, so the node cannot initiate the 735 INFORMATIONAL exchange as required by [RFC6311]. Since the cluster 736 usually acts as TCP Responder, the new active node cannot re- 737 establish TCP connection, since only the TCP Originator can do it. 738 For the client, the cluster failover event may remain undetected for 739 long time if it has no IKE or ESP traffic to send. Once the client 740 sends an ESP or IKEv2 packet, the cluster node will reply with TCP 741 RST and the client (as TCP Originator) will reestablish the TCP 742 connection so that the node will be able to initiate the 743 INFORMATIONAL exchange informing the client about the cluster 744 failover. 746 This document makes the following recommendation: if support for High 747 Availability in IKEv2 is negotiated and TCP transport is used, a 748 client that is a TCP Originator SHOULD periodically send IKEv2 749 messages (e.g. by initiating liveness check exchange) whenever there 750 is no IKEv2 or ESP traffic. This differs from the recommendations 751 given in Section 2.4 of [RFC7296] in the following: the liveness 752 check should be periodically performed even if the client has nothing 753 to send over ESP. The frequency of sending such messages should be 754 high enough to allow quick detection and restoring of broken TCP 755 connection. 757 8.5. IKEv2 Fragmentation 759 IKE message fragmentation [RFC7383] is not required when using TCP 760 encapsulation, since a TCP stream already handles the fragmentation 761 of its contents across packets. Since fragmentation is redundant in 762 this case, implementations might choose to not negotiate IKE 763 fragmentation. Even if fragmentation is negotiated, an 764 implementation SHOULD NOT send fragments when going over a TCP 765 connection, although it MUST support receiving fragments. 767 If an implementation supports both MOBIKE and IKE fragmentation, it 768 SHOULD negotiate IKE fragmentation over a TCP-encapsulated session in 769 case the session switches to UDP encapsulation on another network. 771 9. Middlebox Considerations 773 Many security networking devices, such as firewalls or intrusion 774 prevention systems, network optimization/acceleration devices, and 775 NAT devices, keep the state of sessions that traverse through them. 777 These devices commonly track the transport-layer and/or application- 778 layer data to drop traffic that is anomalous or malicious in nature. 779 While many of these devices will be more likely to pass TCP- 780 encapsulated traffic as opposed to UDP-encapsulated traffic, some may 781 still block or interfere with TCP-encapsulated IKE and IPsec traffic. 783 A network device that monitors the transport layer will track the 784 state of TCP sessions, such as TCP sequence numbers. TCP 785 encapsulation of IKE should therefore use standard TCP behaviors to 786 avoid being dropped by middleboxes. 788 10. Performance Considerations 790 Several aspects of TCP encapsulation for IKE and IPsec packets may 791 negatively impact the performance of connections within a tunnel-mode 792 IPsec SA. Implementations should be aware of these performance 793 impacts and take these into consideration when determining when to 794 use TCP encapsulation. Implementations SHOULD favor using direct ESP 795 or UDP encapsulation over TCP encapsulation whenever possible. 797 10.1. TCP-in-TCP 799 If the outer connection between IKE peers is over TCP, inner TCP 800 connections may suffer negative effects from using TCP within TCP. 801 Running TCP within TCP is discouraged, since the TCP algorithms 802 generally assume that they are running over an unreliable datagram 803 layer. 805 If the outer (tunnel) TCP connection experiences packet loss, this 806 loss will be hidden from any inner TCP connections, since the outer 807 connection will retransmit to account for the losses. Since the 808 outer TCP connection will deliver the inner messages in order, any 809 messages after a lost packet may have to wait until the loss is 810 recovered. This means that loss on the outer connection will be 811 interpreted only as delay by inner connections. The burstiness of 812 inner traffic can increase, since a large number of inner packets may 813 be delivered across the tunnel at once. The inner TCP connection may 814 interpret a long period of delay as a transmission problem, 815 triggering a retransmission timeout, which will cause spurious 816 retransmissions. The sending rate of the inner connection may be 817 unnecessarily reduced if the retransmissions are not detected as 818 spurious in time. 820 The inner TCP connection's round-trip-time estimation will be 821 affected by the burstiness of the outer TCP connection if there are 822 long delays when packets are retransmitted by the outer TCP 823 connection. This will make the congestion control loop of the inner 824 TCP traffic less reactive, potentially permanently leading to a lower 825 sending rate than the outer TCP would allow for. 827 TCP-in-TCP can also lead to increased buffering, or bufferbloat. 828 This can occur when the window size of the outer TCP connection is 829 reduced and becomes smaller than the window sizes of the inner TCP 830 connections. This can lead to packets backing up in the outer TCP 831 connection's send buffers. In order to limit this effect, the outer 832 TCP connection should have limits on its send buffer size and on the 833 rate at which it reduces its window size. 835 Note that any negative effects will be shared between all flows going 836 through the outer TCP connection. This is of particular concern for 837 any latency-sensitive or real-time applications using the tunnel. If 838 such traffic is using a TCP-encapsulated IPsec connection, it is 839 recommended that the number of inner connections sharing the tunnel 840 be limited as much as possible. 842 10.2. Added Reliability for Unreliable Protocols 844 Since ESP is an unreliable protocol, transmitting ESP packets over a 845 TCP connection will change the fundamental behavior of the packets. 846 Some application-level protocols that prefer packet loss to delay 847 (such as Voice over IP or other real-time protocols) may be 848 negatively impacted if their packets are retransmitted by the TCP 849 connection due to packet loss. 851 10.3. Quality-of-Service Markings 853 Quality-of-Service (QoS) markings, such as the Differentiated 854 Services Code Point (DSCP) and Traffic Class, should be used with 855 care on TCP connections used for encapsulation. Individual packets 856 SHOULD NOT use different markings than the rest of the connection, 857 since packets with different priorities may be routed differently and 858 cause unnecessary delays in the connection. 860 10.4. Maximum Segment Size 862 A TCP connection used for IKE encapsulation SHOULD negotiate its MSS 863 in order to avoid unnecessary fragmentation of packets. 865 10.5. Tunneling ECN in TCP 867 Since there is not a one-to-one relationship between outer IP packets 868 and inner ESP/IP messages when using TCP encapsulation, the markings 869 for Explicit Congestion Notification (ECN) [RFC3168] cannot be simply 870 mapped. However, any ECN Congestion Experienced (CE) marking on 871 inner headers should be preserved through the tunnel. 873 Implementations SHOULD follow the ECN compatibility mode for tunnel 874 ingress as described in [RFC6040]. In compatibility mode, the outer 875 tunnel TCP connection marks its packet headers as not ECN-capable. 876 If upon egress, the arriving outer header is marked with CE, the 877 implementation will drop the inner packet, since there is not a 878 distinct inner packet header onto which to translate the ECN 879 markings. 881 11. Security Considerations 883 IKE Responders that support TCP encapsulation may become vulnerable 884 to new Denial-of-Service (DoS) attacks that are specific to TCP, such 885 as SYN-flooding attacks. TCP Responders should be aware of this 886 additional attack surface. 888 TCP Responders should be careful to ensure that (1) the stream prefix 889 "IKETCP" uniquely identifies incoming streams as streams that use the 890 TCP encapsulation protocol and (2) they are not running any other 891 protocols on the same listening port (to avoid potential conflicts). 893 Attackers may be able to disrupt the TCP connection by sending 894 spurious TCP Reset packets. Therefore, implementations SHOULD make 895 sure that IKE session state persists even if the underlying TCP 896 connection is torn down. 898 If MOBIKE is being used, all of the security considerations outlined 899 for MOBIKE apply [RFC4555]. 901 Similarly to MOBIKE, TCP encapsulation requires a TCP Responder to 902 handle changes to source address and port due to network or 903 connection disruption. The successful delivery of valid IKE or ESP 904 messages over a new TCP connection is used by the TCP Responder to 905 determine where to send subsequent responses. If an attacker is able 906 to send packets on a new TCP connection that pass the validation 907 checks of the TCP Responder, it can influence which path future 908 packets will take. For this reason, the validation of messages on 909 the TCP Responder must include decryption, authentication, and replay 910 checks. 912 Since TCP provides reliable, in-order delivery of ESP messages, the 913 ESP anti-replay window size SHOULD be set to 1. See [RFC4303] for a 914 complete description of the ESP anti-replay window. This increases 915 the protection of implementations against replay attacks. 917 12. IANA Considerations 919 TCP port 4500 is already allocated to IPsec for NAT traversal. This 920 port SHOULD be used for TCP-encapsulated IKE and ESP as described in 921 this document. 923 This document updates the reference for TCP port 4500 from RFC 8229 924 to itself: 926 Keyword Decimal Description Reference 927 ----------- -------- ------------------- --------- 928 ipsec-nat-t 4500/tcp IPsec NAT-Traversal [RFCXXXX] 930 Figure 4 932 13. References 934 13.1. Normative References 936 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 937 Requirement Levels", BCP 14, RFC 2119, 938 DOI 10.17487/RFC2119, March 1997, 939 . 941 [RFC3948] Huttunen, A., Swander, B., Volpe, V., DiBurro, L., and M. 942 Stenberg, "UDP Encapsulation of IPsec ESP Packets", 943 RFC 3948, DOI 10.17487/RFC3948, January 2005, 944 . 946 [RFC4301] Kent, S. and K. Seo, "Security Architecture for the 947 Internet Protocol", RFC 4301, DOI 10.17487/RFC4301, 948 December 2005, . 950 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 951 RFC 4303, DOI 10.17487/RFC4303, December 2005, 952 . 954 [RFC6040] Briscoe, B., "Tunnelling of Explicit Congestion 955 Notification", RFC 6040, DOI 10.17487/RFC6040, November 956 2010, . 958 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 959 Kivinen, "Internet Key Exchange Protocol Version 2 960 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 961 2014, . 963 [RFC8019] Nir, Y. and V. Smyslov, "Protecting Internet Key Exchange 964 Protocol Version 2 (IKEv2) Implementations from 965 Distributed Denial-of-Service Attacks", RFC 8019, 966 DOI 10.17487/RFC8019, November 2016, 967 . 969 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 970 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 971 May 2017, . 973 13.2. Informative References 975 [I-D.ietf-ipsecme-ike-tcp] 976 Nir, Y., "A TCP transport for the Internet Key Exchange", 977 draft-ietf-ipsecme-ike-tcp-01 (work in progress), December 978 2012. 980 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 981 Communication Layers", STD 3, RFC 1122, 982 DOI 10.17487/RFC1122, October 1989, 983 . 985 [RFC2817] Khare, R. and S. Lawrence, "Upgrading to TLS Within 986 HTTP/1.1", RFC 2817, DOI 10.17487/RFC2817, May 2000, 987 . 989 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 990 of Explicit Congestion Notification (ECN) to IP", 991 RFC 3168, DOI 10.17487/RFC3168, September 2001, 992 . 994 [RFC4555] Eronen, P., "IKEv2 Mobility and Multihoming Protocol 995 (MOBIKE)", RFC 4555, DOI 10.17487/RFC4555, June 2006, 996 . 998 [RFC4621] Kivinen, T. and H. Tschofenig, "Design of the IKEv2 999 Mobility and Multihoming (MOBIKE) Protocol", RFC 4621, 1000 DOI 10.17487/RFC4621, August 2006, 1001 . 1003 [RFC4987] Eddy, W., "TCP SYN Flooding Attacks and Common 1004 Mitigations", RFC 4987, DOI 10.17487/RFC4987, August 2007, 1005 . 1007 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1008 (TLS) Protocol Version 1.2", RFC 5246, 1009 DOI 10.17487/RFC5246, August 2008, 1010 . 1012 [RFC5685] Devarapalli, V. and K. Weniger, "Redirect Mechanism for 1013 the Internet Key Exchange Protocol Version 2 (IKEv2)", 1014 RFC 5685, DOI 10.17487/RFC5685, November 2009, 1015 . 1017 [RFC5723] Sheffer, Y. and H. Tschofenig, "Internet Key Exchange 1018 Protocol Version 2 (IKEv2) Session Resumption", RFC 5723, 1019 DOI 10.17487/RFC5723, January 2010, 1020 . 1022 [RFC6311] Singh, R., Ed., Kalyani, G., Nir, Y., Sheffer, Y., and D. 1023 Zhang, "Protocol Support for High Availability of IKEv2/ 1024 IPsec", RFC 6311, DOI 10.17487/RFC6311, July 2011, 1025 . 1027 [RFC6520] Seggelmann, R., Tuexen, M., and M. Williams, "Transport 1028 Layer Security (TLS) and Datagram Transport Layer Security 1029 (DTLS) Heartbeat Extension", RFC 6520, 1030 DOI 10.17487/RFC6520, February 2012, 1031 . 1033 [RFC6528] Gont, F. and S. Bellovin, "Defending against Sequence 1034 Number Attacks", RFC 6528, DOI 10.17487/RFC6528, February 1035 2012, . 1037 [RFC7383] Smyslov, V., "Internet Key Exchange Protocol Version 2 1038 (IKEv2) Message Fragmentation", RFC 7383, 1039 DOI 10.17487/RFC7383, November 2014, 1040 . 1042 [RFC8229] Pauly, T., Touati, S., and R. Mantha, "TCP Encapsulation 1043 of IKE and IPsec Packets", RFC 8229, DOI 10.17487/RFC8229, 1044 August 2017, . 1046 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1047 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1048 . 1050 Appendix A. Using TCP Encapsulation with TLS 1052 This section provides recommendations on how to use TLS in addition 1053 to TCP encapsulation. 1055 When using TCP encapsulation, implementations may choose to use TLS 1056 1.2 [RFC5246] or TLS 1.3 [RFC8446] on the TCP connection to be able 1057 to traverse middleboxes, which may otherwise block the traffic. 1059 If a web proxy is applied to the ports used for the TCP connection 1060 and TLS is being used, the TCP Originator can send an HTTP CONNECT 1061 message to establish an SA through the proxy [RFC2817]. 1063 The use of TLS should be configurable on the peers, and may be used 1064 as the default when using TCP encapsulation or may be used as a 1065 fallback when basic TCP encapsulation fails. The TCP Responder may 1066 expect to read encapsulated IKE and ESP packets directly from the TCP 1067 connection, or it may expect to read them from a stream of TLS data 1068 packets. The TCP Originator should be pre-configured to use TLS or 1069 not when communicating with a given port on the TCP Responder. 1071 When new TCP connections are re-established due to a broken 1072 connection, TLS must be renegotiated. TLS session resumption is 1073 recommended to improve efficiency in this case. 1075 The security of the IKE session is entirely derived from the IKE 1076 negotiation and key establishment and not from the TLS session (which 1077 in this context is only used for encapsulation purposes); therefore, 1078 when TLS is used on the TCP connection, both the TCP Originator and 1079 the TCP Responder SHOULD allow the NULL cipher to be selected for 1080 performance reasons. Note, that TLS 1.3 only supports AEAD 1081 algorithms and at the time of writing this document there was no 1082 recommended cipher suite for TLS 1.3 with the NULL cipher. 1084 Implementations should be aware that the use of TLS introduces 1085 another layer of overhead requiring more bytes to transmit a given 1086 IKE and IPsec packet. For this reason, direct ESP, UDP 1087 encapsulation, or TCP encapsulation without TLS should be preferred 1088 in situations in which TLS is not required in order to traverse 1089 middleboxes. 1091 Appendix B. Example Exchanges of TCP Encapsulation with TLS 1.2 1093 B.1. Establishing an IKE Session 1095 Client Server 1096 ---------- ---------- 1097 1) -------------------- TCP Connection ------------------- 1098 (IP_I:Port_I -> IP_R:Port_R) 1099 TcpSyn ----------> 1100 <---------- TcpSyn,Ack 1101 TcpAck ----------> 1103 2) --------------------- TLS Session --------------------- 1104 ClientHello ----------> 1105 ServerHello 1106 Certificate* 1107 ServerKeyExchange* 1108 <---------- ServerHelloDone 1109 ClientKeyExchange 1110 CertificateVerify* 1111 [ChangeCipherSpec] 1112 Finished ----------> 1113 [ChangeCipherSpec] 1114 <---------- Finished 1116 3) ---------------------- Stream Prefix -------------------- 1117 "IKETCP" ----------> 1118 4) ----------------------- IKE Session --------------------- 1119 Length + Non-ESP Marker ----------> 1120 IKE_SA_INIT 1121 HDR, SAi1, KEi, Ni, 1122 [N(NAT_DETECTION_*_IP)] 1123 <------ Length + Non-ESP Marker 1124 IKE_SA_INIT 1125 HDR, SAr1, KEr, Nr, 1126 [N(NAT_DETECTION_*_IP)] 1127 Length + Non-ESP Marker ----------> 1128 first IKE_AUTH 1129 HDR, SK {IDi, [CERTREQ] 1130 CP(CFG_REQUEST), IDr, 1131 SAi2, TSi, TSr, ...} 1132 <------ Length + Non-ESP Marker 1133 first IKE_AUTH 1134 HDR, SK {IDr, [CERT], AUTH, 1135 EAP, SAr2, TSi, TSr} 1137 Length + Non-ESP Marker ----------> 1138 IKE_AUTH + EAP 1139 repeat 1..N times 1140 <------ Length + Non-ESP Marker 1141 IKE_AUTH + EAP 1142 Length + Non-ESP Marker ----------> 1143 final IKE_AUTH 1144 HDR, SK {AUTH} 1145 <------ Length + Non-ESP Marker 1146 final IKE_AUTH 1147 HDR, SK {AUTH, CP(CFG_REPLY), 1148 SA, TSi, TSr, ...} 1149 -------------- IKE and IPsec SAs Established ------------ 1150 Length + ESP Frame ----------> 1152 Figure 5 1154 1. The client establishes a TCP connection with the server on port 1155 4500 or on an alternate pre-configured port that the server is 1156 listening on. 1158 2. If configured to use TLS, the client initiates a TLS handshake. 1159 During the TLS handshake, the server SHOULD NOT request the 1160 client's certificate, since authentication is handled as part of 1161 IKE negotiation. 1163 3. The client sends the stream prefix for TCP-encapsulated IKE 1164 (Section 5) traffic to signal the beginning of IKE negotiation. 1166 4. The client and server establish an IKE connection. This example 1167 shows EAP-based authentication, although any authentication type 1168 may be used. 1170 B.2. Deleting an IKE Session 1171 Client Server 1172 ---------- ---------- 1173 1) ----------------------- IKE Session --------------------- 1174 Length + Non-ESP Marker ----------> 1175 INFORMATIONAL 1176 HDR, SK {[N,] [D,] 1177 [CP,] ...} 1178 <------ Length + Non-ESP Marker 1179 INFORMATIONAL 1180 HDR, SK {[N,] [D,] 1181 [CP], ...} 1183 2) --------------------- TLS Session --------------------- 1184 close_notify ----------> 1185 <---------- close_notify 1186 3) -------------------- TCP Connection ------------------- 1187 TcpFin ----------> 1188 <---------- Ack 1189 <---------- TcpFin 1190 Ack ----------> 1191 -------------------- IKE SA Deleted ------------------- 1193 Figure 6 1195 1. The client and server exchange informational messages to notify 1196 IKE SA deletion. 1198 2. The client and server negotiate TLS session deletion using TLS 1199 CLOSE_NOTIFY. 1201 3. The TCP connection is torn down. 1203 The deletion of the IKE SA should lead to the disposal of the 1204 underlying TLS and TCP state. 1206 B.3. Re-establishing an IKE Session 1207 Client Server 1208 ---------- ---------- 1209 1) -------------------- TCP Connection ------------------- 1210 (IP_I:Port_I -> IP_R:Port_R) 1211 TcpSyn ----------> 1212 <---------- TcpSyn,Ack 1213 TcpAck ----------> 1214 2) --------------------- TLS Session --------------------- 1215 ClientHello ----------> 1216 <---------- ServerHello 1217 [ChangeCipherSpec] 1218 Finished 1219 [ChangeCipherSpec] ----------> 1220 Finished 1221 3) ---------------------- Stream Prefix -------------------- 1222 "IKETCP" ----------> 1223 4) <---------------------> IKE/ESP Flow <------------------> 1224 Length + ESP Frame ----------> 1226 Figure 7 1228 1. If a previous TCP connection was broken (for example, due to a 1229 TCP Reset), the client is responsible for re-initiating the TCP 1230 connection. The TCP Originator's address and port (IP_I and 1231 Port_I) may be different from the previous connection's address 1232 and port. 1234 2. In the ClientHello TLS message, the client SHOULD send the 1235 session ID it received in the previous TLS handshake if 1236 available. It is up to the server to perform either an 1237 abbreviated handshake or a full handshake based on the session ID 1238 match. 1240 3. After TCP and TLS are complete, the client sends the stream 1241 prefix for TCP-encapsulated IKE traffic (Section 5). 1243 4. The IKE and ESP packet flow can resume. If MOBIKE is being used, 1244 the Initiator SHOULD send an UPDATE_SA_ADDRESSES message. 1246 B.4. Using MOBIKE between UDP and TCP Encapsulation 1248 Client Server 1249 ---------- ---------- 1250 (IP_I1:UDP500 -> IP_R:UDP500) 1251 1) ----------------- IKE_SA_INIT Exchange ----------------- 1252 (IP_I1:UDP4500 -> IP_R:UDP4500) 1253 Non-ESP Marker -----------> 1254 Initial IKE_AUTH 1255 HDR, SK { IDi, CERT, AUTH, 1256 CP(CFG_REQUEST), 1257 SAi2, TSi, TSr, 1258 N(MOBIKE_SUPPORTED) } 1259 <----------- Non-ESP Marker 1260 Initial IKE_AUTH 1261 HDR, SK { IDr, CERT, AUTH, 1262 EAP, SAr2, TSi, TSr, 1263 N(MOBIKE_SUPPORTED) } 1264 <------------------ IKE SA Establishment ---------------> 1266 2) ------------ MOBIKE Attempt on New Network -------------- 1267 (IP_I2:UDP4500 -> IP_R:UDP4500) 1268 Non-ESP Marker -----------> 1269 INFORMATIONAL 1270 HDR, SK { N(UPDATE_SA_ADDRESSES), 1271 N(NAT_DETECTION_SOURCE_IP), 1272 N(NAT_DETECTION_DESTINATION_IP) } 1274 3) -------------------- TCP Connection ------------------- 1275 (IP_I2:Port_I -> IP_R:Port_R) 1276 TcpSyn -----------> 1277 <----------- TcpSyn,Ack 1278 TcpAck -----------> 1280 4) --------------------- TLS Session --------------------- 1281 ClientHello -----------> 1282 ServerHello 1283 Certificate* 1284 ServerKeyExchange* 1285 <----------- ServerHelloDone 1286 ClientKeyExchange 1287 CertificateVerify* 1288 [ChangeCipherSpec] 1289 Finished -----------> 1290 [ChangeCipherSpec] 1291 <----------- Finished 1293 5) ---------------------- Stream Prefix -------------------- 1294 "IKETCP" ----------> 1296 6) ----------------------- IKE Session --------------------- 1297 Length + Non-ESP Marker -----------> 1298 INFORMATIONAL (Same as step 2) 1299 HDR, SK { N(UPDATE_SA_ADDRESSES), 1300 N(NAT_DETECTION_SOURCE_IP), 1301 N(NAT_DETECTION_DESTINATION_IP) } 1302 <------- Length + Non-ESP Marker 1303 HDR, SK { N(NAT_DETECTION_SOURCE_IP), 1304 N(NAT_DETECTION_DESTINATION_IP) } 1305 7) <----------------- IKE/ESP Data Flow -------------------> 1307 Figure 8 1309 1. During the IKE_SA_INIT exchange, the client and server exchange 1310 MOBIKE_SUPPORTED notify payloads to indicate support for MOBIKE. 1312 2. The client changes its point of attachment to the network and 1313 receives a new IP address. The client attempts to re-establish 1314 the IKE session using the UPDATE_SA_ADDRESSES notify payload, but 1315 the server does not respond because the network blocks UDP 1316 traffic. 1318 3. The client brings up a TCP connection to the server in order to 1319 use TCP encapsulation. 1321 4. The client initiates a TLS handshake with the server. 1323 5. The client sends the stream prefix for TCP-encapsulated IKE 1324 traffic (Section 5). 1326 6. The client sends the UPDATE_SA_ADDRESSES notify payload on the 1327 TCP-encapsulated connection. Note that this IKE message is the 1328 same as the one sent over UDP in step 2; it should have the same 1329 message ID and contents. 1331 7. The IKE and ESP packet flow can resume. 1333 Acknowledgments 1335 The following people provided valuable feedback and advices while 1336 preparing RFC8229: Stuart Cheshire, Delziel Fernandes, Yoav Nir, 1337 Christoph Paasch, Yaron Sheffer, David Schinazi, Graham Bartlett, 1338 Byju Pularikkal, March Wu, Kingwel Xie, Valery Smyslov, Jun Hu, and 1339 Tero Kivinen. Special thanks to Eric Kinnear for his implementation 1340 work. 1342 The authors would like to thank Tero Kivinen for his valuable 1343 comments while preparing this document. 1345 Authors' Addresses 1346 Valery Smyslov 1347 ELVIS-PLUS 1348 PO Box 81 1349 Moscow (Zelenograd) 124460 1350 Russian Federation 1352 Phone: +7 495 276 0211 1353 Email: svan@elvis.ru 1355 Tommy Pauly 1356 Apple Inc. 1357 1 Infinite Loop 1358 Cupertino, California 95014 1359 United States of America 1361 Email: tpauly@apple.com