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