pk.org: Computer Security/Lecture Notes

Secure Communication

Virtual Private Networks (VPNs)

Paul Krzyzanowski – 2026-11-12

Every network attack we have examined begins from the same position: traffic crossing the Internet passes through equipment that neither endpoint controls, and the protocols that move it were designed without security. DNS resolvers believe the first response that arrives, IP does not verify source addresses, TCP trusts the sequence numbers in the packets it receives, and routers believe what their neighbors announce.

The defenses we have seen so far each secure one piece of the infrastructure but none of them protects the data itself. Cryptography enables a different approach: assume the network is hostile and protect the traffic as it travels. If every packet is encrypted and authenticated, an attacker who intercepts or redirects it cannot read the data or modify it without detection.

We begin with a short review of what TLS provides and where it stops. We then spend most of the discussion on virtual private networks, which apply the same cryptographic protections to all traffic between networks rather than to a single application’s connection. We end with what these tools do not protect.

What TLS Provides

We covered the mechanics of Transport Layer Security (TLS) in detail earlier. Here’s a brief review of what it provides and where it falls short.

TLS creates a secure channel between two applications. After the setup handshake completes, applications communicate as if they were using ordinary TCP sockets, with three added guarantees:

  1. Authentication lets the client verify that it is talking to the intended server, and optionally lets the server verify the client.

  2. Confidentiality protects the data from eavesdropping. Everything sent over the connection is encrypted.

  3. Integrity ensures that any modification of the data in transit is detected.

The TLS 1.3 handshake negotiates cryptographic algorithms, performs a Diffie-Hellman key exchange to establish a shared secret, and has the server prove that it holds the private key for its certificate, which a trusted certificate authority has signed. Both sides then derive session keys from the shared secret. The data itself is protected with authenticated encryption, typically AES-GCM or ChaCha20-Poly1305, which encrypts and authenticates in a single operation.

Why Client Certificates Are Rare

TLS supports mutual authentication, where the client also presents a certificate. Client certificates are rarely used, for several reasons:

Instead, services authenticate the client after the TLS connection is established, using passwords, one-time codes, or other credentials. TLS protects the confidentiality of those credentials over the network. Even a plain password is safe from eavesdropping when it travels over TLS.

Where TLS Stops

TLS is an application-level decision. Each application must choose to use it, and it protects only the one connection between two programs. Traffic from applications that do not use TLS crosses the network unprotected.

A valid certificate proves that the server holds the private key for its name, but it does not make the server trustworthy. These limits motivate protection at the network layer, where a single mechanism can cover all traffic regardless of what the applications do.

Tunneling

The most direct way to connect two offices privately is a dedicated line between them. Telephone carriers sold leased lines for decades before the Internet existed, and companies such as Amazon, Microsoft, Alibaba, Google, and Meta still operate private fiber networks connecting their data centers around the world. For most organizations, dedicated lines to every site are too expensive. The Internet already reaches every office, but it is shared and untrusted.

Tunneling carries the packets of one network inside the packets of another. Two networks joined by a tunnel behave as if a direct link connected them, even though the traffic between them crosses the public Internet.

The mechanism is encapsulation: an entire IP datagram becomes the payload of another IP packet. Consider a company with offices in New York and London that need to communicate. The New York office uses the address range 192.168.1.0/24 and the London office uses 192.168.2.0/24. These are private addresses that cannot be routed on the public Internet.

When a computer at 192.168.1.11 in New York sends a packet to a file server at 192.168.2.22 in London, the original packet contains:

The gateway router at the New York office intercepts this packet and encapsulates it inside a new IP packet that uses public addresses:

The outer packet travels across the public Internet to the London gateway, which strips off the outer headers, extracts the original packet, and routes it to the file server at 192.168.2.22. From the perspective of the communicating computers, they are on the same private network. The encapsulation is invisible to them. The tunnel acts as a virtual point-to-point link between the two networks, with the public Internet as the transport.

Basic tunneling provides connectivity, but it does not provide security. The encapsulated data travels in cleartext, so anyone who intercepts the outer packet can read the inner one. The endpoints are not authenticated, so an attacker could impersonate a gateway. The contents can also be modified in transit without detection.

What Makes a Tunnel a VPN

A virtual private network (VPN) adds three protections to a tunnel:

  1. Encryption keeps the inner packet confidential, so an attacker who captures the outer packet cannot read what is inside.

  2. Integrity protection uses message authentication codes so the receiving gateway detects any modified packet and discards it.

  3. Authentication ensures that each endpoint is talking to the legitimate peer rather than an imposter, using pre-shared keys or public key cryptography, often with X.509 certificates.

This combination creates a secure channel through an untrusted network. The protection applies to the packets routed into the tunnel, and only between the tunnel’s endpoints. Encryption covers the inner packet, its addresses included, but the outer header stays readable, since Internet routers need it to deliver the packet. An observer between the gateways can still see the gateways’ addresses, when packets flow, and how large they are.

VPNs are nearly as old as commercial use of the Internet. In the mid-1990s, Microsoft and several modem makers developed the Point-to-Point Tunneling Protocol (PPTP) so that an employee could dial a local Internet provider and reach the office network. Its cryptography was later broken, but it established remote access over the Internet as a product category. The IETF, the Internet standards body, began publishing its own network-layer security standards, IPsec, in 1995. We will look at IPsec and its two main successors after examining how VPNs are used.

VPN Deployment Models

VPNs appear in three arrangements, distinguished by what sits at each end of the tunnel.

Site-to-Site VPNs

Connecting geographically separated corporate networks was the original use of VPNs. Two gateway routers maintain a tunnel between them, making the remote networks behave as one private network. The individual computers on each network need no VPN software and are unaware that the tunnel exists.

The two offices from the tunneling example form a site-to-site VPN once their gateways add encryption, integrity protection, and authentication to the tunnel. When the computer in New York sends a packet to the file server in London, the New York gateway encapsulates and encrypts it, and the London gateway decrypts it and delivers the original packet. The company gets the behavior of a leased line without paying for one.

Remote Access VPNs

As broadband service and remote work spread, VPNs evolved to connect individual computers to corporate networks. An employee’s laptop runs VPN client software that establishes a tunnel to the corporate VPN gateway. Once connected, the laptop can reach internal resources as if it were in the office. The Rutgers VPN works this way. A student off campus who needs a server that accepts connections only from the campus network connects to the Rutgers gateway, which forwards the traffic onto the campus network.

This arrangement protects remote workers in several ways:

This is the most common corporate use of VPNs today.

Consumer VPNs

The third model is the consumer VPN, sold by commercial services such as NordVPN, ExpressVPN, and Proton VPN, and usually marketed as a privacy tool. The user’s device establishes a tunnel to the provider’s network, and the provider forwards the traffic to its destination on the Internet. To the sites the user visits, the traffic appears to originate from the provider’s network rather than from the user’s location.

This serves several purposes:

The model has a trust implication that is easy to miss. The VPN provider sees the destination of every connection the user makes, and it can read any traffic that is not itself encrypted since the VPN decryption takes place at the provider rather than at the destination.

HTTPS still protects contents: page data and passwords are encrypted between the browser and the website, so the provider sees where the user went but not what they did there. The user is not eliminating trust but moving it, from the local Internet provider to the VPN provider. Whether that is an improvement depends on the provider: where it is based and what laws apply to it, whether it logs activity (its claims are unverifiable), and how it makes money, since a free service may be monetizing the traffic it promises to protect.

Demand for these services responds directly to surveillance and content restrictions. In July 2025, the United Kingdom began enforcing age verification requirements for adult content under its Online Safety Act. Proton VPN, a Swiss provider, reported that signups from the UK rose more than 1,400 percent within hours of the rules taking effect.

IPsec

The IETF developed IPsec in the 1990s as a standard for protecting IP traffic at the network layer. IPsec is typically implemented in the operating system kernel.

Unlike TLS, which runs on top of TCP, IPsec sits directly above IP, in the position a TCP or UDP header would occupy. Because it operates below the transport layer, it can protect any higher-layer protocol, including TCP, UDP, and ICMP, without the applications knowing.

AH and ESP

IPsec defines two security protocols:

  1. The Authentication Header (AH) protocol provides authentication and integrity protection. It computes a message authentication code over the IP datagram, excluding fields that change in transit, such as the hop count. A sequence number in the authenticated header protects against replayed packets. AH does not encrypt the payload, so it does not provide confidentiality.

  2. The Encapsulating Security Payload (ESP) protocol authenticates and encrypts the payload it carries.

AH exists for historical reasons. IPsec was designed when encryption was computationally expensive and subject to export restrictions in several countries, so a protocol that provided integrity without encryption had a place. Today there is little reason to use AH. ESP, with its built-in authentication, is the standard choice.

Tunnel Mode and Transport Mode

IPsec operates in two modes that correspond to different deployments. In tunnel mode, the entire original IP packet, headers included, becomes the payload of a new IP packet. The outer packet uses the addresses of the VPN gateways, while the inner packet keeps the original source and destination. This is the encapsulation described earlier, and it is how site-to-site and remote access VPNs work. It also allows private addresses on the internal networks.

In transport mode, the original IP header is kept and only the payload is protected. Transport mode is for host-to-host communication where both endpoints run IPsec. This sounds like TLS, since both protect traffic between two machines. TLS, however, protects one application’s connection, and each application must choose to use it. Transport mode operates at the IP layer, so it protects all traffic between the two machines, whatever the protocol, and the applications do not have to do anything. It is less common, since it requires IPsec on both hosts and interacts poorly with address translation.

Key Exchange with IKE

IPsec uses the Internet Key Exchange (IKE) protocol to set up a connection. IKE authenticates the two peers using certificates or pre-shared keys, negotiates the encryption and integrity algorithms, and generates session keys with a Diffie-Hellman exchange, which provides forward secrecy. It also rekeys periodically, limiting how much traffic any one key protects. The current version is IKEv2. For the data, deployments typically use AES for encryption and SHA-2 based MACs for integrity.

IPsec has several strengths:

It also has weaknesses:

OpenVPN

OpenVPN was released in May 2001 as an open-source alternative to IPsec. It takes a different approach: instead of implementing a new network-layer protocol in the kernel, OpenVPN runs as a user-space application and builds its security on TLS.

OpenVPN creates a virtual network interface, called a TUN device, that the operating system treats as an ordinary network interface. When the system routes traffic to that interface, the OpenVPN process reads it, encrypts it, and sends it to the remote OpenVPN server as regular UDP or TCP packets. Running in user space means traffic crosses the boundary between the kernel and user space twice in each direction, which adds overhead compared with kernel implementations. Recent versions can move data-packet processing into the kernel, which reduces this overhead.

OpenVPN separates its communication into two channels:

  1. The control channel handles connection setup, authentication, and key exchange. It uses TLS, which gives OpenVPN the TLS ecosystem: X.509 certificates, certificate authorities, and mature libraries such as OpenSSL.

  2. The data channel sends the tunneled traffic, protected with an authenticated cipher such as AES-GCM, using keys derived from the TLS handshake. Because the channels are separate, OpenVPN can renegotiate keys periodically without interrupting the data flow, limiting how much traffic any one key protects.

Authentication usually relies on certificates for the server and often for clients as well, though many deployments authenticate users over the encrypted channel with a username and password instead. OpenVPN also supports a static pre-shared key, which is simpler to configure but weaker: the same key protects all traffic, and a compromise of that key exposes all past and future sessions.

OpenVPN runs over either UDP or TCP. UDP is preferred since TCP connections already travel inside the tunnel. If the outer transport is also TCP, a lost packet can trigger retransmission at both layers, and performance degrades. TCP is the fallback for restrictive networks. Many networks that block UDP still allow outbound TCP on port 443, the HTTPS port, and OpenVPN traffic on that port looks like ordinary HTTPS to a simple firewall. Deep packet inspection can still tell them apart.

OpenVPN has several strengths:

Its main weakness is the performance of its traditional user-space design.

TLS-Based Enterprise VPNs

OpenVPN is not the only design built on TLS. The dominant corporate remote access products, including Cisco Secure Client (formerly AnyConnect), Palo Alto Networks GlobalProtect, and Ivanti Connect Secure, also tunnel traffic inside TLS. Each uses its own proprietary protocol, but the mechanism is the one OpenVPN demonstrated: a client sends the traffic to the gateway over TLS, usually on TCP port 443, so the VPN works from almost any network.

The appeal of these products is manageability rather than protocol design. The gateway integrates with corporate authentication, so a login can require a password, a second factor, and a check that the connecting device runs the organization’s security software. Administrators distribute the client and its configuration automatically, often through a web page. The Rutgers VPN is an example: it uses the Cisco Secure Client, and a login requires a NetID password and a Duo two-factor approval.

WireGuard

WireGuard, released in 2016, was designed around the observation that existing VPN protocols had accumulated decades of complexity. Its goals are a simple design, modern cryptography, and high performance.

The implementation is about 4,000 lines of code. The small size makes the code practical to audit, and the protocol’s handshake has been formally verified. WireGuard has been part of the Linux kernel since version 5.6 in March 2020, which gives it the performance of a kernel implementation.

WireGuard makes fixed choices rather than offering options. There is no cipher negotiation. Every WireGuard peer uses the same set of modern primitives:

Eliminating negotiation removes downgrade vulnerabilities. If a primitive is ever broken, the protocol will be versioned rather than renegotiated.

WireGuard does not use certificates. A peer’s identity is its public key. Configuring an interface means generating a key pair, exchanging public keys with peers, and listing which IP addresses belong to each peer.

The simplicity has a trade-off. WireGuard does not distribute keys. Public keys must be exchanged through some other channel, which is trivial for a few machines but requires additional infrastructure in a large deployment. Commercial services have built that infrastructure on WireGuard. For example, Tailscale uses a coordination server to distribute public keys, so a user’s machines form a mesh of WireGuard tunnels without manual key exchange. Cloudflare’s WARP app uses WireGuard to tunnel consumer traffic to Cloudflare’s network.

Peers establish session keys through a handshake that performs a fresh key exchange, so recorded traffic cannot be decrypted later even if a long-term key is stolen. The handshake repeats about every two minutes, so a captured session key exposes only a short window of traffic. All communication runs over UDP, and the protocol does not keep connection state on the wire. A peer that goes silent is not disconnected. WireGuard learns a peer’s current address from the source of its authenticated packets, so a device that moves to a new network just keeps sending. This is why WireGuard behaves well on mobile devices that change addresses as they move between networks.

WireGuard has several strengths:

It also has weaknesses:

Full Tunneling and Split Tunneling

A remote access VPN raises a configuration question: which of the device’s traffic goes through the tunnel?

With full tunneling, all traffic from the device goes through the VPN, whatever its destination.

An employee connected to the corporate VPN who browses a video site sends that traffic through the corporate network first, then out to the Internet. All traffic passes through the corporate gateway, so the organization can apply its network policies to it and see where it goes. The trade-offs are slower general browsing, corporate bandwidth consumed by personal traffic, and an employer that can see every site the employee visits.

With split tunneling, only traffic destined for the corporate network uses the tunnel. Everything else goes directly from the device to the Internet, bypassing the corporate gateway’s controls. Performance improves, and the corporate network handles less traffic. The device, however, is now connected to two networks at once, one trusted and one not. A device compromised through its local connection can then be used to reach the resources available over its tunnel, and the routing is easier to misconfigure. Many organizations disable split tunneling and accept the performance penalty.

VPN Overhead

A VPN adds overhead in several places:

Comparing VPN Protocols

The table below summarizes the protocols in use today, along with two older ones that still appear in configuration menus:

Protocol Characteristics Typical use Notes
IPsec Standardized, kernel-level, complex Enterprise site-to-site, remote access, and mobile devices ESP in tunnel mode is the common configuration; appears as IKEv2 in phone VPN settings
OpenVPN Open source, TLS-based, user space Remote access, consumer VPNs Runs over UDP or TCP; can use port 443 to pass restrictive firewalls
TLS-based enterprise VPNs Proprietary, TLS on port 443 Corporate remote access Cisco Secure Client, GlobalProtect, and similar products
WireGuard Minimal, fast, fixed cryptography All deployment models In the Linux kernel; rapidly growing adoption
L2TP/IPsec Layer 2 tunneling secured by IPsec Legacy remote access Widely supported but slower; displaced by newer protocols
PPTP 1990s Microsoft-led protocol None Broken cryptography; do not use

The trend is toward simpler protocols with fixed, modern cryptography. WireGuard’s rapid adoption shows the appeal of a protocol that supports current best practices instead of decades of legacy options.

What a VPN Does Not Protect

A VPN secures traffic between two points. The endpoints, the user’s anonymity, and the gateway itself fall outside that guarantee.

A VPN protects the path, not the endpoints. If malware compromises a laptop, the attacker reads the data before it enters the tunnel and rides the tunnel into the corporate network with the user’s credentials. If the network at the far end is compromised, the VPN delivers the traffic to the attacker intact.

A VPN does not provide anonymity. It changes who can observe the traffic, but the VPN provider or the corporate gateway sees where all of it goes, and websites still identify users through cookies, browser fingerprinting, and logins.

The gateway itself is a target. A VPN gateway is reachable from the Internet by design, holds authentication credentials, and sits at the edge of the network it protects. A vulnerability in one is therefore valuable to an attacker. In January 2024, attackers exploited two zero-day vulnerabilities in Ivanti Connect Secure to take over the gateways and move into the networks behind them. On January 31, 2024, CISA, the U.S. Cybersecurity and Infrastructure Security Agency, directed federal civilian agencies to disconnect the affected products and rebuild them before returning them to service.

Finally, trust must go somewhere. Every VPN moves trust rather than eliminating it: to the IT department that runs the gateway or to the commercial provider that forwards the traffic. Part of evaluating a VPN is deciding whether that party should be trusted.

Conclusion

A VPN extends secure communication from a single application’s connection to entire networks. Tunneling makes two networks behave as one; encryption, integrity protection, and authentication make the tunnel safe to run over an untrusted Internet. Site-to-site VPNs join networks, remote access VPNs bring individual users into a network, and consumer VPNs redirect a subscriber’s traffic through a provider.

Three protocols dominate. IPsec, from the 1990s, secures traffic at the network layer and is built into enterprise equipment everywhere, but it is complex. OpenVPN, from 2001, builds on TLS in user space, trading performance for portability and the ability to pass restrictive firewalls. WireGuard, from 2016, is small, fast, and formally analyzed, with fixed modern cryptography.

A VPN protects data in transit, but it does not secure the endpoints, provide anonymity, or remove the need to trust whoever operates it. It authenticates who may connect to a network, but it does not examine what the traffic does once inside. Firewalls and intrusion detection take up that problem, and we will cover them, along with zero trust architecture, later.


Lecture 11 Study Guide | List of terms