IPsec explained

IPsec
Long Name:Internet Protocol Security
Year Started:1996
Organization:Internet Engineering Task Force
Base Standards:Various, see IETF documentation chapter

In computing, Internet Protocol Security (IPsec) is a secure network protocol suite that authenticates and encrypts packets of data to provide secure encrypted communication between two computers over an Internet Protocol network. It is used in virtual private networks (VPNs).

IPsec includes protocols for establishing mutual authentication between agents at the beginning of a session and negotiation of cryptographic keys to use during the session. IPsec can protect data flows between a pair of hosts (host-to-host), between a pair of security gateways (network-to-network), or between a security gateway and a host (network-to-host).IPsec uses cryptographic security services to protect communications over Internet Protocol (IP) networks. It supports network-level peer authentication, data origin authentication, data integrity, data confidentiality (encryption), and protection from replay attacks.

History

Starting in the early 1970s, the Advanced Research Projects Agency sponsored a series of experimental ARPANET encryption devices, at first for native ARPANET packet encryption and subsequently for TCP/IP packet encryption; some of these were certified and fielded. From 1986 to 1991, the NSA sponsored the development of security protocols for the Internet under its Secure Data Network Systems (SDNS) program.[1] This brought together various vendors including Motorola who produced a network encryption device in 1988. The work was openly published from about 1988 by NIST and, of these, Security Protocol at Layer 3 (SP3) would eventually morph into the ISO standard Network Layer Security Protocol (NLSP).[2]

In 1992, the US Naval Research Laboratory (NRL) was funded by DARPA CSTO to implement IPv6 and to research and implement IP encryption in 4.4 BSD, supporting both SPARC and x86 CPU architectures. DARPA made its implementation freely available via MIT. Under NRL's DARPA-funded research effort, NRL developed the IETF standards-track specifications (RFC 1825 through RFC 1827) for IPsec. NRL's IPsec implementation was described in their paper in the 1996 USENIX Conference Proceedings.[3] NRL's open-source IPsec implementation was made available online by MIT and became the basis for most initial commercial implementations.[4]

The Internet Engineering Task Force (IETF) formed the IP Security Working Group in 1992[5] to standardize openly specified security extensions to IP, called IPsec.[6] The NRL developed standards were published by the IETF as RFC-1825 through RFC-1827.[7]

Security architecture

The initial IPv4 suite was developed with few security provisions. As a part of the IPv4 enhancement, IPsec is a layer 3 OSI model or internet layer end-to-end security scheme. In contrast, while some other Internet security systems in widespread use operate above the network layer, such as Transport Layer Security (TLS) that operates above the transport layer and Secure Shell (SSH) that operates at the application layer, IPsec can automatically secure applications at the internet layer.

IPsec is an open standard as a part of the IPv4 suite and uses the following protocols to perform various functions:[8] [9]

Authentication Header

The Security Authentication Header (AH) was developed at the US Naval Research Laboratory in the early 1990s and is derived in part from previous IETF standards' work for authentication of the Simple Network Management Protocol (SNMP) version 2. Authentication Header (AH) is a member of the IPsec protocol suite. AH ensures connectionless integrity by using a hash function and a secret shared key in the AH algorithm. AH also guarantees the data origin by authenticating IP packets. Optionally a sequence number can protect the IPsec packet's contents against replay attacks,[18] using the sliding window technique and discarding old packets.

AH operates directly on top of IP, using IP protocol number 51.[19]

The following AH packet diagram shows how an AH packet is constructed and interpreted:[10] [11]

Authentication Header format
OffsetsOctet160123
Octet16Bit10012345678910111213141516171819202122232425262728293031
00Next HeaderPayload LenReserved
432Security Parameters Index (SPI)
864Sequence Number
C96Integrity Check Value (ICV)
...
......
Next Header (8 bits) : Type of the next header, indicating what upper-layer protocol was protected. The value is taken from the list of IP protocol numbers.
  • Payload Len (8 bits) : The length of this Authentication Header in 4-octet units, minus 2. For example, an AH value of 4 equals 3×(32-bit fixed-length AH fields) + 3×(32-bit ICV fields) − 2 and thus an AH value of 4 means 24 octets. Although the size is measured in 4-octet units, the length of this header needs to be a multiple of 8 octets if carried in an IPv6 packet. This restriction does not apply to an Authentication Header carried in an IPv4 packet.
  • Reserved (16 bits) : Reserved for future use (all zeroes until then).
  • Security Parameters Index (32 bits) : Arbitrary value which is used (together with the destination IP address) to identify the security association of the receiving party.
  • Sequence Number (32 bits) : A monotonic strictly increasing sequence number (incremented by 1 for every packet sent) to prevent replay attacks. When replay detection is enabled, sequence numbers are never reused, because a new security association must be renegotiated before an attempt to increment the sequence number beyond its maximum value.[11]
    Integrity Check Value (multiple of 32 bits) : Variable length check value. It may contain padding to align the field to an 8-octet boundary for IPv6, or a 4-octet boundary for IPv4.

    Encapsulating Security Payload

    The IP Encapsulating Security Payload (ESP)[20] was developed at the Naval Research Laboratory starting in 1992 as part of a DARPA-sponsored research project, and was openly published by IETF SIPP[21] Working Group drafted in December 1993 as a security extension for SIPP. This ESP was originally derived from the US Department of Defense SP3D protocol, rather than being derived from the ISO Network-Layer Security Protocol (NLSP). The SP3D protocol specification was published by NIST in the late 1980s, but designed by the Secure Data Network System project of the US Department of Defense. Encapsulating Security Payload (ESP) is a member of the IPsec protocol suite. It provides origin authenticity through source authentication, data integrity through hash functions and confidentiality through encryption protection for IP packets. ESP also supports encryption-only and authentication-only configurations, but using encryption without authentication is strongly discouraged because it is insecure.[22] [23] [24]

    Unlike Authentication Header (AH), ESP in transport mode does not provide integrity and authentication for the entire IP packet. However, in tunnel mode, where the entire original IP packet is encapsulated with a new packet header added, ESP protection is afforded to the whole inner IP packet (including the inner header) while the outer header (including any outer IPv4 options or IPv6 extension headers) remains unprotected.

    ESP operates directly on top of IP, using IP protocol number 50.

    The following ESP packet diagram shows how an ESP packet is constructed and interpreted:[12] [25]

    Encapsulating Security Payload format
    OffsetsOctet160123
    Octet16Bit10012345678910111213141516171819202122232425262728293031
    00Security Parameters Index (SPI)
    432Sequence Number
    864Payload data
    ......
    ......  
    ...... Padding (0-255 octets) 
    ...... Pad LengthNext Header
    ......Integrity Check Value (ICV)
    ...
    ......
    Security Parameters Index (32 bits) : Arbitrary value used (together with the destination IP address) to identify the security association of the receiving party.
  • Sequence Number (32 bits) : A monotonically increasing sequence number (incremented by 1 for every packet sent) to protect against replay attacks. There is a separate counter kept for every security association.
  • Payload data (variable) : The protected contents of the original IP packet, including any data used to protect the contents (e.g. an Initialisation Vector for the cryptographic algorithm). The type of content that was protected is indicated by the Next Header field.
  • Padding (0-255 octets) : Padding for encryption, to extend the payload data to a size that fits the encryption's cipher block size, and to align the next field.
  • Pad Length (8 bits) : Size of the padding (in octets).
  • Next Header (8 bits) : Type of the next header. The value is taken from the list of IP protocol numbers.
  • Integrity Check Value (multiple of 32 bits) : Variable length check value. It may contain padding to align the field to an 8-octet boundary for IPv6, or a 4-octet boundary for IPv4.
  • Security association

    See main article: Security association. The IPsec protocols use a security association, where the communicating parties establish shared security attributes such as algorithms and keys. As such, IPsec provides a range of options once it has been determined whether AH or ESP is used. Before exchanging data, the two hosts agree on which symmetric encryption algorithm is used to encrypt the IP packet, for example AES or ChaCha20, and which hash function is used to ensure the integrity of the data, such as BLAKE2 or SHA256. These parameters are agreed for the particular session, for which a lifetime must be agreed and a session key.[26]

    The algorithm for authentication is also agreed before the data transfer takes place and IPsec supports a range of methods. Authentication is possible through pre-shared key, where a symmetric key is already in the possession of both hosts, and the hosts send each other hashes of the shared key to prove that they are in possession of the same key. IPsec also supports public key encryption, where each host has a public and a private key, they exchange their public keys and each host sends the other a nonce encrypted with the other host's public key. Alternatively if both hosts hold a public key certificate from a certificate authority, this can be used for IPsec authentication.[27]

    The security associations of IPsec are established using the Internet Security Association and Key Management Protocol (ISAKMP). ISAKMP is implemented by manual configuration with pre-shared secrets, Internet Key Exchange (IKE and IKEv2), Kerberized Internet Negotiation of Keys (KINK), and the use of IPSECKEY DNS records.[17] [28] [29] RFC 5386 defines Better-Than-Nothing Security (BTNS) as an unauthenticated mode of IPsec using an extended IKE protocol. C. Meadows, C. Cremers, and others have used formal methods to identify various anomalies which exist in IKEv1 and also in IKEv2.[30]

    In order to decide what protection is to be provided for an outgoing packet, IPsec uses the Security Parameter Index (SPI), an index to the security association database (SADB), along with the destination address in a packet header, which together uniquely identifies a security association for that packet. A similar procedure is performed for an incoming packet, where IPsec gathers decryption and verification keys from the security association database.

    For IP multicast a security association is provided for the group, and is duplicated across all authorized receivers of the group. There may be more than one security association for a group, using different SPIs, thereby allowing multiple levels and sets of security within a group. Indeed, each sender can have multiple security associations, allowing authentication, since a receiver can only know that someone knowing the keys sent the data. Note that the relevant standard does not describe how the association is chosen and duplicated across the group; it is assumed that a responsible party will have made the choice.

    Keepalives

    To ensure that the connection between two endpoints has not been interrupted, endpoints exchange keepalive messages at regular intervals, which can also be used to automatically reestablish a tunnel lost due to connection interruption.

    Dead Peer Detection (DPD) is a method of detecting a dead Internet Key Exchange (IKE) peer. The method uses IPsec traffic patterns to minimize the number of messages required to confirm the availability of a peer. DPD is used to reclaim the lost resources in case a peer is found dead and it is also used to perform IKE peer failover.

    UDP keepalive is an alternative to DPD.

    Modes of operation

    The IPsec protocols AH and ESP can be implemented in a host-to-host transport mode, as well as in a network tunneling mode.

    Transport mode

    In transport mode, only the payload of the IP packet is usually encrypted or authenticated. The routing is intact, since the IP header is neither modified nor encrypted; however, when the authentication header is used, the IP addresses cannot be modified by network address translation, as this always invalidates the hash value. The transport and application layers are always secured by a hash, so they cannot be modified in any way, for example by translating the port numbers.

    A means to encapsulate IPsec messages for NAT traversal has been defined by RFC documents describing the NAT-T mechanism.

    Tunnel mode

    See main article: Tunneling protocol. In tunnel mode, the entire IP packet is encrypted and authenticated. It is then encapsulated into a new IP packet with a new IP header. Tunnel mode is used to create virtual private networks for network-to-network communications (e.g. between routers to link sites), host-to-network communications (e.g. remote user access) and host-to-host communications (e.g. private chat).[31]

    Tunnel mode supports NAT traversal.

    Algorithms

    Symmetric encryption algorithms

    Cryptographic algorithms defined for use with IPsec include:

    Refer to RFC 8221 for details.

    Key exchange algorithms

    Authentication algorithms

    Implementations

    The IPsec can be implemented in the IP stack of an operating system. This method of implementation is done for hosts and security gateways. Various IPsec capable IP stacks are available from companies, such as HP or IBM.[32] An alternative is so called bump-in-the-stack (BITS) implementation, where the operating system source code does not have to be modified. Here IPsec is installed between the IP stack and the network drivers. This way operating systems can be retrofitted with IPsec. This method of implementation is also used for both hosts and gateways. However, when retrofitting IPsec the encapsulation of IP packets may cause problems for the automatic path MTU discovery, where the maximum transmission unit (MTU) size on the network path between two IP hosts is established. If a host or gateway has a separate cryptoprocessor, which is common in the military and can also be found in commercial systems, a so-called bump-in-the-wire (BITW) implementation of IPsec is possible.[33]

    When IPsec is implemented in the kernel, the key management and ISAKMP/IKE negotiation is carried out from user space. The NRL-developed and openly specified "PF_KEY Key Management API, Version 2" is often used to enable the application-space key management application to update the IPsec security associations stored within the kernel-space IPsec implementation.[34] Existing IPsec implementations usually include ESP, AH, and IKE version 2. Existing IPsec implementations on Unix-like operating systems, for example, Solaris or Linux, usually include PF_KEY version 2.

    Embedded IPsec can be used to ensure the secure communication among applications running over constrained resource systems with a small overhead.[35]

    Standards status

    IPsec was developed in conjunction with IPv6 and was originally required to be supported by all standards-compliant implementations of IPv6 before RFC 6434 made it only a recommendation.[36] IPsec is also optional for IPv4 implementations. IPsec is most commonly used to secure IPv4 traffic.

    IPsec protocols were originally defined in RFC 1825 through RFC 1829, which were published in 1995. In 1998, these documents were superseded by RFC 2401 and RFC 2412 with a few incompatible engineering details, although they were conceptually identical. In addition, a mutual authentication and key exchange protocol Internet Key Exchange (IKE) was defined to create and manage security associations. In December 2005, new standards were defined in RFC 4301 and RFC 4309 which are largely a superset of the previous editions with a second version of the Internet Key Exchange standard IKEv2. These third-generation documents standardized the abbreviation of IPsec to uppercase “IP” and lowercase “sec”. “ESP” generally refers to RFC 4303, which is the most recent version of the specification.

    Since mid-2008, an IPsec Maintenance and Extensions (ipsecme) working group is active at the IETF.[37] [38]

    Alleged NSA interference

    In 2013, as part of Snowden leaks, it was revealed that the US National Security Agency had been actively working to "Insert vulnerabilities into commercial encryption systems, IT systems, networks, and endpoint communications devices used by targets" as part of the Bullrun program.[39] There are allegations that IPsec was a targeted encryption system.[40]

    The OpenBSD IPsec stack came later on and also was widely copied. In a letter which OpenBSD lead developer Theo de Raadt received on 11 Dec 2010 from Gregory Perry, it is alleged that Jason Wright and others, working for the FBI, inserted "a number of backdoors and side channel key leaking mechanisms" into the OpenBSD crypto code. In the forwarded email from 2010, Theo de Raadt did not at first express an official position on the validity of the claims, apart from the implicit endorsement from forwarding the email.[41] Jason Wright's response to the allegations: "Every urban legend is made more real by the inclusion of real names, dates, and times. Gregory Perry's email falls into this category. … I will state clearly that I did not add backdoors to the OpenBSD operating system or the OpenBSD Cryptographic Framework (OCF)."[42] Some days later, de Raadt commented that "I believe that NETSEC was probably contracted to write backdoors as alleged. … If those were written, I don't believe they made it into our tree."[43] This was published before the Snowden leaks.

    An alternative explanation put forward by the authors of the Logjam attack suggests that the NSA compromised IPsec VPNs by undermining the Diffie-Hellman algorithm used in the key exchange. In their paper,[44] they allege the NSA specially built a computing cluster to precompute multiplicative subgroups for specific primes and generators, such as for the second Oakley group defined in RFC 2409. As of May 2015, 90% of addressable IPsec VPNs supported the second Oakley group as part of IKE. If an organization were to precompute this group, they could derive the keys being exchanged and decrypt traffic without inserting any software backdoors.

    A second alternative explanation that was put forward was that the Equation Group used zero-day exploits against several manufacturers' VPN equipment which were validated by Kaspersky Lab as being tied to the Equation Group[45] and validated by those manufacturers as being real exploits, some of which were zero-day exploits at the time of their exposure.[46] [47] [48] The Cisco PIX and ASA firewalls had vulnerabilities that were used for wiretapping by the NSA.

    Furthermore, IPsec VPNs using "Aggressive Mode" settings send a hash of the PSK in the clear. This can be and apparently is targeted by the NSA using offline dictionary attacks.[44] [49] [50]

    See also

    Further reading

    Standards track

    Experimental RFCs

    Informational RFCs

    Best current practice RFCs

    Obsolete/historic RFCs

    External links

    Notes and References

    1. Book: . https://ieeexplore.ieee.org/document/6168355 . en-US. 10.1109/ACCT.2012.64. 16526652. 2012 . Dhall . Hitesh . Dhall . Dolly . Batra . Sonia . Rani . Pooja . 2012 Second International Conference on Advanced Computing & Communication Technologies . Implementation of IPSec Protocol . 176–181 . 978-1-4673-0471-9 .
    2. Web site: Network Encryption – history and patents . John . Gilmore . 2014-02-18 . https://web.archive.org/web/20140903145752/http://www.toad.com/gnu/netcrypt.html . 2014-09-03 . dead .
    3. Web site: USENIX 1996 ANNUAL TECHNICAL CONFERENCE. www.usenix.org.
    4. Web site: IPv6 + IPSEC + ISAKMP Distribution Page. web.mit.edu.
    5. Web site: IP Security Protocol (ipsec) -. datatracker.ietf.org.
    6. 4301 . 4 . Security Architecture for the Internet Protocol. December 2005. Network Working Group of the IETF . The spelling "IPsec" is preferred and used throughout this and all related IPsec standards. All other capitalizations of IPsec [...] are deprecated.. Seo. Karen. Kent. Stephen.
    7. Web site: NRL ITD Accomplishments - IPSec and IPv6. https://web.archive.org/web/20150915230737/http://www.nrl.navy.mil/itd/sites/www.nrl.navy.mil.itd/files/files/itd_accomp_ipsec.pdf . 2015-09-15 . live. US Naval Research Laboratories.
    8. IP Security Document Roadmap. 2411. Thayer. R.. Doraswamy. N.. Glenn. R.. November 1998. IETF. 10.17487/RFC2411.
    9. Cryptographic Suites for IPsec. IETF. Hoffman. P.. December 2005. 4308. 10.17487/RFC4308.
    10. IP Authentication Header. Kent. S.. Atkinson. R.. IETF. November 1998. 2402. 10.17487/RFC2402.
    11. IP Authentication Header. IETF. Kent. S.. December 2005. 4302. 10.17487/RFC4302.
    12. IP Encapsulating Security Payload (ESP). IETF. Kent. S.. Atkinson. R.. November 1998. 2406. 10.17487/RFC2406.
    13. The Internet Key Exchange (IKE), RFC 2409, §1 Abstract
    14. The Internet Key Exchange (IKE). IETF. Harkins. D.. Carrel. D.. November 1998. 2409. 10.17487/RFC2409.
    15. IKE Version 2. IETF. C.. Kaufman. 4306. 10.17487/RFC4306.
    16. Kerberized Internet Negotiation of Keys (KINK). IETF. November 1998. 4430. Sakane. S.. Kamada. K.. Thomas. M.. Vilhuber. J.. 10.17487/RFC4430.
    17. A Method for Storing IPsec Keying Material in DNS. IETF. February 2005. 4025. Richardson. M.. 10.17487/RFC4025.
    18. Book: Carrier-Scale IP Networks: Designing and Operating Internet Networks. Peter Willis . IET. 2001 . 9780852969823. 270.
    19. Web site: Protocol Numbers . 2010-05-27 . https://web.archive.org/web/20100529122930/https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml . 2010-05-29 . IANA . dead .
    20. Web site: SIPP Encapsulating Security Payload . IETF SIPP Working Group . 1993 . 2013-08-07 . https://web.archive.org/web/20160909031941/http://www.toad.com/gnu/draft-ietf-sip-esp-00.txt . 2016-09-09 . dead .
    21. Web site: Draft SIPP Specification . IETF . 1993 . 21. Deering . Steve E. .
    22. Problem Areas for the IP Security Protocols . Proceedings of the Sixth Usenix Unix Security Symposium . Steven M. . Bellovin . 1996 . 1–16 . San Jose, CA . 2007-07-09. Steven M. Bellovin. PostScript.
    23. Cryptography in theory and practice: The case of encryption in IPsec . Eurocrypt 2006, Lecture Notes in Computer Science Vol. 4004 . Paterson. Kenneth G.. Yau. Arnold K.L.. 2006-04-24. 12–29 . Berlin . 2007-08-13. PDF.
    24. Attacking the IPsec Standards in Encryption-only Configurations . IEEE Symposium on Security and Privacy, IEEE Computer Society . Degabriele. Jean Paul. Paterson. Kenneth G.. 2007-08-09. PDF . 335–349 . Oakland, CA . 2007-08-13 .
    25. IP Encapsulating Security Payload (ESP). Kent. S.. December 2005. IETF. 4303. 10.17487/RFC4303.
    26. Book: Carrier-Scale IP Networks: Designing and Operating Internet Networks. Peter Willis . IET. 2001 . 9780852969823. 271.
    27. Book: Carrier-Scale IP Networks: Designing and Operating Internet Networks. Peter Willis . IET. 2001 . 9780852969823. 272–3.
    28. RFC 2406, §1, page 2
    29. Thomas . M. . June 2001 . Requirements for Kerberized Internet Negotiation of Keys . 3129 . 10.17487/RFC3129.
    30. Book: C. Cremers. Key Exchange in IPsec Revisited: Formal Analysis of IKEv1 and IKEv2, ESORICS 2011. Lecture Notes in Computer Science. 2011. 315–334. Springer. 10.1007/978-3-642-23822-2_18. 20.500.11850/69608. 9783642238222. 18222662 .
    31. William, S., & Stallings, W. (2006). Cryptography and Network Security, 4/E. Pearson Education India. p. 492-493
    32. Book: Carrier-Scale IP Networks: Designing and Operating Internet Networks. Peter Willis . IET. 2001 . 9780852969823. 266.
    33. Book: Carrier-Scale IP Networks: Designing and Operating Internet Networks. Peter Willis . IET. 2001 . 9780852969823. 267.
    34. RFC 2367, PF_KEYv2 Key Management API, Dan McDonald, Bao Phan, & Craig Metz (July 1998)
    35. Book: Hamad. Mohammad. Prevelakis. Vassilis. 2015 World Symposium on Computer Networks and Information Security (WSCNIS) . Implementation and performance evaluation of embedded IPsec in microkernel OS . 2015. 1–7 . en-US. IEEE. 10.1109/wscnis.2015.7368294. 9781479999064. 16935000.
    36. RFC 6434, "IPv6 Node Requirements", E. Jankiewicz, J. Loughney, T. Narten (December 2011)
    37. Web site: 2015-10-26. ipsecme charter.
    38. Web site: 2015-10-26. ipsecme status.
    39. News: Secret Documents Reveal N.S.A. Campaign Against Encryption. New York Times.
    40. Web site: Re: [Cryptography] Opening Discussion: Speculation on "BULLRUN"]. John Gilmore.
    41. Web site: Allegations regarding OpenBSD IPSEC. Theo de Raadt.
    42. Web site: Allegations regarding OpenBSD IPSEC. Jason Wright.
    43. Web site: Update on the OpenBSD IPSEC backdoor allegation. Theo de Raadt.
    44. Book: https://doi.org/10.1145/2810103.2813707. 10.1145/2810103.2813707. Imperfect Forward Secrecy. Proceedings of the 22nd ACM SIGSAC Conference on Computer and Communications Security. 2015. Adrian. David. Bhargavan. Karthikeyan. Durumeric. Zakir. Gaudry. Pierrick. Green. Matthew. Halderman. J. Alex. Heninger. Nadia. Springall. Drew. Thomé. Emmanuel. Valenta. Luke. Vandersloot. Benjamin. Wustrow. Eric. Zanella-Béguelin. Santiago. Zimmermann. Paul. 5–17. 9781450338325. 347988.
    45. News: Confirmed: hacking tool leak came from "omnipotent" NSA-tied group . Dan . Goodin . August 16, 2016 . August 19, 2016 . Ars Technica.
    46. News: Cisco confirms two of the Shadow Brokers' 'NSA' vulns are real . Iain . Thomson . August 17, 2016 . September 16, 2016 . The Register.
    47. News: Equation Group exploit hits newer Cisco ASA, Juniper Netscreen . Darren . Pauli . August 24, 2016 . September 16, 2016 . The Register.
    48. News: Fortinet follows Cisco in confirming Shadow Broker vuln . Richard . Chirgwin . . August 18, 2016 . September 16, 2016.
    49. Web site: key exchange - What are the problems of IKEv1 aggressive mode (compared to IKEv1 main mode or IKEv2)?. Cryptography Stack Exchange.
    50. Web site: Don't stop using IPsec just yet. No Hats. December 29, 2014.