Latest / CyberCode Academy / Course 17 - Computer Network Security Protocols And Techniques | Episode 9: Foundations of VPN Security: The IPsec Protocol Suite
Transcript
- 0:00Speaker 1: All right, imagine this for a second. You're running a
- 0:04Speaker 1: big marketing firm headquarters in New York. You've got a
- 0:07Speaker 1: branch office in London, and you have salespeople all over
- 0:11Speaker 1: the place, right, working from coffee shops, hotel, Wi.
- 0:14Speaker 2: Fi, total chaos network wise exactly.
- 0:17Speaker 1: And all these people they need constant secure access to
- 0:21Speaker 1: really sensitive client data.
- 0:23Speaker 2: Right. And you know, back in the day, the only
- 0:26Speaker 2: truly secure way to do that was physical. You would
- 0:28Speaker 2: literally lay your own private network. We're talking dedicated fiber,
- 0:32Speaker 2: your own routers, a whole separate infrastructure. Cost of that,
- 0:35Speaker 2: I mean, oh, it's prohibitive. You're essentially building a private
- 0:38Speaker 2: Internet just for your company. It's just not a sustainable
- 0:41Speaker 2: model anymore.
- 0:42Speaker 1: So why reinvent the wheel? Right? The public internet is
- 0:45Speaker 1: already there, it's global. The problem is it's like a
- 0:47Speaker 1: public highway and you need to send I don't know,
- 0:49Speaker 1: a top secret corporate memo.
- 0:51Speaker 2: And that's where the virtual private network, the VPN comes in.
- 0:54Speaker 2: It's such a brilliant virtualization trick.
- 0:58Speaker 1: It is.
- 0:58Speaker 2: It takes your company's track fick and just before it
- 1:01Speaker 2: hits that public highway, it wraps it up and crypts
- 1:04Speaker 2: it and shoves it through this this secure channel. We
- 1:08Speaker 2: call it a tunnel.
- 1:08Speaker 1: Tunnel, right, creates a private lane on the public highway exactly.
- 1:11Speaker 2: You get all the privacy of that dedicated network, but
- 1:14Speaker 2: without that massive physical cause.
- 1:16Speaker 1: Okay, so we all get the concept of the tunnel.
- 1:19Speaker 1: But what's the engine, you know, once the blueprint that
- 1:22Speaker 1: actually builds it, that manages the keys and make sure
- 1:24Speaker 1: every single packet that shows up on the other end
- 1:27Speaker 1: is exactly what you sent.
- 1:28Speaker 2: And that is what we're going to unpack. That engine
- 1:31Speaker 2: is a protocol called ip SC, which stands for Internet
- 1:34Speaker 2: Protocol Security.
- 1:35Speaker 1: Let's do it so ip SC. Okay, this is the
- 1:38Speaker 1: thing that makes most VPNs tick.
- 1:40Speaker 2: It's absolutely fundamental. It's the most widely deployed protocol for
- 1:43Speaker 2: this stuff. And what's so interesting is where it works.
- 1:46Speaker 2: It's down at the network layer, the IP layer, so.
- 1:49Speaker 1: It's protecting everything above it no matter what application you're using.
- 1:52Speaker 2: Precisely, it doesn't care. It protects IP version four, IP
- 1:56Speaker 2: version six, It just secures the traffic before it even
- 1:59Speaker 2: hits it the wire.
- 2:00Speaker 1: I think when most people hear VPN, they just think encryption,
- 2:03Speaker 1: you know, scrambling the data. But ip SC is it's
- 2:08Speaker 1: a whole framework, isn't it. It's doing a lot more
- 2:10Speaker 1: than just that.
- 2:10Speaker 2: Oh, it's a full security suite. It's providing really five
- 2:15Speaker 2: essential services at once. Think of it like a security checklist.
- 2:18Speaker 1: Okay, what's first on the list?
- 2:19Speaker 2: First up is access control? Pretty simple. It just makes
- 2:22Speaker 2: sure that only authorized people like our salesperson's laptop can
- 2:27Speaker 2: even try to use the network.
- 2:28Speaker 1: So it's the bouncer at the door exactly.
- 2:31Speaker 2: Then number two is data origin authentication. This is critical
- 2:35Speaker 2: when a packet arrives in New York, the router there
- 2:38Speaker 2: needs to be absolutely certain it genuinely came from the
- 2:41Speaker 2: London office and not some attacker pretending to be them.
- 2:44Speaker 1: And that's different from the third pillar, which is integrity protection.
- 2:47Speaker 2: Mm hmm. It's a subtle but important difference. Authentication proves
- 2:51Speaker 2: who sent it. Integrity proves that what they sent hasn't
- 2:55Speaker 2: been messed with in transit, Like.
- 2:57Speaker 1: A tamper proof seal on a package that is.
- 2:59Speaker 2: The perfect analoge. If that seal is broken, you know
- 3:02Speaker 2: someone might have altered the contents. Fourth on the list,
- 3:05Speaker 2: ip SC protects against replay attacks.
- 3:08Speaker 1: What's that exactly?
- 3:09Speaker 2: An attacker could say capture a valid encrypted packet, maybe
- 3:12Speaker 2: a transfer funds command, and then just try to rescend
- 3:15Speaker 2: it an hour later. Ip SC has mechanisms to see
- 3:19Speaker 2: that it's old data and just reject it instantly.
- 3:21Speaker 1: And then finally number five is the one.
- 3:23Speaker 2: Everybody knows, confidentiality. That's the encryption scrambling the data, so
- 3:28Speaker 2: if anyone does grab it, it's just useless gibberish to them.
- 3:31Speaker 1: So to run that whole checklist, ip SC needs a toolkit.
- 3:34Speaker 2: It does. It relies on a set of cryptographic tools.
- 3:37Speaker 2: For the key exchange, you know, to agree on a
- 3:40Speaker 2: secret key, we use things like Diffy Hellman. For integrity,
- 3:43Speaker 2: we use hashing algorithms like SAHA to create that digital signature.
- 3:47Speaker 2: And for confidentiality, strong encryption like AES.
- 3:51Speaker 1: Okay, that makes sense a standard set of tools. But
- 3:55Speaker 1: before our salesperson can send anything, their laptop and the
- 3:58Speaker 1: router at headquarters have to agree on which tools they're
- 4:01Speaker 1: going to use.
- 4:02Speaker 2: Yes, and that formal agreement is called a security association
- 4:06Speaker 2: or NSSA. It's a logical connection that defines all of
- 4:10Speaker 2: those specifics, the keys, the algorithms, how long they're good for.
- 4:14Speaker 1: Now here's a detail. I find interesting. An essay is simplex.
- 4:19Speaker 1: It's one way.
- 4:20Speaker 2: It is a unidirectional connection.
- 4:22Speaker 1: Why do that? Why not just have one simple to
- 4:25Speaker 1: a tunnel. It feels like you're complicating it.
- 4:28Speaker 2: You might think so, but it's for flexibility. You might
- 4:31Speaker 2: have different security policies for data going out versus data
- 4:34Speaker 2: coming in. So New York sending to London, that's one
- 4:37Speaker 2: to say London replying to New York. That requires a
- 4:39Speaker 2: completely separate second essay.
- 4:41Speaker 1: So every device, every router has to keep a database
- 4:44Speaker 1: of all these one way connections. What kind of information
- 4:47Speaker 1: is it's storing for each essay?
- 4:48Speaker 2: A few key things, the destination address, the encryption and
- 4:52Speaker 2: integrity algorithms, the key is, of course, but the most
- 4:55Speaker 2: crucial part is something called the security parameter index the
- 4:58Speaker 2: SPsi eSPI thirty two bit number in the packet center.
- 5:02Speaker 2: It basically acts like a unique ID for that specific essay, So.
- 5:05Speaker 1: It's like a secret handshake or a badge number.
- 5:07Speaker 2: Exactly like a badge number, the receiving router sees the packet,
- 5:10Speaker 2: looks at the SPI and instantly knows, ugh, this belongs
- 5:14Speaker 2: to connection forty seven. I need to use as two
- 5:18Speaker 2: fifty six and this specific SAHA hash. It just removes
- 5:22Speaker 2: all ambiguity.
- 5:23Speaker 1: Okay, this is where it gets really interesting for me
- 5:25Speaker 1: managing all these essays and doing that secure Diffie Hellman
- 5:29Speaker 1: key exchange. That sounds like a job for another protocol.
- 5:33Speaker 2: It is, and that protocol is the Internet Key Exchange
- 5:36Speaker 2: or IKE. IKE is the real architect here. It builds
- 5:38Speaker 2: the whole structure.
- 5:39Speaker 1: And we're mostly on version two now IKA.
- 5:41Speaker 2: Two right, which is a huge improvement. It solves a
- 5:44Speaker 2: lot of real world networking headaches that the first version
- 5:47Speaker 2: struggled with.
- 5:48Speaker 1: Can you give us an example of one of those headaches?
- 5:50Speaker 2: The biggest one, by far is.
- 5:51Speaker 1: Not traversal ah network address translation, the bane of so
- 5:55Speaker 1: many connections.
- 5:56Speaker 2: Our salesperson in the hotel, their laptop has a private
- 6:00Speaker 2: IP address from the hotel's network, the hotel router has
- 6:03Speaker 2: one public IP. IKVA one was notoriously bad at building
- 6:07Speaker 2: tunnels through that kind of setup, so.
- 6:09Speaker 1: IKD just handles that private to public jump seamlessly, seamlessly.
- 6:13Speaker 2: It was designed for it. It's also just more efficient,
- 6:16Speaker 2: uses less bandwidth, has a keep alive feature built in.
- 6:20Speaker 2: It's actually mandated now for things like five G security,
- 6:24Speaker 2: So I could.
- 6:24Speaker 1: Self works in two stages, right, it's a two phase process.
- 6:27Speaker 2: It's very methodical, yes, and for a good reason. IKE
- 6:30Speaker 2: Phase one is all about setting up a secure channel
- 6:33Speaker 2: just for management, so.
- 6:34Speaker 1: It's not for the actual company data.
- 6:36Speaker 2: Yet, not at all. Its only job is to create
- 6:38Speaker 2: a secure tunnel for the two routers to talk to
- 6:40Speaker 2: each other safely. They negotiate parameters, run diffy hellman to
- 6:44Speaker 2: get a shared key and authenticate each other.
- 6:47Speaker 1: So Phase one build a secure little meeting room so
- 6:49Speaker 1: they can plan the next step without anyone eavesdropping.
- 6:52Speaker 2: Perfect way to put it. Then, once that room is secure,
- 6:56Speaker 2: they moved to IKE Phase two, and this happens through
- 6:58Speaker 2: the tunnel they just built. In phase two, they negotiate
- 7:01Speaker 2: the rules for the actual data tunnel. They'll decide are
- 7:04Speaker 2: we using AH or ESP transport or tunnel mode? What
- 7:08Speaker 2: are the keys and lifetimes for the real corporate data?
- 7:11Speaker 2: And once phase two is done, the data tunnel is
- 7:13Speaker 2: finally ready to go.
- 7:14Speaker 1: That's a perfect transition. Let's talk about those protocols they
- 7:17Speaker 1: negotiate AH versus ESP. Let's start with AH. The authentication header.
- 7:22Speaker 2: AH is pretty narrow in its focus. It provides data origin,
- 7:27Speaker 2: authentication and integrity protection. That's it.
- 7:30Speaker 1: So no encryption, no encryption whatsoever, absolutely no confidentiality.
- 7:35Speaker 2: Why would anyone use that today? I mean, is it
- 7:37Speaker 2: encryption the whole point of a VPN for most people?
- 7:39Speaker 1: That is a great question. And honestly, it's mostly a
- 7:42Speaker 1: legacy option. Maybe in some very niche case where you
- 7:46Speaker 1: only care about integrity and speed is everything, But the
- 7:49Speaker 1: data itself isn't sensitive at all. But for the most
- 7:51Speaker 1: part AH has been superseded by esp okay.
- 7:54Speaker 2: But how does it work? How does it prove integrity
- 7:57Speaker 2: without encryption?
- 7:57Speaker 1: It's all about hashing. The sender calculate it's a cryptographic hash,
- 8:01Speaker 1: a digital fingerprint of the whole packet, and puts that
- 8:03Speaker 1: fingerprint in the AA chicker. The receiver gets the packet,
- 8:06Speaker 1: recalculates the hash on its own, and if the two
- 8:08Speaker 1: fingerprints match, the packet is authentic and untampered with. Wait,
- 8:12Speaker 1: I see a problem there. As a packet crosses the Internet,
- 8:15Speaker 1: some fields in the IP header have to change, like
- 8:18Speaker 1: the time to live the TTL it goes down at
- 8:20Speaker 1: every router hop it does, so wouldn't that change the
- 8:23Speaker 1: packet and make the hash calculation fail?
- 8:25Speaker 2: On the other end, Ah, you've hit on the subtle
- 8:28Speaker 2: genius of it. You're absolutely right. So ip sec is
- 8:31Speaker 2: smart enough to know which fields are mutable, which ones
- 8:33Speaker 2: are supposed to change. It simply excludes the TTL and
- 8:37Speaker 2: the checksum from the hash calculation.
- 8:39Speaker 1: Oh that's clever.
- 8:40Speaker 2: It is. It's like signing a document but leaving a
- 8:43Speaker 2: space for the notary to stamp it later. The stamp
- 8:46Speaker 2: doesn't invalidate your signature.
- 8:47Speaker 1: Okay, clever. So if AH is the integrity only option,
- 8:51Speaker 1: then the real powerhouse is ESP. The encapsulating Security Payload.
- 8:56Speaker 2: ESP is the undisputed champion. It's what everyone uses because
- 8:59Speaker 2: it gives you both integrity and encryption.
- 9:02Speaker 1: How does it combine the two?
- 9:03Speaker 2: The sequence is important. First, the original data payload gets
- 9:06Speaker 2: encrypted with an algorithm like AES. Then a MESSC a
- 9:11Speaker 2: message authentication code, which is that hash or signature, is
- 9:14Speaker 2: calculated over the now encrypted data.
- 9:16Speaker 1: So the integrity check is protecting the integrity the ciphertext,
- 9:20Speaker 1: not the original data exactly.
- 9:22Speaker 2: The receiver gets the packet, checks the signature first to
- 9:25Speaker 2: make sure the encrypted blob wasn't modified, and only then
- 9:28Speaker 2: does it go ahead and decrypt it. It gives you
- 9:30Speaker 2: confidence in every aspect of the data.
- 9:33Speaker 1: So we've established what protocol is wrapping the data, usually ESP.
- 9:38Speaker 1: Now let's talk about how it wraps it. The two
- 9:40Speaker 1: modes transport versus.
- 9:42Speaker 2: Tunnel, right, And this distinction is all about how much
- 9:45Speaker 2: of the original packet you're protecting. In transport mode, IPsec
- 9:49Speaker 2: only protects the upper layer information, so that's the TCP
- 9:52Speaker 2: header and the actual user data.
- 9:55Speaker 1: But and this is the key part, it uses the
- 9:57Speaker 1: original IP header. So an observer on the Internet can't
- 10:00Speaker 1: see your data, but they can still see the original
- 10:02Speaker 1: source and destination IP addresses. They know who is talking
- 10:06Speaker 1: to whom.
- 10:07Speaker 2: Correct. Now contrast that with tunnel mode. Tunnel mode is comprehensive.
- 10:10Speaker 2: It takes the entire original IP packet, the original IP
- 10:13Speaker 2: header included, and encrypts the whole thing.
- 10:16Speaker 1: So the original routing information is now hidden inside the
- 10:19Speaker 1: encrypted payload.
- 10:20Speaker 2: Completely hidden. But now you have a problem. If you
- 10:22Speaker 2: hid in the address, how do you mail the letter.
- 10:25Speaker 1: You need a new envelope, a new IP header.
- 10:27Speaker 2: You add a new IP header to the outside. This
- 10:30Speaker 2: new header just has the aggresses of the tunnel endpoints.
- 10:34Speaker 2: So the public IP of the hotel and the public
- 10:36Speaker 2: IP of the New York headquarters. The Internet only sees
- 10:40Speaker 2: the routers talking, not the actual computers inside.
- 10:44Speaker 1: So that gives us four possible combinations. But if you
- 10:46Speaker 1: want maximum security, I'm guessing one of them is the
- 10:49Speaker 1: clear winner.
- 10:50Speaker 2: Oh absolutely. Tunnel mode with ESP is the standard. It's
- 10:53Speaker 2: the most widely used and often mandated configuration for any
- 10:57Speaker 2: serious VPN because.
- 10:58Speaker 1: It protects the entire package, the data and the metadata.
- 11:01Speaker 2: It gives you maximum confidentiality and crucially, traffic privacy. You're
- 11:05Speaker 2: not just hiding what's being said, You're hiding who is
- 11:08Speaker 2: saying it and to whom inside the corporate network.
- 11:10Speaker 1: Well, let's bring this all back to our marketing company.
- 11:12Speaker 1: Let's trace a packet.
- 11:13Speaker 2: Sure, so inside the New York head quarters traffic is
- 11:16Speaker 2: just normal unsecured IP. The second a packet is destined
- 11:20Speaker 2: for London and hits.
- 11:22Speaker 1: That main router, the ip sec process kicks in right.
- 11:26Speaker 2: That router takes the normal IP packet and based on
- 11:29Speaker 2: the essays negotiated by IKOB two, it wraps it up
- 11:33Speaker 2: in tunnel mode. ESP, slaps that new ipheater on the
- 11:36Speaker 2: outside and sends it on its way.
- 11:38Speaker 1: Then the London router receives it, unwraps it, checks the signature,
- 11:42Speaker 1: decrypts it, and sends the original clean IP packet onto
- 11:45Speaker 1: the destination computer inside the office.
- 11:47Speaker 2: Perfect.
- 11:48Speaker 1: And for our salesperson in.
- 11:49Speaker 2: The hotel, they're running VPN client software on their laptop.
- 11:54Speaker 2: That software is what does the negotiation, manages the essays
- 11:58Speaker 2: and basically access their end to the time. It's that
- 12:00Speaker 2: software that does all the complex IPsec wrapping before the
- 12:03Speaker 2: data ever leaves the laptop.
- 12:05Speaker 1: It really is amazing. This completely seamless secure connection is
- 12:08Speaker 1: built from all these complex interlocking steps happening almost instantly
- 12:12Speaker 1: at the network layer.
- 12:13Speaker 2: It really is the foundation of modern remote work. It
- 12:15Speaker 2: turns the entire insecure global Internet into your own private,
- 12:19Speaker 2: trusted corporate network, a true cryptographic blueprint.
- 12:23Speaker 1: So to leave you with a final thought exercise on
- 12:25Speaker 1: all this, we established that esp in tunnel mode is
- 12:29Speaker 1: the gold standard because it hires the original IP heater.
- 12:32Speaker 1: So think about this. If a rival company was monitoring
- 12:35Speaker 1: all the Internet traffic coming out of your headquarters, what
- 12:38Speaker 1: critical information about your internal network structure could they figure
- 12:41Speaker 1: out if you were forced to use transport mode instead,
- 12:44Speaker 1: what would that exposed original IP header tell them,