Defence: WireGuard
WireGuard is a small, modern VPN. Follow a laptop on café Wi-Fi as it builds an encrypted tunnel to a home server: first watch an attacker's packets meet total silence, then see public keys, a one-round-trip handshake and cryptokey routing keep every packet private and genuine.
5 quick questions
Pick an answer to see why. Your score saves with your progress.
01An attacker sends a made-up handshake to the server's WireGuard port. What does the server send back?
Without the server's public key the attacker cannot make a valid mac1, so the server drops the packet silently. A scanner cannot even tell WireGuard is there.
02How does a WireGuard server know which peer sent a data packet?
Identity comes from cryptography, not addresses. The outer address can change as the laptop roams; the key cannot be faked.
03A packet from the laptop's session decrypts fine, but its inner source is 10.8.0.9, while the laptop's allowed IPs are 10.8.0.2/32. What happens?
Cryptokey routing: the key says who sent it, and the allowed IPs say which inner addresses that peer may use. Anything else is dropped.
04How many messages does the WireGuard handshake take before the laptop can send data?
An initiation (148 bytes) and a response (92 bytes). There is no cipher negotiation because the cryptography is fixed.
05The attacker records a valid tunnel packet and sends an exact copy later. Why is it dropped?
Every data packet carries a counter, and the receiver refuses a counter it has already accepted. An edited copy fails the tag instead.
Glossary
- VPN
- Virtual private network: an encrypted tunnel that carries your packets across an untrusted network as if you were on the private one.
- Peer
- Another WireGuard device you trust, identified by its public key and the allowed IPs it may use.
- Public key / private key
- A matched pair of numbers. The private key never leaves its device; the public key can be shared freely.
- Allowed IPs
- The tunnel addresses a peer may send from, and the addresses that get sent to it.
- Cryptokey routing
- WireGuard's rule that ties each peer's public key to its allowed IPs, both for sending and for checking what arrives.
- Handshake
- The two messages in which the peers prove who they are and make fresh session keys.
- mac1
- A check field in each handshake message, computed with the receiver's public key, so strangers' packets can be dropped at once.
- IPsec
- An older family of VPN standards that negotiates its algorithms with IKEv2 and protects packets with ESP.
Notes and sources
- 198.51.100.23, 203.0.113.5 and 192.0.2.66 are RFC 5737 documentation addresses; 10.8.0.2, 10.8.0.1 and 192.168.1.0/24 are private RFC 1918 addresses. All keys are illustrative.
- Port 51820 is the conventional choice, not a fixed one. A home router would forward that UDP port to the server.
- An optional extra pre-shared key can be mixed into the handshake as a second layer against future quantum computers.
- Under heavy load the server can answer a handshake with a 64-byte cookie reply instead, so a flood of handshakes from forged addresses costs it little work.
- Sizes are from the WireGuard whitepaper: initiation 148 bytes, response 92 bytes, data = 16-byte header + padded packet + 16-byte tag.
- Sessions are re-keyed after 120 seconds of use, and keys older than 180 seconds are refused.
Quiz Unlocks after the last step.