Network T. Pauly Internet-Draft Apple Inc. Intended status: Standards Track S. Touati Expires: March 13, 2016 Ericsson September 10, 2015 TCP Encapsulation of IKEv2 and IPSec Packets draft-pauly-ipsecme-tcp-encaps-00 Abstract This document describes a method to transport IKEv2 and IPSec packets over a TCP connection for traversing network middleboxes that may block IKEv2 negotiation over UDP. This method, referred to as TCP encapsulation, involves sending all packets for tunnel establishment as well as tunneled packets over a TCP connection. Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on March 13, 2016. Copyright Notice Copyright (c) 2015 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of Pauly & Touati Expires March 13, 2016 [Page 1] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. Requirements Language . . . . . . . . . . . . . . . . . . 3 2. Configuration . . . . . . . . . . . . . . . . . . . . . . . . 3 3. TCP-Encapsulated Header Formats . . . . . . . . . . . . . . . 4 3.1. TCP-Encapsulated IKEv2 Header Format . . . . . . . . . . 4 3.2. TCP-Encapsulated ESP Header Format . . . . . . . . . . . 4 4. Applicability . . . . . . . . . . . . . . . . . . . . . . . . 5 5. Connection Establishment and Teardown . . . . . . . . . . . . 5 6. Interaction with NAT Detection Payloads . . . . . . . . . . . 6 7. Considerations for Keep-alives and DPD . . . . . . . . . . . 6 8. Using MOBIKE with TCP encapsulation . . . . . . . . . . . . . 7 9. Performance Considerations . . . . . . . . . . . . . . . . . 7 9.1. TCP-in-TCP . . . . . . . . . . . . . . . . . . . . . . . 7 9.2. Added Reliability for Unreliable Protocols . . . . . . . 7 9.3. Encryption Overhead . . . . . . . . . . . . . . . . . . . 8 10. Security Considerations . . . . . . . . . . . . . . . . . . . 8 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 8 12. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 8 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 9 13.1. Normative References . . . . . . . . . . . . . . . . . . 9 13.2. Informative References . . . . . . . . . . . . . . . . . 9 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 10 1. Introduction IKEv2 [RFC7296] is a protocol for establishing IPSec tunnels, using IKE messages over UDP for control traffic, and using ESP messages (or ESP over UDP) for its data traffic. Many network middleboxes that filter traffic on public hotspots block all UDP traffic, including IKEv2 and IPSec, but allow TCP connections through since they appear to be web traffic. Devices on these networks that need to use IPSec (to access private enterprise networks, to route voice-over-IP calls to carrier networks, or because of security policies) are unable to establish IPSec tunnels. This document defines a method for encapsulating both the IKEv2 control messages as well as the IPSec data messages within a TCP connection. Using TCP as a transport for IPSec packets adds a third option to the list of traditional IPSec transports: 1. Direct. Currently, IKEv2 negotiations begin over UDP port 500. If no NAT is detected between the initiator and the receiver, Pauly & Touati Expires March 13, 2016 [Page 2] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 then subsequent IKEv2 packets are sent over UDP port 500 and IPSec data packets are sent using ESP [RFC4303]. 2. UDP Encapsulation [RFC3948]. If a NAT is detected between the initiator and the receiver, then subsequent IKEv2 packets are sent over UDP port 4500 with four bytes of zero at the start of the UDP payload and ESP packets are sent out over UDP port 4500. 3. TCP Encapsulation. If both of the other two methods are not available or appropriate, both IKEv2 negotiation packets as well as ESP packets can be sent over a single TCP connection to the peer. This connection can itself use TLS [RFC5246] or other methods if needed. If the connection uses TLS, it will also be capable of traversing a web proxy [RFC2817]. 1.1. Requirements Language The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119]. 2. Configuration One of the main reasons to use TCP encapsulation is that UDP traffic may be entirely blocked on a network. Because of this, support for TCP encapsulation is not specifically negotiated in the IKEv2 exchange. Instead, support for TCP encapsulation must be pre- configured on both the initiator and the responder. The configuration defined on each peer should include the following parameters: o One or more TCP ports on which the responder will listen for incoming connections. Note that the initiator may initiate TCP connections to the responder from any local port. o Whether or not to use TLS for connections to a given TCP port. The responder may expect to read encapsulated IKEv2 and ESP packets directly from the TCP connection, or it may expect to read them from a stream of TLS data packets. The initiator should be pre-configured to use TLS or not when communicating with a given port on the responder. Since TCP encapsulation of IKEv2 and IPSec packets adds overhead and has potential performance trade-offs compared to direct or UDP- encapsulated tunnels (as described in Performance Considerations, Section 8), implementations SHOULD prefer IKEv2 negotiation over UDP. Pauly & Touati Expires March 13, 2016 [Page 3] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 3. TCP-Encapsulated Header Formats 3.1. TCP-Encapsulated IKEv2 Header Format 1 2 3 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Non-ESP Marker | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | IKEv2 header [RFC7296] | ~ ~ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 1 The IKE header is preceded by a 32-bit length field in network byte order that specifies the length of the IKE packet within the TCP stream. As with IKEv2 over UDP port 4500, a zeroed 32-bit Non-ESP Marker is inserted before the start of the IKEv2 header in order to differentiate the traffic from ESP traffic between the same addresses and ports. o Length (4 octets, unsigned integer) - Length of the IKE packet including the Length Field and Non-ESP Marker. 3.2. TCP-Encapsulated ESP Header Format 1 2 3 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ESP header [RFC4303] | ~ ~ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 2 The ESP header is preceded by a 32-bit length field in network byte order that specifies the length of the ESP packet within the TCP stream. o Length (4 octets, unsigned integer) - Length of the ESP packet including the Length Field. Pauly & Touati Expires March 13, 2016 [Page 4] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 4. Applicability TCP encapsulation is applicable only when it has been configured to be used with specific IKEv2 peers. If a responder is configured to use TCP encapsulation, it MUST listen on the configured port(s) in case any peers will initiate new IKEv2 sessions. Initiators MAY use TCP encapsulation for any IKEv2 session to a peer that is configured to support TCP encapsulation, although it is recommended that initiators should only use TCP encapsulation when traffic over UDP is blocked. Any specific IKE SA, along with its Child SAs, is either TCP encapsulated or not. A mix of TCP and UDP encapsulation for a single SA is not allowed. The exception to this rule is SAs that are migrated between addresses using MOBIKE (Section 8). 5. Connection Establishment and Teardown When the initiator decides to use TCP encapsulation for IKEv2 negotiation, the initiator will initiate a TCP connection with the responder using the configured TCP port. If TLS is being used, it may be negotiated at this point, although the policy for the TLS negotiation is out of scope of this document. If a web proxy is applied to the ports for the TCP connection, and TLS is being used, the initiator can send an HTTP CONNECT message to establish a tunnel through the proxy [RFC2817] Before either initiator or responder closes the TCP connection by sending a FIN or a RST, session teardown SHOULD be gracefully negotiated with DELETE payloads. Once all SAs have been deleted, the initiator of the original connection MUST close the TCP connection. An unexpected FIN or a RST on the TCP connection may indicate either a loss of connectivity, an attack, or some other error. If a DELETE payload has not been sent, both sides SHOULD maintain the state for their SAs for the standard lifetime or time-out period. The original initiator (that is, the endpoint that initiated the TCP connection and sent the first IKE_SA_INIT message) is responsible for re- establishing the TCP connection if it is torn down for any unexpected reason. Since new TCP connections may use different ports due to NAT mappings or local port allocations changing, the responder MUST allow packets for existing SAs to be received from new source ports. The streams of data sent over any TCP connection used for this protocol MUST begin with a complete IKEv2 or ESP message, complying to the format specified in Figure 1 and Figure 2. If either initiator or responder receives a stream that cannot be parsed correctly, it MUST close the TCP connection. Pauly & Touati Expires March 13, 2016 [Page 5] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 Multiple TCP connections between the initiator and the responder are allowed, but not recommended. IKE and IPSec messages MUST be processed according to the standard source identification (using the SPI) and ordering rules. It is also possible to negotiate multiple IKE SAs over the same TCP connection, in which case messages are de- multiplexed using the SPI of the message. 6. Interaction with NAT Detection Payloads When negotiating over UDP port 500, IKE_SA_INIT packets include NAT_DETECTION_SOURCE_IP and NAT_DETECTION_DESTINATION_IP payloads to determine if UDP encapsulation of IPSec packets should be used. These payloads contain SHA-1 digests of the SPIs, IP addresses, and ports. IKE_SA_INIT packets sent on a TCP connection SHOULD include these payloads, and SHOULD use the applicable TCP ports when creating and checking the SHA-1 digests. If a NAT is detected due to the SHA-1 digests not matching the expected values, no change should be made for encapsulation of subsequent IKEv2 or ESP packets, since TCP encapsulation inherently supports NAT traversal. Implementations MAY use the information that a NAT is present to influence keep-alive timer values. 7. Considerations for Keep-alives and DPD Encapsulating IKE and IPSec inside of a TCP connection can impact the strategy that implementations use to detect peer liveness and to maintain middlebox mappings. In addition to mechanisms in IKE and IPSec, TCP keepalives are available. The following mechanisms may be employed: o IKEv2 Informational packets [RFC7296] o IPSec ESP NAT keep-alives [RFC3948] o TCP NAT keep-alives [RFC1122] o TLS keep-alives [RFC6520] It is up to the implementation to decide which keepalives are appropriate for TCP-encapsulated connections. NAT timeouts are generally longer for TCP ports, but implementations should still use some form of keep-alive when a NAT is detected. If TCP NAT keep- alives are used, IPSec ESP NAT keep-alives may be considered redundant and can safely be disabled. Pauly & Touati Expires March 13, 2016 [Page 6] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 8. Using MOBIKE with TCP encapsulation When an IKEv2 session is transitioned between networks using MOBIKE [RFC4555], the initiator of the transition may switch between using TCP encapsulation, UDP encapsulation, or no encapsulation. Implementations that implement both MOBIKE and TCP encapsulation MUST support dynamically enabling and disabling TCP encapsulation as interfaces change. The encapsulation method of ESP packets MUST always match the encapsulation method of the IKEv2 negotiation, which may be different when an IKEv2 endpoint changes networks. When an MOBIKE-enabled initiator changes networks, the UPDATE_SA_ADDRESSES notification SHOULD be sent out first over UDP before attempting over TCP. If there is a response to the UPDATE_SA_ADDRESSES notification sent over UDP, then the ESP packets should be sent directly over IP or over UDP port 4500 (depending on if a NAT was detected), regardless of if a connection on a previous network was using TCP encapsulation. Similarly, if the responder only responds to the UPDATE_SA_ADDRESSES notification over TCP, then the ESP packets should be sent over the TCP connection, regardless of if a connection on a previous network did not use TCP encapsulation. 9. Performance Considerations Several aspects of TCP encapsulation for IKEv2 and IPSec packets may negatively impact the performance of connections within the tunnel. Implementations should be aware of these and take these into consideration when determining when to use TCP encapsulation. 9.1. TCP-in-TCP If the outer connection between IKEv2 peers is over TCP, inner TCP connections may suffer effects from using TCP within TCP. In particular, the inner TCP's round-trip-time estimation will be affected by the burstiness of the outer TCP. This will make loss- recovery of the inner TCP traffic less reactive and more prone to spurious retransmission timeouts. 9.2. Added Reliability for Unreliable Protocols Since ESP is an unreliable protocol, transmitting ESP packets over a TCP connection will change the fundamental behavior of the packets. Some application-level protocols that prefer packet loss to delay (such as Voice over IP or other real-time protocols) may be negatively impacted if their packets are retransmitted by the TCP connection due to packet loss. Pauly & Touati Expires March 13, 2016 [Page 7] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 9.3. Encryption Overhead If TLS or another encryption method is used on the TCP connection, there may be increased processing overhead for encrypting and decrypting. This overhead may be experienced as a decrease in throughput on CPU-limited devices, or an increase in CPU usage or battery consumption on other devices, therefore the initiator and responder MUST allow the selection of NULL cipher when using TLS. Additionally, the TLS record introduces another layer of overhead, requiring more bytes to transmit a given IKEv2 and IPSec packet. 10. Security Considerations IKEv2 responders that support TCP encapsulation may become vulnerable to new Denial-of-Service (DoS) attacks that are specific to TCP, such as SYN-flooding attacks. Responders should be aware of this additional attack-surface. Attackers may be able to disrupt the TCP connection by sending spurious RST packets. Due to this, implementations SHOULD make sure that IKE session state persists even if the underlying TCP connection is torn down. If TLS is used on the encapsulating TCP connection, it should not be considered as a security measure. The security of the IKEv2 session is entirely derived from the IKEv2 negotiation and key establishment. 11. IANA Considerations This memo includes no request to IANA. TCP port 4500 is already allocated to IPSec. This port MAY be used for the protocol described in this document, but implementations MAY prefer to use other ports based on local policy. We foresee some implementations using TCP port 443 to more easily pass through some middleboxes [I-D.tschofenig-hourglass]. 12. Acknowledgments The authors would like to acknowledge the input and advice of Stuart Cheshire, Delziel Fernandes, Yoav Nir, Christoph Paasch, Yaron Sheffer, David Schinazi, March Wu and Kingwel Xie. Special thanks to Eric Kinnear for his implementation work. Pauly & Touati Expires March 13, 2016 [Page 8] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 13. References 13.1. Normative References [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/ RFC2119, March 1997, . [RFC7296] Kaufman, C., Hoffman, P., Nir, Y., Eronen, P., and T. Kivinen, "Internet Key Exchange Protocol Version 2 (IKEv2)", STD 79, RFC 7296, DOI 10.17487/RFC7296, October 2014, . 13.2. Informative References [I-D.tschofenig-hourglass] Tschofenig, H., "The New Waist of the Hourglass", draft- tschofenig-hourglass-00 (work in progress), July 2012. [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - Communication Layers", STD 3, RFC 1122, DOI 10.17487/ RFC1122, October 1989, . [RFC2817] Khare, R. and S. Lawrence, "Upgrading to TLS Within HTTP/1.1", RFC 2817, DOI 10.17487/RFC2817, May 2000, . [RFC3948] Huttunen, A., Swander, B., Volpe, V., DiBurro, L., and M. Stenberg, "UDP Encapsulation of IPsec ESP Packets", RFC 3948, DOI 10.17487/RFC3948, January 2005, . [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", RFC 4303, DOI 10.17487/RFC4303, December 2005, . [RFC4555] Eronen, P., "IKEv2 Mobility and Multihoming Protocol (MOBIKE)", RFC 4555, DOI 10.17487/RFC4555, June 2006, . [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security (TLS) Protocol Version 1.2", RFC 5246, August 2008. Pauly & Touati Expires March 13, 2016 [Page 9] Internet-DraftTCP Encapsulation of IKEv2 and IPSec PacketsSeptember 2015 [RFC6520] Seggelmann, R., Tuexen, M., and M. Williams, "Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS) Heartbeat Extension", RFC 6520, DOI 10.17487/ RFC6520, February 2012, . Authors' Addresses Tommy Pauly Apple Inc. 1 Infinite Loop Cupertino, California 95014 US Email: tpauly@apple.com Samy Touati Ericsson 300 Holger Way San Jose, California 95134 US Email: samy.touati@ericsson.com Pauly & Touati Expires March 13, 2016 [Page 10]