idnits 2.17.1 draft-ietf-ipsecme-tcp-encaps-09.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (March 12, 2017) is 2592 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: 'Appendix A' is mentioned on line 305, but not defined == Missing Reference: 'Section 4' is mentioned on line 363, but not defined == Missing Reference: 'ChangeCipherSpec' is mentioned on line 922, but not defined == Missing Reference: 'CERTREQ' is mentioned on line 765, but not defined == Missing Reference: 'CERT' is mentioned on line 770, but not defined == Missing Reference: 'CP' is mentioned on line 814, but not defined -- Obsolete informational reference (is this intentional?): RFC 5246 (Obsoleted by RFC 8446) Summary: 0 errors (**), 0 flaws (~~), 7 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network T. Pauly 3 Internet-Draft Apple Inc. 4 Intended status: Standards Track S. Touati 5 Expires: September 13, 2017 Ericsson 6 R. Mantha 7 Cisco Systems 8 March 12, 2017 10 TCP Encapsulation of IKE and IPsec Packets 11 draft-ietf-ipsecme-tcp-encaps-09 13 Abstract 15 This document describes a method to transport IKE and IPsec packets 16 over a TCP connection for traversing network middleboxes that may 17 block IKE negotiation over UDP. This method, referred to as TCP 18 encapsulation, involves sending both IKE packets for Security 19 Association establishment and ESP packets over a TCP connection. 20 This method is intended to be used as a fallback option when IKE 21 cannot be negotiated over UDP. 23 Status of This Memo 25 This Internet-Draft is submitted in full conformance with the 26 provisions of BCP 78 and BCP 79. 28 Internet-Drafts are working documents of the Internet Engineering 29 Task Force (IETF). Note that other groups may also distribute 30 working documents as Internet-Drafts. The list of current Internet- 31 Drafts is at http://datatracker.ietf.org/drafts/current/. 33 Internet-Drafts are draft documents valid for a maximum of six months 34 and may be updated, replaced, or obsoleted by other documents at any 35 time. It is inappropriate to use Internet-Drafts as reference 36 material or to cite them other than as "work in progress." 38 This Internet-Draft will expire on September 13, 2017. 40 Copyright Notice 42 Copyright (c) 2017 IETF Trust and the persons identified as the 43 document authors. All rights reserved. 45 This document is subject to BCP 78 and the IETF Trust's Legal 46 Provisions Relating to IETF Documents 47 (http://trustee.ietf.org/license-info) in effect on the date of 48 publication of this document. Please review these documents 49 carefully, as they describe your rights and restrictions with respect 50 to this document. Code Components extracted from this document must 51 include Simplified BSD License text as described in Section 4.e of 52 the Trust Legal Provisions and are provided without warranty as 53 described in the Simplified BSD License. 55 Table of Contents 57 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 58 1.1. Prior Work and Motivation . . . . . . . . . . . . . . . . 3 59 1.2. Terminology and Notation . . . . . . . . . . . . . . . . 4 60 2. Configuration . . . . . . . . . . . . . . . . . . . . . . . . 4 61 3. TCP-Encapsulated Header Formats . . . . . . . . . . . . . . . 5 62 3.1. TCP-Encapsulated IKE Header Format . . . . . . . . . . . 6 63 3.2. TCP-Encapsulated ESP Header Format . . . . . . . . . . . 6 64 4. TCP-Encapsulated Stream Prefix . . . . . . . . . . . . . . . 7 65 5. Applicability . . . . . . . . . . . . . . . . . . . . . . . . 7 66 5.1. Recommended Fallback from UDP . . . . . . . . . . . . . . 8 67 6. Connection Establishment and Teardown . . . . . . . . . . . . 8 68 7. Interaction with NAT Detection Payloads . . . . . . . . . . . 10 69 8. Using MOBIKE with TCP encapsulation . . . . . . . . . . . . . 10 70 9. Using IKE Message Fragmentation with TCP encapsulation . . . 11 71 10. Considerations for Keep-alives and DPD . . . . . . . . . . . 11 72 11. Middlebox Considerations . . . . . . . . . . . . . . . . . . 11 73 12. Performance Considerations . . . . . . . . . . . . . . . . . 12 74 12.1. TCP-in-TCP . . . . . . . . . . . . . . . . . . . . . . . 12 75 12.2. Added Reliability for Unreliable Protocols . . . . . . . 12 76 12.3. Quality of Service Markings . . . . . . . . . . . . . . 12 77 12.4. Maximum Segment Size . . . . . . . . . . . . . . . . . . 12 78 13. Security Considerations . . . . . . . . . . . . . . . . . . . 13 79 14. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 80 15. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 14 81 16. References . . . . . . . . . . . . . . . . . . . . . . . . . 14 82 16.1. Normative References . . . . . . . . . . . . . . . . . . 14 83 16.2. Informative References . . . . . . . . . . . . . . . . . 14 84 Appendix A. Using TCP encapsulation with TLS . . . . . . . . . . 15 85 Appendix B. Example exchanges of TCP Encapsulation with TLS . . 16 86 B.1. Establishing an IKE session . . . . . . . . . . . . . . . 16 87 B.2. Deleting an IKE session . . . . . . . . . . . . . . . . . 17 88 B.3. Re-establishing an IKE session . . . . . . . . . . . . . 18 89 B.4. Using MOBIKE between UDP and TCP Encapsulation . . . . . 19 90 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 21 92 1. Introduction 94 IKEv2 [RFC7296] is a protocol for establishing IPsec Security 95 Associations (SAs), using IKE messages over UDP for control traffic, 96 and using Encapsulating Security Payload (ESP) messages for encrypted 97 data traffic. Many network middleboxes that filter traffic on public 98 hotspots block all UDP traffic, including IKE and IPsec, but allow 99 TCP connections through since they appear to be web traffic. Devices 100 on these networks that need to use IPsec (to access private 101 enterprise networks, to route voice-over-IP calls to carrier 102 networks, or because of security policies) are unable to establish 103 IPsec SAs. This document defines a method for encapsulating both the 104 IKE control messages as well as the IPsec data messages within a TCP 105 connection. 107 Using TCP as a transport for IPsec packets adds a third option to the 108 list of traditional IPsec transports: 110 1. Direct. Currently, IKE negotiations begin over UDP port 500. 111 If no NAT is detected between the Initiator and the Responder, 112 then subsequent IKE packets are sent over UDP port 500 and 113 IPsec data packets are sent using ESP [RFC4303]. 115 2. UDP Encapsulation [RFC3948]. If a NAT is detected between the 116 Initiator and the Responder, then subsequent IKE packets are 117 sent over UDP port 4500 with four bytes of zero at the start of 118 the UDP payload and ESP packets are sent out over UDP port 119 4500. Some peers default to using UDP encapsulation even when 120 no NAT are detected on the path as some middleboxes do not 121 support IP protocols other than TCP and UDP. 123 3. TCP Encapsulation. If both of the other two methods are not 124 available or appropriate, both IKE negotiation packets as well 125 as ESP packets can be sent over a single TCP connection to the 126 peer. 128 Direct use of ESP or UDP Encapsulation should be preferred by IKE 129 implementations due to performance concerns when using TCP 130 Encapsulation Section 12. Most implementations should use TCP 131 Encapsulation only on networks where negotiation over UDP has been 132 attempted without receiving responses from the peer, or if a network 133 is known to not support UDP. 135 1.1. Prior Work and Motivation 137 Encapsulating IKE connections within TCP streams is a common approach 138 to solve the problem of UDP packets being blocked by network 139 middleboxes. The goal of this document is to promote 140 interoperability by providing a standard method of framing IKE and 141 ESP message within streams, and to provide guidelines for how to 142 configure and use TCP encapsulation. 144 Some previous alternatives include: 146 Cellular Network Access Interworking Wireless LAN (IWLAN) uses IKEv2 147 to create secure connections to cellular carrier networks for 148 making voice calls and accessing other network services over 149 Wi-Fi networks. 3GPP has recommended that IKEv2 and ESP packets 150 be sent within a TLS connection to be able to establish 151 connections on restrictive networks. 153 ISAKMP over TCP Various non-standard extensions to ISAKMP have been 154 deployed that send IPsec traffic over TCP or TCP-like packets. 156 SSL VPNs Many proprietary VPN solutions use a combination of TLS and 157 IPsec in order to provide reliability. 159 IKEv2 over TCP IKEv2 over TCP as described in 160 [I-D.nir-ipsecme-ike-tcp] is used to avoid UDP fragmentation. 162 The goal of this specification is to provide a standardized method 163 for using TCP streams to transport IPsec that is compatible with the 164 current IKE standard, and avoids the overhead of other alternatives 165 that always rely on TCP or TLS. 167 1.2. Terminology and Notation 169 This document distinguishes between the IKE peer that initiates TCP 170 connections to be used for TCP encapsulation and the roles of 171 Initiator and Responder for particular IKE messages. During the 172 course of IKE exchanges, the role of IKE Initiator and Responder may 173 swap for a given SA (as with IKE SA Rekeys), while the initiator of 174 the TCP connection is still responsible for tearing down the TCP 175 connection and re-establishing it if necessary. For this reason, 176 this document will use the term "TCP Originator" to indicate the IKE 177 peer that initiates TCP connections. The peer that receives TCP 178 connections will be referred to as the "TCP Responder". If an IKE SA 179 is rekeyed one or more times, the TCP Originator MUST remain the peer 180 that originally initiated the first IKE SA. 182 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 183 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 184 document are to be interpreted as described in RFC 2119 [RFC2119]. 186 2. Configuration 188 One of the main reasons to use TCP encapsulation is that UDP traffic 189 may be entirely blocked on a network. Because of this, support for 190 TCP encapsulation is not specifically negotiated in the IKE exchange. 191 Instead, support for TCP encapsulation must be pre-configured on both 192 the TCP Originator and the TCP Responder. 194 The configuration defined on each peer should include the following 195 parameters: 197 o One or more TCP ports on which the TCP Responder will listen for 198 incoming connections. Note that the TCP Originator may initiate 199 TCP connections to the TCP Responder from any local port. The 200 ports on which the TCP Responder listens will likely be based on 201 the ports commonly allowed on restricted networks. 203 o Optionally, an extra framing protocol to use on top of TCP to 204 further encapsulate the stream of IKE and IPsec packets. See 205 Appendix A for a detailed discussion. 207 This document leaves the selection of TCP ports up to 208 implementations. It is suggested to use TCP port 4500, which is 209 allocated for IPsec NAT Traversal. 211 Since TCP encapsulation of IKE and IPsec packets adds overhead and 212 has potential performance trade-offs compared to direct or UDP- 213 encapsulated SAs (as described in Performance Considerations, 214 Section 12), implementations SHOULD prefer ESP direct or UDP 215 encapsulated SAs over TCP encapsulated SAs when possible. 217 3. TCP-Encapsulated Header Formats 219 Like UDP encapsulation, TCP encapsulation uses the first four bytes 220 of a message to differentiate IKE and ESP messages. TCP 221 encapsulation also adds a length field to define the boundaries of 222 messages within a stream. The message length is sent in a 16-bit 223 field that precedes every message. If the first 32-bits of the 224 message are zeros (a Non-ESP Marker), then the contents comprise an 225 IKE message. Otherwise, the contents comprise an ESP message. 226 Authentication Header (AH) messages are not supported for TCP 227 encapsulation. 229 Although a TCP stream may be able to send very long messages, 230 implementations SHOULD limit message lengths to typical UDP datagram 231 ESP payload lengths. The maximum message length is used as the 232 effective MTU for connections that are being encrypted using ESP, so 233 the maximum message length will influence characteristics of inner 234 connections, such as the TCP Maximum Segment Size (MSS). 236 Note that this method of encapsulation will also work for placing IKE 237 and ESP messages within any protocol that presents a stream 238 abstraction, beyond TCP. 240 3.1. TCP-Encapsulated IKE Header Format 242 1 2 3 243 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 244 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 245 | Length | 246 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 247 | Non-ESP Marker | 248 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 249 | | 250 ~ IKE header [RFC7296] ~ 251 | | 252 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 254 Figure 1 256 The IKE header is preceded by a 16-bit length field in network byte 257 order that specifies the length of the IKE message (including the 258 Non-ESP marker) within the TCP stream. As with IKE over UDP port 259 4500, a zeroed 32-bit Non-ESP Marker is inserted before the start of 260 the IKE header in order to differentiate the traffic from ESP traffic 261 between the same addresses and ports. 263 o Length (2 octets, unsigned integer) - Length of the IKE packet 264 including the Length Field and Non-ESP Marker. 266 3.2. TCP-Encapsulated ESP Header Format 268 1 2 3 269 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 270 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 271 | Length | 272 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 273 | | 274 ~ ESP header [RFC4303] ~ 275 | | 276 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 278 Figure 2 280 The ESP header is preceded by a 16-bit length field in network byte 281 order that specifies the length of the ESP packet within the TCP 282 stream. 284 The SPI field in the ESP header MUST NOT be a zero value. 286 o Length (2 octets, unsigned integer) - Length of the ESP packet 287 including the Length Field. 289 4. TCP-Encapsulated Stream Prefix 291 Each stream of bytes used for IKE and IPsec encapsulation MUST begin 292 with a fixed sequence of six bytes as a magic value, containing the 293 characters "IKETCP" as ASCII values. This allows peers to 294 differentiate this protocol from other protocols that may be run over 295 the same TCP port. Since TCP encapsulated IPsec is not assigned to a 296 specific port, TCP Responders may be able to receive multiple 297 protocols on the same port. The bytes of the stream prefix do not 298 overlap with the valid start of any other known stream protocol. 299 This value is only sent once, by the TCP Originator only, at the 300 beginning of any stream of IKE and ESP messages. 302 If other framing protocols are used within TCP to further encapsulate 303 or encrypt the stream of IKE and ESP messages, the Stream Prefix must 304 be at the start of the TCP Originator's IKE and ESP message stream 305 within the added protocol layer [Appendix A]. Although some framing 306 protocols do support negotiating inner protocols, the stream prefix 307 should always be used in order for implementations to be as generic 308 as possible and not rely on other framing protocols on top of TCP. 310 0 1 2 3 4 5 311 +------+------+------+------+------+------+ 312 | 0x49 | 0x4b | 0x45 | 0x54 | 0x43 | 0x50 | 313 +------+------+------+------+------+------+ 315 Figure 3 317 5. Applicability 319 TCP encapsulation is applicable only when it has been configured to 320 be used with specific IKE peers. If a Responder is configured to use 321 TCP encapsulation, it MUST listen on the configured port(s) in case 322 any peers will initiate new IKE sessions. Initiators MAY use TCP 323 encapsulation for any IKE session to a peer that is configured to 324 support TCP encapsulation, although it is recommended that Initiators 325 should only use TCP encapsulation when traffic over UDP is blocked. 327 Since the support of TCP encapsulation is a configured property, not 328 a negotiated one, it is recommended that if there are multiple IKE 329 endpoints representing a single peer (such as multiple machines with 330 different IP addresses when connecting by Fully-Qualified Domain 331 Name, or endpoints used with IKE redirection), all of the endpoints 332 equally support TCP encapsulation. 334 If TCP encapsulation is being used for a specific IKE SA, all 335 messages for that IKE SA and its Child SAs MUST be sent over a TCP 336 connection until the SA is deleted or MOBIKE is used to change the SA 337 endpoints and/or encapsulation protocol. See Section 8 for more 338 details on using MOBIKE to transition between encapsulation modes. 340 5.1. Recommended Fallback from UDP 342 Since UDP is the preferred method of transport for IKE messages, 343 implementations that use TCP encapsulation should have an algorithm 344 for deciding when to use TCP after determining that UDP is unusable. 345 If an Initiator implementation has no prior knowledge about the 346 network it is on and the status of UDP on that network, it SHOULD 347 always attempt negotiate IKE over UDP first. IKEv2 defines how to 348 use retransmission timers with IKE messages, and IKE_SA_INIT messages 349 specifically [RFC7296]. Generally, this means that the 350 implementation will define a frequency of retransmission, and the 351 maximum number of retransmissions allowed before marking the IKE SA 352 as failed. An implementation can attempt negotiation over TCP once 353 it has hit the maximum retransmissions over UDP, or slightly before 354 to reduce connection setup delays. It is recommended that the 355 initial message over UDP is retransmitted at least once before 356 falling back to TCP, unless the Initiator knows beforehand that the 357 network is likely to block UDP. 359 6. Connection Establishment and Teardown 361 When the IKE Initiator uses TCP encapsulation, it will initiate a TCP 362 connection to the Responder using the configured TCP port. The first 363 bytes sent on the stream MUST be the stream prefix value [Section 4]. 364 After this prefix, encapsulated IKE messages will negotiate the IKE 365 SA and initial Child SA [RFC7296]. After this point, both 366 encapsulated IKE Figure 1 and ESP Figure 2 messages will be sent over 367 the TCP connection. The TCP Responder MUST wait for the entire 368 stream prefix to be received on the stream before trying to parse out 369 any IKE or ESP messages. The stream prefix is sent only once, and 370 only by the TCP Originator. 372 In order to close an IKE session, either the Initiator or Responder 373 SHOULD gracefully tear down IKE SAs with DELETE payloads. Once the 374 SA has been deleted, the TCP Originator SHOULD close the TCP 375 connection if it does not intend to use the connection for another 376 IKE session to the TCP Responder. If the connection is left idle, 377 and the TCP Responder needs to clean up resources, the TCP Responder 378 MAY close the TCP connection. 380 An unexpected FIN or a RST on the TCP connection may indicate either 381 a loss of connectivity, an attack, or some other error. If a DELETE 382 payload has not been sent, both sides SHOULD maintain the state for 383 their SAs for the standard lifetime or time-out period. The TCP 384 Originator is responsible for re-establishing the TCP connection if 385 it is torn down for any unexpected reason. Since new TCP connections 386 may use different ports due to NAT mappings or local port allocations 387 changing, the TCP Responder MUST allow packets for existing SAs to be 388 received from new source ports. 390 A peer MUST discard a partially received message due to a broken 391 connection. 393 Whenever the TCP Originator opens a new TCP connection to be used for 394 an existing IKE SA, it MUST send the stream prefix first, before any 395 IKE or ESP messages. This follows the same behavior as the initial 396 TCP connection. 398 If a TCP connection is being used to resume a previous IKE session, 399 the TCP Responder can recognize the session using either the IKE SPI 400 from an encapsulated IKE message or the ESP SPI from an encapsulated 401 ESP message. If the session had been fully established previously, 402 it is suggested that the TCP Originator send an UPDATE_SA_ADDRESSES 403 message if MOBIKE is supported, or an INFORMATIONAL message (a 404 keepalive) otherwise. If either TCP Originator or TCP Responder 405 receives a stream that cannot be parsed correctly (for example, if 406 the TCP Originator stream is missing the stream prefix, or message 407 frames are not parsable as IKE or ESP messages), it MUST close the 408 TCP connection. If there is instead a syntax issue within an IKE 409 message, an implementation MUST send the INVALID_SYNTAX notify 410 payload and tear down the IKE SA as usual, rather than tearing down 411 the TCP connection directly. 413 An TCP Originator SHOULD only open one TCP connection per IKE SA, 414 over which it sends all of the corresponding IKE and ESP messages. 415 This helps ensure that any firewall or NAT mappings allocated for the 416 TCP connection apply to all of the traffic associated with the IKE SA 417 equally. 419 Similarly, a TCP Responder SHOULD at any given time send packets for 420 an IKE SA and its Child SAs over only one TCP connection. It SHOULD 421 choose the TCP connection on which it last received a valid and 422 decryptable IKE or ESP message. In order to be considered valid for 423 choosing a TCP connection, an IKE message must be successfully 424 decrypted and authenticated, not be a retransmission of a previously 425 received message, and be within the expected window for IKE message 426 IDs. Similarly, an ESP message must pass authentication checks and 427 be decrypted, not be a replay of a previous message. 429 Since a connection may be broken and a new connection re-established 430 by the TCP Originator without the TCP Responder being aware, a TCP 431 Responder SHOULD accept receiving IKE and ESP messages on both old 432 and new connections until the old connection is closed by the TCP 433 Originator. A TCP Responder MAY close a TCP connection that it 434 perceives as idle and extraneous (one previously used for IKE and ESP 435 messages that has been replaced by a new connection). 437 Multiple IKE SAs MUST NOT share a single TCP connection, unless one 438 is a rekey of an existing IKE SA, in which case there will 439 temporarily be two IKE SAs on the same TCP connection. 441 7. Interaction with NAT Detection Payloads 443 When negotiating over UDP port 500, IKE_SA_INIT packets include 444 NAT_DETECTION_SOURCE_IP and NAT_DETECTION_DESTINATION_IP payloads to 445 determine if UDP encapsulation of IPsec packets should be used. 446 These payloads contain SHA-1 digests of the SPIs, IP addresses, and 447 ports as defined in [RFC7296]. IKE_SA_INIT packets sent on a TCP 448 connection SHOULD include these payloads with the same content as 449 when sending over UDP, and SHOULD use the applicable TCP ports when 450 creating and checking the SHA-1 digests. 452 If a NAT is detected due to the SHA-1 digests not matching the 453 expected values, no change should be made for encapsulation of 454 subsequent IKE or ESP packets, since TCP encapsulation inherently 455 supports NAT traversal. Implementations MAY use the information that 456 a NAT is present to influence keep-alive timer values. 458 If a NAT is detected, implementations need to handle transport mode 459 TCP and UDP packet checksum fixup as defined for UDP encapsulation in 460 [RFC3948]. 462 8. Using MOBIKE with TCP encapsulation 464 When an IKE session that has negotiated MOBIKE [RFC4555] is 465 transitioning between networks, the Initiator of the transition may 466 switch between using TCP encapsulation, UDP encapsulation, or no 467 encapsulation. Implementations that implement both MOBIKE and TCP 468 encapsulation MUST support dynamically enabling and disabling TCP 469 encapsulation as interfaces change. 471 When a MOBIKE-enabled Initiator changes networks, the 472 UPDATE_SA_ADDRESSES notification SHOULD be sent out first over UDP 473 before attempting over TCP. If there is a response to the 474 UPDATE_SA_ADDRESSES notification sent over UDP, then the ESP packets 475 should be sent directly over IP or over UDP port 4500 (depending on 476 if a NAT was detected), regardless of if a connection on a previous 477 network was using TCP encapsulation. Similarly, if the Responder 478 only responds to the UPDATE_SA_ADDRESSES notification over TCP, then 479 the ESP packets should be sent over the TCP connection, regardless of 480 if a connection on a previous network did not use TCP encapsulation. 482 9. Using IKE Message Fragmentation with TCP encapsulation 484 IKE Message Fragmentation [RFC7383] is not required when using TCP 485 encapsulation, since a TCP stream already handles the fragmentation 486 of its contents across packets. Since fragmentation is redundant in 487 this case, implementations might choose to not negotiate IKE 488 fragmentation. Even if fragmentation is negotiated, an 489 implementation SHOULD NOT send fragments when going over a TCP 490 connection, although it MUST support receiving fragments. 492 If an implementation supports both MOBIKE and IKE fragmentation, it 493 SHOULD negotiate IKE fragmentation over a TCP encapsulated session in 494 case the session switches to UDP encapsulation on another network. 496 10. Considerations for Keep-alives and DPD 498 Encapsulating IKE and IPsec inside of a TCP connection can impact the 499 strategy that implementations use to detect peer liveness and to 500 maintain middlebox port mappings. Peer liveness should be checked 501 using IKE Informational packets [RFC7296]. 503 In general, TCP port mappings are maintained by NATs longer than UDP 504 port mappings, so IPsec ESP NAT keep-alives [RFC3948] SHOULD NOT be 505 sent when using TCP encapsulation. Any implementation using TCP 506 encapsulation MUST silently drop incoming NAT keep-alive packets, and 507 not treat them as errors. NAT keep-alive packets over a TCP 508 encapsulated IPsec connection will be sent with a length value of 1 509 byte, whose value is 0xFF Figure 2. 511 Note that depending on the configuration of TCP and TLS on the 512 connection, TCP keep-alives [RFC1122] and TLS keep-alives [RFC6520] 513 may be used. These MUST NOT be used as indications of IKE peer 514 liveness. 516 11. Middlebox Considerations 518 Many security networking devices such as Firewalls or Intrusion 519 Prevention Systems, network optimization/acceleration devices and 520 Network Address Translation (NAT) devices keep the state of sessions 521 that traverse through them. 523 These devices commonly track the transport layer and/or the 524 application layer data to drop traffic that is anomalous or malicious 525 in nature. 527 A network device that monitors up to the application layer will 528 commonly expect to see HTTP traffic within a TCP socket running over 529 port 80, if non-HTTP traffic is seen (such as TCP encapsulated IKE), 530 this could be dropped by the security device. 532 A network device that monitors the transport layer will track the 533 state of TCP sessions, such as TCP sequence numbers. TCP 534 encapsulation of IKE should therefore use standard TCP behaviors to 535 avoid being dropped by middleboxes. 537 12. Performance Considerations 539 Several aspects of TCP encapsulation for IKE and IPsec packets may 540 negatively impact the performance of connections within a tunnel-mode 541 IPsec SA. Implementations should be aware of these and take these 542 into consideration when determining when to use TCP encapsulation. 544 12.1. TCP-in-TCP 546 If the outer connection between IKE peers is over TCP, inner TCP 547 connections may suffer effects from using TCP within TCP. In 548 particular, the inner TCP's round-trip-time estimation will be 549 affected by the burstiness of the outer TCP. This will make loss- 550 recovery of the inner TCP traffic less reactive and more prone to 551 spurious retransmission timeouts. 553 12.2. Added Reliability for Unreliable Protocols 555 Since ESP is an unreliable protocol, transmitting ESP packets over a 556 TCP connection will change the fundamental behavior of the packets. 557 Some application-level protocols that prefer packet loss to delay 558 (such as Voice over IP or other real-time protocols) may be 559 negatively impacted if their packets are retransmitted by the TCP 560 connection due to packet loss. 562 12.3. Quality of Service Markings 564 Quality of Service (QoS) markings, such as DSCP and Traffic Class, 565 should be used with care on TCP connections used for encapsulation. 566 Individual packets SHOULD NOT use different markings than the rest of 567 the connection, since packets with different priorities may be routed 568 differently and cause unnecessary delays in the connection. 570 12.4. Maximum Segment Size 572 A TCP connection used for IKE encapsulation SHOULD negotiate its 573 maximum segment size (MSS) in order to avoid unnecessary 574 fragmentation of packets. 576 13. Security Considerations 578 IKE Responders that support TCP encapsulation may become vulnerable 579 to new Denial-of-Service (DoS) attacks that are specific to TCP, such 580 as SYN-flooding attacks. TCP Responders should be aware of this 581 additional attack-surface. 583 TCP Responders should be careful to ensure that the stream prefix 584 "IKETCP" uniquely identifies streams using the TCP encapsulation 585 protocol. The prefix was chosen to not overlap with the start of any 586 known valid protocol over TCP, but implementations should make sure 587 to validate this assumption in order to avoid unexpected processing 588 of TCP connections. 590 Attackers may be able to disrupt the TCP connection by sending 591 spurious RST packets. Due to this, implementations SHOULD make sure 592 that IKE session state persists even if the underlying TCP connection 593 is torn down. 595 If MOBIKE is being used, all of the security considerations outlined 596 for MOBIKE apply [RFC4555]. 598 Similarly to MOBIKE, TCP encapsulation requires a TCP Responder to 599 handle changing of source address and port due to network or 600 connection disruption. The successful delivery of valid IKE or ESP 601 messages over a new TCP connection is used by the TCP Responder to 602 determine where to send subsequent responses. If an attacker is able 603 to send packets on a new TCP connection that pass the validation 604 checks of the TCP Responder, it can influence which path future 605 packets take. For this reason, the validation of messages on the TCP 606 Responder must include decryption, authentication, and replay checks. 608 Since TCP provides a reliable, in-order delivery of ESP messages, the 609 ESP Anti-Replay Window size SHOULD be set to 1. See [RFC4303] for a 610 complete description of the ESP Anti-Replay Window. This increases 611 the protection of implementations against replay attacks. 613 14. IANA Considerations 615 This memo includes no request to IANA. 617 TCP port 4500 is already allocated to IPsec. This port MAY be used 618 for the protocol described in this document, but implementations MAY 619 prefer to use other ports based on local policy. 621 15. Acknowledgments 623 The authors would like to acknowledge the input and advice of Stuart 624 Cheshire, Delziel Fernandes, Yoav Nir, Christoph Paasch, Yaron 625 Sheffer, David Schinazi, Graham Bartlett, Byju Pularikkal, March Wu, 626 Kingwel Xie, Valery Smyslov, Jun Hu, and Tero Kivinen. Special 627 thanks to Eric Kinnear for his implementation work. 629 16. References 631 16.1. Normative References 633 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 634 Requirement Levels", BCP 14, RFC 2119, 635 DOI 10.17487/RFC2119, March 1997, 636 . 638 [RFC3948] Huttunen, A., Swander, B., Volpe, V., DiBurro, L., and M. 639 Stenberg, "UDP Encapsulation of IPsec ESP Packets", 640 RFC 3948, DOI 10.17487/RFC3948, January 2005, 641 . 643 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 644 RFC 4303, DOI 10.17487/RFC4303, December 2005, 645 . 647 [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. 648 Kivinen, "Internet Key Exchange Protocol Version 2 649 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 650 2014, . 652 16.2. Informative References 654 [I-D.nir-ipsecme-ike-tcp] 655 Nir, Y., "A TCP transport for the Internet Key Exchange", 656 draft-nir-ipsecme-ike-tcp-01 (work in progress), July 657 2012. 659 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 660 Communication Layers", STD 3, RFC 1122, 661 DOI 10.17487/RFC1122, October 1989, 662 . 664 [RFC2817] Khare, R. and S. Lawrence, "Upgrading to TLS Within 665 HTTP/1.1", RFC 2817, DOI 10.17487/RFC2817, May 2000, 666 . 668 [RFC4555] Eronen, P., "IKEv2 Mobility and Multihoming Protocol 669 (MOBIKE)", RFC 4555, DOI 10.17487/RFC4555, June 2006, 670 . 672 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 673 (TLS) Protocol Version 1.2", RFC 5246, 674 DOI 10.17487/RFC5246, August 2008, 675 . 677 [RFC6520] Seggelmann, R., Tuexen, M., and M. Williams, "Transport 678 Layer Security (TLS) and Datagram Transport Layer Security 679 (DTLS) Heartbeat Extension", RFC 6520, 680 DOI 10.17487/RFC6520, February 2012, 681 . 683 [RFC7383] Smyslov, V., "Internet Key Exchange Protocol Version 2 684 (IKEv2) Message Fragmentation", RFC 7383, 685 DOI 10.17487/RFC7383, November 2014, 686 . 688 Appendix A. Using TCP encapsulation with TLS 690 This section provides recommendations on the support of TLS with the 691 TCP encapsulation. 693 When using TCP encapsulation, implementations may choose to use TLS 694 [RFC5246], to be able to traverse middle-boxes, which may block non- 695 HTTP traffic. 697 If a web proxy is applied to the ports for the TCP connection, and 698 TLS is being used, the TCP Originator can send an HTTP CONNECT 699 message to establish an SA through the proxy [RFC2817]. 701 The use of TLS should be configurable on the peers, and may be used 702 as the default when using TCP encapsulation, or else be a fallback 703 when basic TCP encapsulation fails. The TCP Responder may expect to 704 read encapsulated IKE and ESP packets directly from the TCP 705 connection, or it may expect to read them from a stream of TLS data 706 packets. The TCP Originator should be pre-configured to use TLS or 707 not when communicating with a given port on the TCP Responder. 709 When new TCP connections are re-established due to a broken 710 connection, TLS must be re-negotiated. TLS Session Resumption is 711 recommended to improve efficiency in this case. 713 The security of the IKE session is entirely derived from the IKE 714 negotiation and key establishment and not from the TLS session (which 715 in this context is only used for encapsulation purposes), therefore 716 when TLS is used on the TCP connection, both the TCP Originator and 717 TCP Responder SHOULD allow the NULL cipher to be selected for 718 performance reasons. 720 Implementations should be aware that the use of TLS introduces 721 another layer of overhead requiring more bytes to transmit a given 722 IKE and IPsec packet. For this reason, direct ESP, UDP 723 encapsulation, or TCP encapsulation without TLS should be preferred 724 in situations in which TLS is not required in order to traverse 725 middle-boxes. 727 Appendix B. Example exchanges of TCP Encapsulation with TLS 729 B.1. Establishing an IKE session 731 Client Server 732 ---------- ---------- 733 1) -------------------- TCP Connection ------------------- 734 (IP_I:Port_I -> IP_R:TCP443 or TCP4500) 735 TcpSyn ----------> 736 <---------- TcpSyn,Ack 737 TcpAck ----------> 739 2) --------------------- TLS Session --------------------- 740 ClientHello ----------> 741 ServerHello 742 Certificate* 743 ServerKeyExchange* 744 <---------- ServerHelloDone 745 ClientKeyExchange 746 CertificateVerify* 747 [ChangeCipherSpec] 748 Finished ----------> 749 [ChangeCipherSpec] 750 <---------- Finished 752 3) ---------------------- Stream Prefix -------------------- 753 "IKETCP" ----------> 754 4) ----------------------- IKE Session --------------------- 755 Length + Non-ESP Marker ----------> 756 IKE_SA_INIT 757 HDR, SAi1, KEi, Ni, 758 [N(NAT_DETECTION_*_IP)] 759 <------ Length + Non-ESP Marker 760 IKE_SA_INIT 761 HDR, SAr1, KEr, Nr, 762 [N(NAT_DETECTION_*_IP)] 763 Length + Non-ESP Marker ----------> 764 first IKE_AUTH 765 HDR, SK {IDi, [CERTREQ] 766 CP(CFG_REQUEST), IDr, 767 SAi2, TSi, TSr, ...} 768 <------ Length + Non-ESP Marker 769 first IKE_AUTH 770 HDR, SK {IDr, [CERT], AUTH, 771 EAP, SAr2, TSi, TSr} 772 Length + Non-ESP Marker ----------> 773 IKE_AUTH + EAP 774 repeat 1..N times 775 <------ Length + Non-ESP Marker 776 IKE_AUTH + EAP 777 Length + Non-ESP Marker ----------> 778 final IKE_AUTH 779 HDR, SK {AUTH} 780 <------ Length + Non-ESP Marker 781 final IKE_AUTH 782 HDR, SK {AUTH, CP(CFG_REPLY), 783 SA, TSi, TSr, ...} 784 -------------- IKE and IPsec SAs Established ------------ 785 Length + ESP frame ----------> 787 Figure 4 789 1. Client establishes a TCP connection with the server on port 443 790 or 4500. 792 2. Client initiates TLS handshake. During TLS handshake, the 793 server SHOULD NOT request the client's' certificate, since 794 authentication is handled as part of IKE negotiation. 796 3. Client send the Stream Prefix for TCP encapsulated IKE 797 Section 4 traffic to signal the beginning of IKE negotiation. 799 4. Client and server establish an IKE connection. This example 800 shows EAP-based authentication, although any authentication 801 type may be used. 803 B.2. Deleting an IKE session 804 Client Server 805 ---------- ---------- 806 1) ----------------------- IKE Session --------------------- 807 Length + Non-ESP Marker ----------> 808 INFORMATIONAL 809 HDR, SK {[N,] [D,] 810 [CP,] ...} 811 <------ Length + Non-ESP Marker 812 INFORMATIONAL 813 HDR, SK {[N,] [D,] 814 [CP], ...} 816 2) --------------------- TLS Session --------------------- 817 close_notify ----------> 818 <---------- close_notify 819 3) -------------------- TCP Connection ------------------- 820 TcpFin ----------> 821 <---------- Ack 822 <---------- TcpFin 823 Ack ----------> 824 --------------------- IKE SA Deleted ------------------- 826 Figure 5 828 1. Client and server exchange INFORMATIONAL messages to notify IKE 829 SA deletion. 831 2. Client and server negotiate TLS session deletion using TLS 832 CLOSE_NOTIFY. 834 3. The TCP connection is torn down. 836 The deletion of the IKE SA should lead to the disposal of the 837 underlying TLS and TCP state. 839 B.3. Re-establishing an IKE session 840 Client Server 841 ---------- ---------- 842 1) -------------------- TCP Connection ------------------- 843 (IP_I:Port_I -> IP_R:TCP443 or TCP4500) 844 TcpSyn ----------> 845 <---------- TcpSyn,Ack 846 TcpAck ----------> 847 2) --------------------- TLS Session --------------------- 848 ClientHello ----------> 849 <---------- ServerHello 850 [ChangeCipherSpec] 851 Finished 852 [ChangeCipherSpec] ----------> 853 Finished 854 3) ---------------------- Stream Prefix -------------------- 855 "IKETCP" ----------> 856 4) <---------------------> IKE/ESP flow <------------------> 857 Length + ESP frame ----------> 859 Figure 6 861 1. If a previous TCP connection was broken (for example, due to a 862 RST), the client is responsible for re-initiating the TCP 863 connection. The TCP Originator's address and port (IP_I and 864 Port_I) may be different from the previous connection's address 865 and port. 867 2. In ClientHello TLS message, the client SHOULD send the Session 868 ID it received in the previous TLS handshake if available. It 869 is up to the server to perform either an abbreviated handshake 870 or full handshake based on the session ID match. 872 3. After TCP and TLS are complete, the client sends the Stream 873 Prefix for TCP encapsulated IKE traffic Section 4. 875 4. The IKE and ESP packet flow can resume. If MOBIKE is being 876 used, the Initiator SHOULD send UPDATE_SA_ADDRESSES. 878 B.4. Using MOBIKE between UDP and TCP Encapsulation 880 Client Server 881 ---------- ---------- 882 (IP_I1:UDP500 -> IP_R:UDP500) 883 1) ----------------- IKE_SA_INIT Exchange ----------------- 884 (IP_I1:UDP4500 -> IP_R:UDP4500) 885 Non-ESP Marker -----------> 886 Initial IKE_AUTH 887 HDR, SK { IDi, CERT, AUTH, 888 CP(CFG_REQUEST), 889 SAi2, TSi, TSr, 890 N(MOBIKE_SUPPORTED) } 891 <----------- Non-ESP Marker 892 Initial IKE_AUTH 893 HDR, SK { IDr, CERT, AUTH, 894 EAP, SAr2, TSi, TSr, 895 N(MOBIKE_SUPPORTED) } 896 <------------------ IKE SA establishment ---------------> 898 2) ------------ MOBIKE Attempt on new network -------------- 899 (IP_I2:UDP4500 -> IP_R:UDP4500) 900 Non-ESP Marker -----------> 901 INFORMATIONAL 902 HDR, SK { N(UPDATE_SA_ADDRESSES), 903 N(NAT_DETECTION_SOURCE_IP), 904 N(NAT_DETECTION_DESTINATION_IP) } 906 3) -------------------- TCP Connection ------------------- 907 (IP_I2:PORT_I -> IP_R:TCP443 or TCP4500) 908 TcpSyn -----------> 909 <----------- TcpSyn,Ack 910 TcpAck -----------> 912 4) --------------------- TLS Session --------------------- 913 ClientHello -----------> 914 ServerHello 915 Certificate* 916 ServerKeyExchange* 917 <----------- ServerHelloDone 918 ClientKeyExchange 919 CertificateVerify* 920 [ChangeCipherSpec] 921 Finished -----------> 922 [ChangeCipherSpec] 923 <----------- Finished 924 5) ---------------------- Stream Prefix -------------------- 925 "IKETCP" ----------> 927 6) ----------------------- IKE Session --------------------- 928 Length + Non-ESP Marker -----------> 929 INFORMATIONAL (Same as step 2) 930 HDR, SK { N(UPDATE_SA_ADDRESSES), 931 N(NAT_DETECTION_SOURCE_IP), 932 N(NAT_DETECTION_DESTINATION_IP) } 933 <------- Length + Non-ESP Marker 934 HDR, SK { N(NAT_DETECTION_SOURCE_IP), 935 N(NAT_DETECTION_DESTINATION_IP) } 936 7) <----------------- IKE/ESP data flow -------------------> 938 Figure 7 940 1. During the IKE_SA_INIT exchange, the client and server exchange 941 MOBIKE_SUPPORTED notify payloads to indicate support for 942 MOBIKE. 944 2. The client changes its point of attachment to the network, and 945 receives a new IP address. The client attempts to re-establish 946 the IKE session using the UPDATE_SA_ADDRESSES notify payload, 947 but the server does not respond because the network blocks UDP 948 traffic. 950 3. The client brings up a TCP connection to the server in order to 951 use TCP encapsulation. 953 4. The client initiates and TLS handshake with the server. 955 5. The client sends the Stream Prefix for TCP encapsulated IKE 956 traffic Section 4. 958 6. The client sends the UPDATE_SA_ADDRESSES notify payload on the 959 TCP encapsulated connection. Note that this IKE message is the 960 same as the one sent over UDP in step 2, and should have the 961 same message ID and contents. 963 7. The IKE and ESP packet flow can resume. 965 Authors' Addresses 967 Tommy Pauly 968 Apple Inc. 969 1 Infinite Loop 970 Cupertino, California 95014 971 US 973 Email: tpauly@apple.com 974 Samy Touati 975 Ericsson 976 2755 Augustine 977 Santa Clara, California 95054 978 US 980 Email: samy.touati@ericsson.com 982 Ravi Mantha 983 Cisco Systems 984 SEZ, Embassy Tech Village 985 Panathur, Bangalore 560 037 986 India 988 Email: ramantha@cisco.com