Lesson 2 of 3 Network Models and Protocols

Secure Protocols

Secure protocols protect data in transit with encryption, integrity and authentication. This lesson covers IPsec, SSH and TLS and the secure replacements for legacy protocols.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain IPsec AH, ESP, transport mode and tunnel mode.
  • Describe SSH and TLS and identify secure replacements for legacy protocols.

IPsec

IPsec secures IP traffic at the network layer, transparently to applications. The Authentication Header (AH) provides integrity, data origin authentication and replay protection but no encryption. The Encapsulating Security Payload (ESP) adds confidentiality and is used in almost all deployments. Internet Key Exchange (IKE) negotiates security associations (SAs), which define the algorithms and keys for each direction of traffic.

In transport mode, IPsec protects the payload of packets between two hosts, leaving the original IP header visible. In tunnel mode, it encapsulates the entire original packet in a new one, which is how site-to-site VPNs between gateways work and hides internal addressing.

Setting up an IPsec connection happens in two stages. In the first, the two peers use IKE to authenticate each other, with certificates or a pre-shared key, and establish a protected channel for negotiation. In the second, they use that channel to agree the security associations that will protect the actual traffic: which protocol (normally ESP), which encryption and integrity algorithms, which keys and for how long. Because an SA covers one direction only, a two-way connection needs a pair. The SAs are renegotiated regularly so that keys are replaced.

AH and NAT conflict because AH's integrity check covers the outer IP header, including the addresses. A NAT device must rewrite those addresses, which breaks the check and makes every packet look tampered with. ESP's integrity protection does not include the outer header, and NAT traversal encapsulates ESP in UDP so that NAT devices can handle it. This is one practical reason why ESP is used almost everywhere. The following comparison summarises the two protocols.

AH
ConfidentialityNo
Integrity and authenticationYes, including the outer IP header
Works through NATNo
ESP
ConfidentialityYes
Integrity and authenticationYes, of the protected payload
Works through NATYes, with NAT traversal

The following diagram compares what each IPsec configuration protects.

What each IPsec configuration protects. AH provides integrity and origin authentication but no confidentiality. ESP in transport mode encrypts the payload between two hosts and leaves the original IP header visible. ESP in tunnel mode, typically between gateways, encrypts the whole original packet, including its addresses, inside a new one.
ESP can also provide integrity and authentication.
Scenario questions

Deploying IPsec

Exam skills 4.1.3

Choose the IPsec protocol and mode that fit each case.

Log in to try this activity Interactive activities are free with an account.

SSH and TLS

Secure Shell (SSH) provides encrypted remote command-line access, file transfer (SFTP, SCP) and tunnelling, replacing Telnet, rlogin and FTP. Key-based authentication with protected private keys is stronger than passwords.

SSH also authenticates the server, which users often overlook. The first time a client connects, it shows the server's host key fingerprint and asks whether to trust it; afterwards it warns if the key changes, which could indicate an attacker in the middle. Accepting a changed key without checking defeats this protection. In organisations, host keys are distributed in advance or signed by an internal SSH certificate authority, so users never need to make that decision.

Transport Layer Security (TLS) protects application protocols such as HTTPS, SMTP with STARTTLS, LDAPS and many APIs. It authenticates servers (and optionally clients) with certificates and negotiates session keys. SSL and TLS 1.0 and 1.1 are deprecated and insecure; TLS 1.2 with strong cipher suites is acceptable, and TLS 1.3 removes obsolete algorithms, shortens the handshake and always provides forward secrecy.

The TLS handshake combines the cryptographic building blocks covered in Domain 3. The client proposes protocol versions and cipher suites and sends its share of an ephemeral key exchange. The server chooses the parameters, sends its own key share and its certificate, and proves that it holds the matching private key by signing the handshake. The client validates the certificate chain, both sides derive the same session keys from the key exchange, and all further traffic is protected with authenticated symmetric encryption such as AES-GCM. With mutual TLS, the client also presents a certificate, which is common between services and for device authentication.

TLS protects data between the two endpoints of the connection, not beyond them. If a load balancer terminates TLS and forwards plaintext to back-end servers, the internal leg is unprotected unless it is encrypted again. Questions that ask whether data is protected "end to end" often turn on this point.

True or false

SSH and TLS in practice

Exam skills 4.1.3

Check common points about SSH host keys and TLS protection.

Log in to try this activity Interactive activities are free with an account.

Replacing insecure protocols

Legacy protocols send credentials and data in cleartext. The following table lists common insecure protocols and their secure replacements.

InsecureSecure replacement
Telnet, rloginSSH
FTPSFTP or FTPS
HTTPHTTPS (TLS)
SNMPv1/v2cSNMPv3 with authentication and encryption
LDAP (simple bind)LDAPS or LDAP with StartTLS
DNS (unauthenticated)DNSSEC for integrity; DNS over HTTPS or TLS for privacy
SMTP without encryptionSMTP with STARTTLS; S/MIME or PGP for end-to-end

Replacement is not complete until the insecure protocol is switched off. Many organisations introduce SFTP but leave the old FTP service running for a few legacy partners, and those cleartext credentials are often the same as the ones used elsewhere. A practical migration inventories which systems still use each legacy protocol, usually from network flow data, moves them one by one and then blocks the old ports. Opportunistic encryption such as STARTTLS also has a limit: if an attacker can strip the STARTTLS offer from the conversation, the two servers may fall back to cleartext, so policies that require encryption between known partners are stronger than encryption that is merely attempted.

Match the pairs

Secure replacements

Exam skills 4.1.3

Match each insecure protocol with its secure replacement.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing an IPsec mode

A company needs to connect two offices over the internet so that all traffic between their networks is encrypted and internal IP addresses are hidden from the internet. Which IPsec configuration fits?

A gateway-to-gateway connection that encrypts and hides internal addresses calls for ESP in tunnel mode between the two offices' VPN gateways. AH would not provide confidentiality, and transport mode protects only payloads between individual hosts while exposing their IP headers.

Check yourself

Which IPsec protocol provides confidentiality?

Show answer

ESP (Encapsulating Security Payload). AH provides integrity and authentication only.

Exam Tips

Remember for the exam

  • AH: integrity only. ESP: confidentiality plus integrity.
  • Tunnel mode for site-to-site VPNs; transport mode host to host.
  • TLS 1.3 always provides forward secrecy; SSL is obsolete.