csperkins.org

Networked Systems H (2020-2021)

Lecture 3: Secure Communications

This lecture considers secure communications in the Internet. It reviews the need for security, and the principles of encryption, integrity protection, and authentication of messages. It explains the principles of operation of the Transport Layer Security Protocol (TLS), version 1.3, and how it protects Internet traffic. And it briefly reviews some of the issues around writing secure software.

Part 1: Secure Communications

The 1st part of this lecture discussed the need for security in Internet communications. It reviews why end-to-end encryption and message integrity protection are essential to protect Internet users for eavesdropping, identity theft, fraud, and other attacks. And it discusses some of the tensions and concerns that have been raised about the provision of such protection.

00:00:00.000 In the last lecture I discussed the

00:00:03.651 behaviour of TCP and some issues around

00:00:06.302 connection establishment. One of those issues was

00:00:08.953 the observation that establishing a secure connection,

00:00:11.604 using TLS, was slower than establishing an

00:00:14.255 insecure connection.

00:00:15.013 In this lecture I want to talk

00:00:17.764 more about security.

 

00:00:20.000 In this first part, I’ll talk about

00:00:22.572 why security is important, and why we

00:00:25.144 need to secure communications.

00:00:26.614 Then, in part two, I’ll talk about

00:00:29.286 the principle of secure communication, and the

00:00:31.858 cryptographic techniques that can be used to

00:00:34.430 protect data.

00:00:35.165 Part three of the lecture will describe

00:00:37.837 some of the behaviour of the Transport

00:00:40.409 Layer Security protocol that provides security for

00:00:42.981 most Internet traffic.

00:00:44.084 And finally, in part four, I’ll talk

00:00:46.756 about some general issues around network security

00:00:49.328 and how to write secure networked applications.

 

00:00:53.000 So, why do we need secure communications?

00:00:55.362 Well, the fundamental problem is that it’s

00:00:57.823 possible to monitor network traffic. This can

00:01:00.185 be done by wiretapping the network links

00:01:02.546 down which the data flows, or it

00:01:04.908 can be done by configuring network routers

00:01:07.269 to save a copy of the packets

00:01:09.631 they forward.

00:01:10.305 The result is that the traffic that

00:01:12.767 passing across the network can be monitored

00:01:15.129 by third parties. If you want to

00:01:17.490 ensure that the data you send across

00:01:19.852 the network is private, then that data

00:01:22.213 needs to be encrypted somehow.

 

00:01:24.000 Similarly, a network router can modify the

00:01:26.322 packets it’s forwarding. This means that the

00:01:28.643 router can change the data being delivered,

00:01:30.965 without the consent of the sender.

00:01:32.955 The sender cannot stop this happening,

00:01:34.945 but it can add some message integrity

00:01:37.267 protection, such as a digital signature,

00:01:39.257 to allow the receiver to detect and

00:01:41.578 reject messages that have been tampered with.

 

00:01:44.000 Finally, there are numerous devices in the

00:01:46.788 network, known as middleboxes, that try to

00:01:49.577 improve communication by somehow interpreting or modifying

00:01:52.365 the data being sent. For example,

00:01:54.755 we spoke about network address translation in

00:01:57.543 the last lecture, where a NAT router

00:02:00.332 rewrites the addresses and port numbers in

00:02:03.120 TCP/IP headers to allow several machines to

00:02:05.908 share a single IP address.

 

00:02:08.000 Other examples include network firewalls that monitor

00:02:10.677 traffic, and try to prevent “bad” traffic

00:02:13.354 from entering a network. Or the so-called

00:02:16.031 “WAN accelerator” devices that try to improve

00:02:18.708 the performance of TCP connections running over

00:02:21.385 satellite links.

00:02:22.149 If not carefully maintained, these devices tend

00:02:24.926 to lead to network ossification, where they

00:02:27.603 tend to limit the ability to change

00:02:30.280 network protocols. A final role of secure

00:02:32.957 communications is to limit the ability of

00:02:35.634 such devices to inspect and act on

00:02:38.311 traffic, so helping to ensure that the

00:02:40.988 network can continue to evolve.

 

00:02:44.000 A lot of different organisations monitor the

00:02:46.950 network, for a lot of different reasons.

 

00:02:50.000 These include governments, intelligence agencies, and law

00:02:53.271 enforcement agencies. For example, local police often

00:02:56.543 monitor the network as part of their

00:02:59.814 crime prevention activities, domestic intelligence agencies inspect

00:03:03.086 traffic to protect against terrorism, or to

00:03:06.357 monitor foreign targets, and foreign intelligence agencies

00:03:09.629 might try to spy on domestic targets.

 

00:03:13.000 That this happens shouldn’t be a surprise.

00:03:15.256 And there are clearly good reasons for

00:03:17.611 some of this monitoring.

 

00:03:19.000 Many people would agree, I think,

00:03:21.540 that targeted wiretaps on suspected criminals,

00:03:24.079 subject to appropriate oversight, the need to

00:03:27.042 obtain a warrant of some sort,

00:03:29.581 and when there’s probable cause, is probably

00:03:32.544 not unreasonable.

00:03:33.391 Few people would object to actively monitoring

00:03:36.453 the network traffic of those actively suspected

00:03:39.416 of being engaged in serious crimes,

00:03:41.956 terrorist activities, child abuse, and so on.

00:03:44.919 People differ on what crimes they consider

00:03:47.981 serious, or on the standards of probable

00:03:50.944 cause, or on the amount of oversight

00:03:53.907 needed, but all societies accept some degree

00:03:56.870 of monitoring and oversight of some traffic.

00:03:59.833 However, Edward Snowden showed that some intelligence

00:04:02.895 agencies, including but certainly not limited to

00:04:05.858 the “Five Eyes”, the UK, US,

00:04:08.398 Canada, Australia, and New Zealand, were conducting

00:04:11.360 pervasive monitoring of all network traffic.

 

00:04:14.000 Many felt that this indiscriminate monitoring of

00:04:16.682 all network traffic, without probable cause or

00:04:19.364 suspicion, was a step too far.

00:04:21.663 In part I think this came from

00:04:24.445 a distrust of those governments, their motives,

00:04:27.127 and how they might use the data.

00:04:29.808 The people they were supposed to represent

00:04:32.490 were unconvinced that the monitoring was actually

00:04:35.172 doing them good.

00:04:36.322 But, in part, there was also the

00:04:39.104 realisation that if supposedly friendly governments were

00:04:41.786 monitoring traffic indiscriminately, then so were others.

00:04:44.467 The great firewall of China is often

00:04:47.149 cited here, along with monitoring by Russia,

00:04:49.831 Iran, Saudi Arabia, and others.

00:04:51.747 This led to a push to enable

00:04:54.529 pervasive encryption, to encrypt more and more

00:04:57.211 of the traffic crossing the Internet.

00:04:59.510 The most visible manifestation of this is

00:05:02.192 that most web sites now use HTTPS

00:05:04.873 URLs and encrypt their traffic, but the

00:05:07.555 spread of encryption has been wider than

00:05:10.237 the web. The result is that most

00:05:12.919 Internet traffic is now encrypted by default,

00:05:15.601 hindering, but not preventing, pervasive monitoring.

 

00:05:18.000 Governments are not the only organisations to

00:05:21.080 monitor network traffic, of course.

00:05:23.280 We’ve all contacted a business and been

00:05:26.460 told about our call “may be monitored

00:05:29.540 for quality and training purposes”, for example.

00:05:32.620 Some of this monitoring by businesses is

00:05:35.800 necessary for regulatory compliance. Banking and insurance

00:05:38.880 industries, for example, require records to be

00:05:41.960 kept in most cases, to prevent fraud.

00:05:45.040 There are good reasons for a lot

00:05:48.120 of this monitoring.

00:05:49.440 Other aspects of monitoring and tracking by

00:05:52.620 businesses are perhaps less beneficial. Targeted advertising

00:05:55.700 and customer profiling is frequently cited as

00:05:58.780 problematic, for example.

00:06:00.100 Communications security measures, such as encryption,

00:06:02.840 can help to reduce such unwanted monitoring.

00:06:05.920 The effect is small though, since this

00:06:09.100 type or monitoring and tracking is often

00:06:12.180 delivered by the sites we intentionally visit,

00:06:15.260 rather than by snooping on communications.

 

00:06:18.000 We also see network operators monitoring traffic

00:06:20.697 on the networks they operate.

00:06:22.623 Again, there are both beneficial and problematic

00:06:25.419 reasons for this.

00:06:26.575 Network operators monitor traffic to understand how

00:06:29.371 well their networks are operating, and whether

00:06:32.068 they’re meeting their quality of service goals.

00:06:34.765 It’s common, for example, for network operators

00:06:37.561 to inspect the sequence and acknowledgement numbers

00:06:40.258 in TCP flows traversing their networks.

00:06:42.569 This lets them understand if packets are

00:06:45.266 being lost, or if the time taken

00:06:47.962 for packets to traverse the network is

00:06:50.659 building up, both of which are signs

00:06:53.355 that the network is becoming overloaded.

00:06:55.667 This helps the operators decide when to

00:06:58.463 reroute traffic, or when to install more

00:07:01.160 network capacity, to keep good performance.

00:07:03.471 Few would argue that this sort of

00:07:06.167 monitoring is a problem.

00:07:07.708 On the other hand, operators can monitor

00:07:10.505 traffic to profile what sites their customers

00:07:13.201 are visiting. This information could then to

00:07:15.898 sold to advertisers, or could be used

00:07:18.595 to negatively influence the performance of traffic.

00:07:21.291 For example an operator might choose to

00:07:24.088 lower the priority of Netflix traffic for

00:07:26.784 customers who haven’t signed up for their

00:07:29.481 streaming video package.

00:07:30.636 Many people are less comfortable with such

00:07:33.433 behaviours, and communications security measures can limit

00:07:36.130 their effectiveness.

 

00:07:37.000 Finally, of course, there are criminals and

00:07:40.289 malicious users, that try to steal data

00:07:43.577 and user credentials, perform identity theft,

00:07:46.396 or conduct other attacks. Communications security clearly

00:07:49.685 cannot prevent such attacks, but it can

00:07:52.974 certainly limit their scope, by limiting the

00:07:56.262 amount of information that’s available and visible

00:07:59.551 to those monitoring the network.

 

00:08:03.000 As a result of these various attacks,

00:08:05.780 there are a range of measures deployed

00:08:08.560 that can help to protect privacy by

00:08:11.340 encrypting network traffic

00:08:12.531 Unfortunately, what makes this problem space challenging

00:08:15.411 is that the mechanisms used to protect

00:08:18.191 against malicious attackers also prevent benign monitoring.

00:08:20.971 There’s no known way to stop criminals

00:08:23.751 and malicious attackers from accessing private data,

00:08:26.531 that doesn’t also stop law enforcement from

00:08:29.311 doing so, for example.

 

00:08:32.000 In addition to monitoring and observing data

00:08:34.800 as it traverses the network, many organisations

00:08:37.600 might also try to modify messages.

00:08:40.000 Governments and law enforcement, for example,

00:08:42.500 might require ISPs to censor or modify

00:08:45.300 DNS responses to restrict access to certain

00:08:48.100 sites. They might require DNS responses to

00:08:50.900 be modified to indicate that certain sites

00:08:53.700 don’t exist. Or to change the address

00:08:56.500 in the DNS response to direct users

00:08:59.300 to a page indicating that the content

00:09:02.100 is blocked.

 

00:09:03.000 Alternatively, governments they might require ISPs and

00:09:06.317 network operators to block or rewrite traffic

00:09:09.635 containing certain content.

00:09:11.057 As with government traffic monitoring, there can

00:09:14.474 be reasonable and unreasonable reasons for governments

00:09:17.791 to modify messages.

00:09:19.213 Many countries have widely accepted laws about

00:09:22.630 restricting hate speech, blocking child pornography,

00:09:25.474 or preventing terrorism. Part of the implementation

00:09:28.791 of such laws is often by modifying

00:09:32.109 DNS responses, to limit access to certain

00:09:35.426 sites.

 

00:09:36.000 The same techniques can, of course,

00:09:38.181 also be used to block other types

00:09:40.725 of content or restrict other kinds of

00:09:43.270 speech.

00:09:44.383 Businesses and network operators might also block

00:09:47.028 or modify content. The DNS server in

00:09:49.572 a cafe or a train that redirects

00:09:52.117 you to a sign-up page and asks

00:09:54.661 for payment before letting you browse the

00:09:57.206 web on their WiFi is an example.

 

00:09:59.000 Other examples might be services that filter

00:10:02.301 spam or block malicious attachments, that enforce

00:10:05.601 terms of service, or that try to

00:10:08.902 prevent copyright infringement.

00:10:10.316 And, finally, of course there are criminals

00:10:13.717 and malicious users, people modifying content to

00:10:17.017 conduct phishing scams, steal identity, mislead and

00:10:20.318 defraud.

00:10:21.539 Again, what makes this problem space challenging,

00:10:24.940 is that mechanisms that protect message integrity

00:10:28.241 against malicious attackers, also prevent benign modification.

00:10:31.541 For example, a recent development in network

00:10:34.942 security is DNS over HTTPS. This is

00:10:38.242 an approach to encrypting DNS traffic,

00:10:41.071 that was designed to protect users from

00:10:44.372 phishing attacks, where an attacker spoofs DNS

00:10:47.672 responses to perform identity theft. It does

00:10:50.973 this successfully.

00:10:51.916 Unfortunately, some Internet service providers in the

00:10:55.316 UK intentionally spoofed DNS responses to block

00:10:58.617 access to sites hosting child abuse material,

00:11:01.918 as part of a government mandated block

00:11:05.218 list. Encrypting DNS traffic, to prevent identity

00:11:08.519 theft, unintentionally also prevented the child abuse

00:11:11.819 block list from working, since both relied

00:11:15.120 on the same vulnerability.

00:11:17.006 There are difficult questions in this space.

00:11:20.406 It’s not clear that we have the

00:11:23.707 right answers.

 

00:11:25.000 The final reason for securing communication relates

00:11:29.165 to protocol ossification.

00:11:30.950 It’s common for network operators deploy middleboxes,

00:11:35.215 of various sorts, to monitor or modify

00:11:39.380 traffic. These can be devices such as

00:11:43.545 NATs and firewalls, traffic shapers, filters,

00:11:47.115 or protocol accelerators.

 

00:11:49.000 These middleboxes need to understand the traffic

00:11:51.695 they’re observing or modifying.

00:11:53.234 For example, in order to translate IP

00:11:56.029 addresses and ports, a NAT needs to

00:11:58.724 know the format of an IP packet

00:12:01.418 and where the ports are located in

00:12:04.113 the TCP or UDP header.

00:12:06.038 @12:04 Equally, a traffic shaping device,

00:12:08.448 intended to limit the throughput of TCP

00:12:11.142 connections for a particular user, needs to

00:12:13.837 understand the congestion control algorithm used by

00:12:16.532 TCP, otherwise how can it influence the

00:12:19.226 sending rate of a connection?

00:12:21.151 This means that the network becomes more

00:12:23.946 complex.

00:12:25.081 Devices in the network no longer just

00:12:27.875 look at the IP header, and forward

00:12:30.570 the packets based on their destination address.

00:12:33.265 They also understand some details of TCP,

00:12:35.959 UDP, and other protocols, and observe,

00:12:38.269 inspect, and modify those protocols too.

00:12:40.579 This leads to protocol ossification, where it

00:12:43.373 becomes difficult to change the protocols running

00:12:46.068 between the endpoints, because doing to interacts

00:12:48.763 poorly with middleboxes that don’t understand the

00:12:51.457 new version of the protocol.

00:12:53.382 For example, it would be very difficult

00:12:56.177 to change the format of the TCP

00:12:58.871 header now, even if we could upgrade

00:13:01.566 all the end systems to support the

00:13:04.261 new version, because of all the NATs

00:13:06.955 and firewalls that would also need updating.

 

00:13:09.000 This protocol ossification, where the network learns

00:13:11.794 about the transport and higher layer protocols,

00:13:14.588 and effectively prevents them from being upgraded,

00:13:17.381 occurs because the network has visibility into

00:13:20.175 those protocols.

00:13:20.973 Encryption offers one way to prevent ossification.

00:13:23.867 The more of a protocol that is

00:13:26.661 encrypted, the easier it is to change,

00:13:29.454 since the encryption will have stopped middleboxes

00:13:32.248 from understanding or modifying the data.

00:13:34.643 There’s a trade-off, though, between the ability

00:13:37.537 to change end-to-end protocols, and the ability

00:13:40.330 of the network to helpful features.

00:13:42.725 The more of a protocol that’s encrypted,

00:13:45.519 the easier it is to change the

00:13:48.313 protocol, but the harder it is for

00:13:51.106 middleboxes to provide help from the network.

 

00:13:55.000 As we’ve seen, there are good reasons

00:13:57.764 to encrypt and authenticate data, to protect

00:14:00.528 privacy, to prevent fraud, and to allow

00:14:03.293 protocols to evolve while avoiding network ossification.

00:14:06.057 Providing security in this way is a

00:14:08.921 good thing, but there are always trade-offs,

00:14:11.685 and I’ve tried to highlight some of

00:14:14.449 these. In particular, there are always examples

00:14:17.214 where providing security to protect against some

00:14:19.978 attack will prevent some beneficial monitoring or

00:14:22.742 service.

00:14:23.887 There are no easy answers here.

00:14:26.356 It’s easy to argue that we must

00:14:29.120 encrypt all the things for privacy,

00:14:31.490 missing that this causes real problems.

00:14:33.859 Equally, it’s easy to argue that law

00:14:36.623 enforcement should have exceptional access to help

00:14:39.387 prevent terrorism and child abuse, for example,

00:14:42.152 missing that there are very real risks

00:14:44.916 that this will cause other serious problems.

00:14:47.680 We need more dialogue between engineers,

00:14:50.149 protocol designers, network operators, policy makers,

00:14:52.519 and law enforcement, to better understand the

00:14:55.283 constraints and concerns.

00:14:56.468 The “Keys under Doormats” paper, linked from

00:14:59.332 the slide, talks about the issue in

00:15:02.096 more detail, and I encourage you to

00:15:04.860 read it.

 

00:15:06.000 That wraps up the discussion of why

00:15:09.355 secure communications is needed.

00:15:11.272 Network traffic is frequently monitored, by governments,

00:15:14.728 businesses, network operators, and malicious users.

00:15:17.603 Some of this monitoring is beneficial,

00:15:20.479 some is less so.

00:15:22.397 In the following parts I’ll talk about

00:15:25.852 the technologies we can use to provide

00:15:29.207 privacy, to protect message integrity, and to

00:15:32.562 prevent protocol ossification.

Part 2: Principles of Secure Communication

The 2nd part of the lecture reviews the principles of secure communication. It describes the concepts behind symmetric, public-key, and hybrid cryptography. It outlines techniques for message integrity protection and authentication including cryptographic hash functions and digital signatures. And it reviews the need for a public key infrastructure.

00:00:00.000 In this part, I want to talk

00:00:02.186 about some of the principles of secure

00:00:04.372 communication. I’ll talk about how we go

00:00:06.557 about ensuring confidentiality of messages as they

00:00:08.743 traverse the network.

 

00:00:09.780 About how we authenticate messages to ensure

00:00:12.486 that they're not modified in transit,

00:00:14.805 and about how we can go about

00:00:17.511 validating the identity of the participants in

00:00:20.217 a communication.

 

00:00:21.090 So what are the goals of secure

00:00:23.916 communication?

 

00:00:24.420 Well, we're trying to deliver a message

00:00:27.080 across the internet from a sender to

00:00:29.740 a receiver.

 

00:00:30.600 In the process we want to avoid

00:00:32.821 eavesdropping on the message – we need

00:00:35.042 to encrypt it in order to provide

00:00:37.264 confidentiality, to make sure no one other

00:00:39.485 than the intended receiver can have access

00:00:41.706 to the content of the message.

 

00:00:43.710 We want to avoid tampering with the

00:00:45.652 message – we need to authenticate the

00:00:47.594 message to ensure that it's not modified

00:00:49.536 in transit by any of the devices

00:00:51.478 which are which are involved in the

00:00:53.420 delivery of that message.

 

00:00:54.630 And we want to avoid spoofing –

00:00:57.220 we want to somehow validate the identity

00:00:59.810 of the sender, so that the receiver

00:01:02.400 knows, and can be sure of who

00:01:04.990 the message came from.

 

00:01:06.570 So how do we go about providing

00:01:09.580 confidentiality?

 

00:01:10.110 Well unfortunately data traversing the network can

00:01:12.116 be read by any of the devices

00:01:14.121 on the path between the sender and

00:01:16.127 the receiver.

 

00:01:16.800 It's possible to eavesdrop on packets as

00:01:18.893 they traverse the links that comprise the

00:01:20.986 network. And it's also possible to configure

00:01:23.080 the switches or routers to snoop on

00:01:25.173 the data as they're forwarding it between

00:01:27.266 the different links in the network.

 

00:01:29.160 The network operator can always do this.

00:01:31.359 They own the network; they can configure

00:01:33.558 the devices to save a copy of

00:01:35.757 the data if they choose to do

00:01:37.956 so.

 

00:01:38.370 If the network's been compromised, maybe so

00:01:41.081 can others. If an attacker can break

00:01:43.792 into the routers, for example, there's nothing

00:01:46.503 stopping them saving the data, redirecting copies

00:01:49.214 of data traversing the network to some

00:01:51.925 other location.

 

00:01:52.800 If the data can always be read,

00:01:55.367 how do we provide confidentiality?

 

00:01:57.300 Well, we use encryption to make sure

00:01:59.399 that the data is useless if it's

00:02:01.497 intercepted or copied. We can't stop an

00:02:03.596 attacker, or the network operator, from reading

00:02:05.694 our data. But we can make sure

00:02:07.793 that they can't make sense of it

00:02:09.891 if they do read it.

 

00:02:11.490 There are two basic approaches to providing

00:02:14.500 encryption.

 

00:02:15.030 The first is called symmetric cryptography.

00:02:17.834 Algorithms that such as the Advanced Encryption

00:02:21.105 Standard, AES.

 

00:02:22.140 The other approach is what's known as

00:02:25.022 public key cryptography. Algorithm such as the

00:02:27.904 Diffie-Hellman algorithm, the RSA algorithm, and elliptic

00:02:30.787 curve algorithms.

 

00:02:31.710 They have quite different properties and are

00:02:34.210 used in different situations. I’ll talk about

00:02:36.709 the details and the differences between them

00:02:39.209 in a minute.

 

00:02:40.380 Both of them are based on some

00:02:42.652 fairly complex mathematics. I'm not going to

00:02:44.925 attempt to describe how that works.

00:02:46.872 What's important is not the details of

00:02:49.145 the maths. But what are their properties,

00:02:51.417 what behaviours do they provide, and how

00:02:53.689 do they help us secure data as

00:02:55.962 it traverses the network?

 

00:02:57.360 So we’ll start with the idea of

00:03:00.339 symmetric cryptography.

 

00:03:01.290 The idea of symmetric encryption is that

00:03:03.557 it can convert plain text into cipher

00:03:05.823 text with the aid of a key.

 

00:03:08.190 If you have, for example, the plain

00:03:10.433 text as we see on the top-right

00:03:12.675 of the slide, and we pass it

00:03:14.918 through the encryption algorithm, in this case,

00:03:17.160 the AES Advanced Encryption Algorithm, with the

00:03:19.403 aid of an encryption key, we get

00:03:21.646 a blob of encrypted text as we

00:03:23.888 see it in the middle.

 

00:03:25.590 If we pass that encrypted text through

00:03:28.687 the inverse algorithm, the decryption algorithm,

00:03:31.341 using the same key, then we get

00:03:34.438 the original text back out.

 

00:03:36.750 The point is that a single secret

00:03:39.205 key controls both the encryption and the

00:03:41.659 decryption process. The key used to encrypt

00:03:44.114 is the same as the key used

00:03:46.569 to decrypt.

 

00:03:47.370 Now, provided the key is kept secret.

00:03:49.895 And it's known only to the sender

00:03:52.420 and receiver. This can be very secure,

00:03:54.946 and it can be very fast.

 

00:03:57.210 Symmetric algorithms such as AES can encrypt

00:04:00.443 and decrypt many gigabits per second.

00:04:03.214 This makes them very suitable for Internet

00:04:06.448 communications because they don't slow down the

00:04:09.681 communications, while still providing security.

 

00:04:12.090 There are a wide range of different

00:04:15.323 symmetric encryption algorithms, probably the most widely

00:04:18.555 used is the US Advanced Encryption Standard,

00:04:21.788 AES.

 

00:04:22.350 The AES algorithm was developed as part

00:04:24.935 of the output of an open competition,

00:04:27.521 run by the US National Institute of

00:04:30.106 Standards, and it's actually a Dutch algorithm

00:04:32.692 known as Rijndael.

 

00:04:33.900 Importantly, the AES algorithm, the Rijndael algorithm,

00:04:36.714 is public and the security of the

00:04:39.529 algorithm depends only on keeping the key

00:04:42.343 secret, not on keeping the algorithm itself

00:04:45.158 secret.

 

00:04:45.660 The link on the slide is a

00:04:47.967 pointer to the specification for the algorithm,

00:04:50.275 and there’s a large amount of open

00:04:52.582 source code which implements it.

 

00:04:54.330 The problem of symmetric cryptography is that

00:04:56.912 you need to keep the key secret.

00:04:59.493 If anyone other than the sender and

00:05:02.075 the receiver know the key, then the

00:05:04.656 security of the encryption fails.

 

00:05:06.600 The question then, is how do you

00:05:09.102 security distribute the key? If you want

00:05:11.604 to exchange message a secure message with

00:05:14.105 someone I know well, then this is

00:05:16.607 straightforward. I can meet them in person,

00:05:19.109 give them the key, and ensure that

00:05:21.611 no one else can eavesdrop on that

00:05:24.113 communication.

 

00:05:24.570 The problem comes when I'm trying to

00:05:26.701 communicate securely with someone where I can't

00:05:28.832 meet them in person.

 

00:05:30.150 How do I securely get a key

00:05:32.400 from an Internet shopping site, for example?

00:05:34.651 The only means of communication. I have

00:05:36.901 is over the Internet. And if I

00:05:39.151 send the key over the Internet,

00:05:41.080 someone can eavesdrop on the key,

00:05:43.009 and that gives them the ability to

00:05:45.260 decrypt our communications and breaks the security.

 

00:05:47.610 The solution to this is an approach

00:05:50.457 known as public key cryptography.

 

00:05:52.590 public key cryptography, like symmetric cryptography,

00:05:54.841 is used to convert a plain text

00:05:57.466 message into an encrypted form. The difference,

00:06:00.092 though, is that there are two different

00:06:02.718 keys, and the key used to encrypt

00:06:05.344 the message, and the key to decrypt

00:06:07.970 the message are different

 

00:06:09.570 The keys come in pairs. The two

00:06:11.647 halves of the pair are known as

00:06:13.723 the public key and the private key.

 

00:06:15.900 Importantly, a message which is encrypted using

00:06:18.456 one of those keys can only be

00:06:21.012 decrypted using the other key. If the

00:06:23.568 message is encrypted with the public key,

00:06:26.124 for example, then only the private key

00:06:28.679 can decrypt that message.

 

00:06:30.240 As you might expect from the names.

00:06:32.410 The idea is that you keep the

00:06:34.580 private key from the key pair secret,

00:06:36.750 and you make the public key as

00:06:38.920 public as is possible.

 

00:06:40.260 You publish it in the phone book,

00:06:42.207 you put it on your webpage,

00:06:43.876 you write it on your business card,

00:06:45.822 and you make sure everybody knows that

00:06:47.769 this is your public key.

 

00:06:49.260 In order to send you a message,

00:06:51.556 someone looks up your public key and

00:06:53.852 uses that to encrypt the message.

 

00:06:55.920 Once the message has been encrypted using

00:06:58.331 a particular public key, the only thing

00:07:00.741 which can decrypt it is the corresponding

00:07:03.152 private key. And since the private key

00:07:05.563 has been kept private, you're the only

00:07:07.974 one who can receive the message.

 

00:07:10.140 This solves the key distribution problem.

00:07:12.511 Provided you can look up the appropriate

00:07:15.278 public key for the receiver in a

00:07:18.045 directory,

 

00:07:18.540 and you can trust that that receiver

00:07:20.632 has kept their private key secret,

00:07:22.425 then you use their public key to

00:07:24.517 encrypt the message, and you know that

00:07:26.609 they're the only one who can decrypt

00:07:28.701 it.

 

00:07:29.100 This allows Internet shopping sites, and the

00:07:31.182 like, to work. If I wish to

00:07:33.264 buy something from Amazon, I look up

00:07:35.345 the key for Amazon in a directory,

00:07:37.427 use that to encrypt the message I'm

00:07:39.509 sending to Amazon, and I know that

00:07:41.591 they're the only ones that can decrypt

00:07:43.673 it.

 

00:07:44.070 The problem with public key cryptography is

00:07:46.969 very, very, slow. The public key algorithms

00:07:49.867 such as the Diffie-Hellman algorithm, the RSA

00:07:52.766 algorithm,

 

00:07:53.280 and the elliptic curve algorithms, work millions

00:07:56.304 of times slower than symmetric encryption algorithms.

00:07:59.329 The result is that they’re too slow

00:08:02.353 to use for any realistic amount of

00:08:05.378 communication. The performance just isn't there.

 

00:08:08.070 Accordingly, modern communications use what's known as

00:08:11.437 hybrid cryptography, where they use a combination

00:08:14.803 of both public key and symmetric cryptography.

 

00:08:18.270 This provides both security and speed.

 

00:08:21.870 The way this works is that the

00:08:24.673 sender and receiver use public key cryptography,

00:08:27.476 which is very slow, to exchange a

00:08:30.278 small amount of information.

 

00:08:31.980 That information is then used as the

00:08:34.619 key for the symmetric encryption algorithm,

00:08:36.882 which is very fast.

 

00:08:38.490 In detail, the sender chooses a random

00:08:41.117 value, that we’ll call Ks, which will

00:08:43.743 be used as the key for the

00:08:46.370 symmetric encryption.

 

00:08:47.220 The sender then looks up the receiver’s

00:08:49.918 public key, Kpub, uses it to encrypt

00:08:52.616 Ks and sends the result to the

00:08:55.315 receiver.

 

00:08:55.800 The receiver uses its corresponding private key,

00:08:59.127 Kpriv, to decrypt the message and retrieve

00:09:02.455 Ks.

 

00:09:03.030 This securely transfers Ks, the key for

00:09:06.658 the symmetric encryption algorithm, from the sender

00:09:10.285 to the receiver.

 

00:09:11.940 Doing this using public key encryption is

00:09:14.450 very slow, but the key for the

00:09:16.960 symmetric encryption, Ks, is very small,

00:09:19.111 so the fact it's very slow doesn't

00:09:21.621 matter.

 

00:09:22.080 The sender, then uses that key,

00:09:24.867 Ks, to encrypt future messages using symmetric

00:09:28.119 cryptography, for example, using the AES algorithm.

 

00:09:31.470 The receiver also has Ks, which it

00:09:34.087 exchanged using the public key encryption,

00:09:36.330 and can use that to decrypt the

00:09:38.946 messages.

 

00:09:39.420 Symmetric cryptography is very fast, so the

00:08:01.176 performance of the communication, once it's got

00:06:22.932 started, is very quick, but it requires

00:04:44.688 the key to be exchanged securely.

00:03:20.478 The public key algorithm, which is slow,

00:01:42.234 is used to securely exchange the key.

 

00:00:04.090 The result is something which achieves both

00:03:46.793 confidentiality, and solves the key distribution problem,

00:07:29.496 and also achieves good performance.

 

00:10:08.670 Encryption gives you confidentiality of data and

00:10:10.843 makes sure that no one can eavesdrop

00:10:13.016 on the messages being sent from the

00:10:15.188 sender to the receiver.

 

00:10:16.530 We also, though, need to verify the

00:10:18.857 identity of the sender, and make sure

00:10:21.183 that messages haven't been modified in transit.

 

00:10:23.610 In order to do this, we generate

00:10:26.035 a digital signature to authenticate our messages.

00:10:28.461 And the receiver can then validate that

00:10:30.886 signature, check the signature, to make sure

00:10:33.311 they came from the expected sender.

 

00:10:35.490 The digital signature relies on a combination

00:10:39.410 of public key cryptography, and a cryptographic

00:10:43.330 hash algorithm.

 

00:10:44.550 So first of all, what is a

00:10:47.132 cryptographic hash?

 

00:10:47.970 A cryptographic hash function is a function

00:10:50.748 that takes some arbitrary length input and

00:10:53.525 produces a fixed length output hash that

00:10:56.303 somehow represents that input.

 

00:10:57.990 For example, at the top of the

00:11:00.463 slide, we see some input text going

00:11:02.937 through a hash algorithm, known as SHA256,

00:11:05.410 that produces the fixed length output block

00:11:07.883 you see on the right.

 

00:11:09.750 A cryptographic hash algorithm has four fundamental

00:11:12.532 properties. The first is that every input

00:11:15.314 will generate a different output, and the

00:11:18.096 slightest change to the input will change

00:11:20.878 the output value.

 

00:11:22.170 The second is that it should be

00:11:24.454 infeasible to give to find two inputs

00:11:26.738 that gives the same output.

 

00:11:28.470 The third is that calculating the hash

00:11:30.787 itself should be fast, and going from

00:11:33.103 input to output should happen very quickly.

 

00:11:35.520 And the fourth, and perhaps most important,

00:11:37.809 is that reversing a hash should be

00:11:40.098 infeasible. If you're only given the output,

00:11:42.386 there should be no way of finding

00:11:44.675 out what the inputs was.

 

00:11:46.410 A cryptographic hash therefor acts as a

00:11:49.207 unique fingerprint for the input data.

00:11:51.605 It provides a short output, that uniquely

00:11:54.402 identifies a given message.

 

00:11:56.100 There are many different cryptographic hash algorithms.

00:11:59.797 The current recommendation is the SHA256 over

00:12:03.493 specified by the IETF in RFC 6234.

 

00:12:07.290 There are a number of older algorithms,

00:12:10.083 such MD5 and SHA1, which you may

00:12:12.876 hear about, but these all have known

00:12:15.668 security flaws and are not recommended for

00:12:18.461 use.

 

00:12:18.960 So how can we use a cryptographic

00:12:21.325 hash to help build a digital signature?

 

00:12:23.790 Well, in order to do that,

00:12:25.924 you take the message you wish to

00:12:28.413 send, and you calculate a cryptographic hash

00:12:30.903 of that message.

 

00:12:32.070 The sender that encrypts that hash with

00:12:34.294 their private key. Now the private key

00:12:36.517 is known only to the sender,

00:12:38.423 so they're the only one who can

00:12:40.647 encrypt that message.

 

00:12:41.700 But the thing which would decrypt it

00:12:44.127 is the sender’s public key, which is

00:12:46.553 available to everybody. Encrypting the hash with

00:12:48.980 the sender’s private key doesn't provide any

00:12:51.407 confidentiality, because anyone can decrypt the message

00:12:53.833 using the public key.

 

00:12:55.320 What it does do though, provided the

00:12:57.637 sender can be trusted to keep its

00:12:59.955 private key private, is demonstrate that the

00:13:02.272 sender must have encrypted the hash.

00:13:04.259 Since the hash is a fingerprint of

00:13:06.576 the message, this means that the sender

00:13:08.894 must have generated the original message.

 

00:13:10.980 The sender then attaches the encrypted hash

00:13:14.035 to the message, forming the digital signature.

 

00:13:17.190 The message, and its digital signature,

00:13:19.834 are then encrypted and sent to the

00:13:22.918 receiver using hybrid encryption.

 

00:13:24.780 When the message arrives at the receiver,

00:13:27.456 the receiver can verify the signature.

 

00:13:29.850 To do this, it first decrypt that

00:13:32.560 the message and its digital signature.

00:13:34.884 The receiver then takes the message itself,

00:13:37.594 and calculates its cryptographic hash.

 

00:13:39.630 Having done that, it takes the digital

00:13:42.317 signature, looks up the sender’s public key,

00:13:45.004 and uses that to decrypt the digital

00:13:47.691 signature to retrieve the original

 

00:13:49.710 cryptographic hash that was in the message.

00:13:52.249 It compares the hash, which has sent

00:13:54.787 in the message as part of the

00:13:57.326 digital signature, with the cryptographic hash it

00:13:59.865 just calculated.

 

00:14:00.690 If the two match, then it knows

00:14:02.982 the messages is authentic and has been

00:14:05.274 unmodified, provided is trusts the sender to

00:14:07.566 have kept its private key private.

 

00:14:09.630 If the hash of the message it

00:14:11.892 calculated, and the hash that was sent

00:14:14.154 in the digital signature, don't match then

00:14:16.416 it knows that somehow the message has

00:14:18.678 been modified in transit.

 

00:14:20.070 Public Key Encryption is therefore one of

00:14:22.193 the fundamental building blocks of a secure

00:14:24.317 network.

 

00:14:24.720 It allows us to send a message

00:14:26.909 to a recipient securely, even if we've

00:14:29.098 not met that recipient, and be sure

00:14:31.288 that they're the only one who’ll be

00:14:33.477 able to decrypt that message. And it

00:14:35.666 allows us to use digital signatures to

00:14:37.855 verify that messages have not been modified

00:14:40.045 in transit.

 

00:14:40.770 The security of public key encryption,

00:14:43.157 though, depends on knowing which public key

00:14:45.941 corresponds to a particular receiver.

 

00:14:48.030 There are three ways you can know

00:14:50.305 this. The first is that the receiver

00:14:52.580 gives you their key in person.

 

00:14:54.630 The second is that the receiver sent

00:14:56.972 you their key, but the message in

00:14:59.314 which they send it is authenticated by

00:15:01.656 someone you trust.

 

00:15:02.760 That is, there’s a digital signature in

00:15:05.270 the message, signed by someone who's key

00:15:07.781 already have, that authenticates that this message

00:15:10.291 is from who it claims to be

00:15:12.801 from.

 

00:15:13.260 The third is that someone you trust

00:15:16.159 gives you the receivers key.

 

00:15:18.330 In the Internet, the role of someone

00:15:20.809 you trust is often played by an

00:15:23.287 organisation known as a certificate authority,

00:15:25.411 as part of a public key infrastructure.

 

00:15:27.990 The role of a certificate authority is

00:15:30.723 to validate the identity of potential senders.

00:15:33.457 The certificate authority checks the identity of

00:15:36.190 a potential sender, and then adds a

00:15:38.924 digital signature to the sender’s public key

00:15:41.657 to indicate that it's done so.

 

00:15:44.100 If a receiver trusts the public key

00:15:47.295 infrastructure, trusts the certificate authority, then it

00:15:50.490 can verify that digital signature, added by

00:15:53.685 the certificate authority, to confirm the identity

00:15:56.881 of the sender.

 

00:15:58.350 These mechanisms, symmetric and public key encryption,

00:16:01.771 and digital signatures, allow us to provide

00:16:05.192 confidentiality for communication over the Internet that

00:16:08.613 performs well

 

00:16:09.690 and is secure. They allow us to

00:16:11.790 authenticate messages, and demonstrate that they've not

00:16:13.890 been modified in transit. And they allow

00:16:15.990 us to validate the identity of senders

00:16:18.090 of those messages.

Part 3: Transport Layer Security (TLS) v1.3

The 3rd part of the lecture describes the operation of the Transport Layer Security Protocol (TLS) v1.3; one of the key security protocols used in the Internet.

00:00:00.000 In previous parts of this lecture I

00:00:02.640 spoke about network security in general terms.

00:00:05.281 In part one, I discussed why security

00:00:07.921 is needed in order to protect Internet

00:00:10.562 communications,

 

00:00:11.039 and in part two, I spoke about

00:00:13.724 how security is provided in outline.

00:00:16.026 I spoke about the different types of

00:00:18.712 encryption, public key and symmetric,

 

00:00:20.730 the use of hybrid encryption, in order

00:00:24.026 to improve performance while still maintaining security,

00:00:27.322 and the ideas of digital signatures and

00:00:30.618 public key infrastructure.

 

00:00:32.130 In this third part of the lecture,

00:00:34.546 I want to move on to talk

00:00:36.962 about Internet security in specific terms.

00:00:39.033 I want to talk about the Transport

00:00:41.449 Layer Security protocol, TLS version 1.3

 

00:00:43.620 I’ll begin by introducing what is TLS,

00:00:45.935 talking about conceptually what role it performs

00:00:48.250 in the network stack. And I'll talk

00:00:50.565 through some of the details of TLS.

 

00:00:52.980 I'll talk about the TLS handshake protocol,

00:00:56.118 that's used to establish TLS connections.

00:00:58.807 The record protocol, that's used to exchange

00:01:01.945 data. The 0-RTT extension, that reduces connection

00:01:05.083 setup times. And finally, I'll talk about

00:01:08.221 some of the limitations of TLS.

 

00:01:11.010 As we saw in some of the

00:01:13.825 earlier lectures, TCP connections are not secure

 

00:01:16.740 Neither the TCP headers, nor the IP

00:01:19.519 headers, nor the data they transfer are

00:01:22.298 encrypted or authenticated in any way.

 

00:01:24.780 Data sent in a TCP connection is

00:01:28.194 not confidential. It can be observed by

00:01:31.608 governments, businesses, network operators, criminals, or malicious

00:01:35.022 users.

 

00:01:35.610 Similarly, the data is not authenticated.

00:01:37.663 Anyone who's able to access the network

00:01:40.058 connections, or the routers over which the

00:01:42.453 data flows, is able to modify that

00:01:44.849 data. And the sender and the receiver

00:01:47.244 will not be able to tell that

00:01:49.639 such modifications have been performed.

 

00:01:51.450 In order to provide security for data

00:01:54.157 going across a TCP connection, we need

00:01:56.863 to run some sort of additional security

00:01:59.570 protocol within that TCP connection to protect

00:02:02.277 the data.

 

00:02:03.150 The way this is typically done in

00:02:05.357 the Internet, is using a protocol called

00:02:07.564 the Transport Layer Security protocol.

 

00:02:09.240 The latest version of this is TLS

00:02:12.150 1.3 and it's used to encrypt and

00:02:15.059 authenticate data that is carried within a

00:02:17.969 TCP connection.

 

00:02:18.900 The official specification for TLS 1.3 is

00:02:21.907 RFC 8446, which was published by the

00:02:24.913 IETF in the last couple of years.

 

00:02:28.020 The TLS specification is not a simple

00:02:30.932 document to read.

 

00:02:32.280 In part, this is because it's solving

00:02:34.863 a difficult problem. Providing security over the

00:02:37.447 top of an insecure connection, a TCP

00:02:40.030 connection, is a complex challenge, and TLS

00:02:42.613 has to define the number of complex

00:02:45.197 mechanisms in order to provide that security.

 

00:02:47.880 In other part, the complexity comes because

00:02:50.604 TLS is an old protocol.

 

00:02:52.650 The latest versions of TLS have to

00:02:55.520 be backwards compatible, not only with previous

00:02:58.390 versions of TLS as specified, but with

00:03:01.260 previous implementation problems, and bugs in the

00:03:04.130 TLS specification and in its implementations

 

00:03:06.690 The protocol designers have done a good

00:03:09.775 job, though. TLS version 1.3 is smaller,

00:03:12.860 faster, and simpler than previous versions of

00:03:15.946 TLS, and it's also more secure.

 

00:03:18.690 The slide lists four blog posts which

00:03:21.347 perfect more information about TLS. The first

00:03:24.003 one is an introduction to TLS 1.3

00:03:26.660 from the IETF. This was written by

00:03:29.316 the TLS working group chairs, and introduces

00:03:31.973 the new features in the protocol.

 

00:03:34.350 The second, from CloudFlare, is a detailed

00:03:36.997 look at what's new in TLS 1.3,

00:03:39.643 as compared to previous versions of TLS.

 

00:03:42.390 It talks about some of the advantages

00:03:44.926 of TLS 1.3, and how it improves

00:03:47.462 security, and reduces the connection set up

00:03:49.998 times.

 

00:03:50.460 The third of these, from David Wong,

00:03:52.887 attempts to redraw the TLS specification in

00:03:55.314 a way that makes it easier to

00:03:57.741 read. This is a copy of RFC

00:04:00.168 8446, the TLS specification, with the diagrams

00:04:02.595 redrawn in an easier to read way,

00:04:05.023 and with explanatory videos and comments added

00:04:07.450 to make it easier to follow.

 

00:04:09.630 The final post is the most detailed.

00:04:12.566 It's an annotated packet capture showing the

00:04:15.503 details of a TLS connection.

 

00:04:17.700 This walks through the TLS connection establishment

00:04:20.421 handshake, byte by byte, labelling each byte

00:04:23.141 with reference to the specification to explain

00:04:25.862 exactly what it means, and how the

00:04:28.583 handshake proceeds.

 

00:04:29.460 I encourage you to review these four

00:04:32.045 blog posts. They give a nice complement

00:04:34.631 to the material I'll talk about in

00:04:37.216 the rest of this lecture, introducing how

00:04:39.802 TLS 1.3 works.

 

00:04:41.010 So what's the goal of TLS 1.3?

 

00:04:44.250 Well, given an existing connection, that's capable

00:04:47.405 of delivering data reliably and in the

00:04:50.560 order it was sent, but is insecure,

00:04:53.716 TLS 1.3 aims to add security.

 

00:04:56.520 That is given a TCP connection,

00:04:59.577 it seems to add authentication, confidentiality,

00:05:02.635 and integrity protection to the data sent

00:05:06.201 over that connection.

 

00:05:07.830 In terms of authentication, it uses public

00:05:10.485 key cryptography, and a public key infrastructure,

00:05:13.140 in order to verify the identity of

00:05:15.796 the server to which the connection is

00:05:18.451 made.

 

00:05:18.930 That is, the client can always verify

00:05:21.516 that it's talking to the desired server.

00:05:24.102 In addition, it provides optional authentication for

00:05:26.688 the client, to allow the server to

00:05:29.274 verify the identity of the client.

 

00:05:31.590 Once the connection has been established,

00:05:34.233 and verified to be correct, TLS provides

00:05:37.317 confidentiality for data sent across that connection.

 

00:05:40.500 It uses hybrid encryption schemes to provide

00:05:43.251 good performance, while still providing a strong

00:05:46.001 amount of security.

 

00:05:47.280 Finally, TLS authenticates data sent across the

00:05:50.490 connection, to provide integrity protection. It's not

00:05:53.699 possible for an attacker to modify data

00:05:56.909 sent across a TLS connection without that

00:06:00.119 modification being detectable by the endpoints.

 

00:06:02.970 How does TLS 1.3 work?

 

00:06:05.790 Well, first of all, a TCP connection

00:06:08.560 must be established. TLS is not a

00:06:11.329 transport protocol itself, and it relies on

00:06:14.099 an underlying TCP connection in order to

00:06:16.869 exchange data.

 

00:06:17.760 Once the TCP connection has been established,

00:06:21.167 TLS runs within that connection.

 

00:06:23.700 There are two parts to a TLS

00:06:26.467 connection. It begins with a handshake protocol,

00:06:29.233 and then proceeds with a record protocol.

 

00:06:32.100 The goal of the handshake protocol,

00:06:34.186 at the beginning of the connection,

00:06:36.271 is to authenticate the endpoints and agree

00:06:38.704 on what encryption keys to use.

 

00:06:40.890 Once this is completed, TLS switches to

00:06:43.827 running the record protocol, which lets endpoints

00:06:46.764 exchange authenticated and encrypted blocks of data

00:06:49.701 over the connection.

 

00:06:51.060 TLS turns the TCP byte stream into

00:06:54.329 a series of records. It provides framing,

00:06:57.598 delivers data block by block, each block

00:07:00.867 being encrypted and authenticated to ensure that

00:07:04.136 the data being sent in that block

00:07:07.405 is confidential, and arrives unmodified.

 

00:07:09.840 A secure connection over the Internet starts

00:07:12.595 up establishing a TCP connection as normal.

 

00:07:15.450 The client connects to the server,

00:07:17.685 sending a SYN packet, along with its

00:07:20.293 initial sequence number.

 

00:07:21.510 The server response with the SYN-ACK,

00:07:23.859 acknowledging the client’s initial sequence number,

00:07:26.208 and providing the server’s initial sequence number.

00:07:28.948 And then the client responsive with an

00:07:31.688 ACK packet, acknowledging that packet from the

00:07:34.429 server.

 

00:07:34.920 This sets up a TCP connection.

 

00:07:37.620 Immediately following that, the TLS handshake starts,

00:07:41.072 running within the TCP connection itself.

 

00:07:44.130 The TLS client sends a TLS ClientHello

00:07:46.951 message to a server immediately following the

00:07:49.772 final ACK of the TCP handshake.

 

00:07:52.290 The server responds to that with a

00:07:54.714 TLS ServerHello message, and then the client

00:07:57.137 in return

 

00:07:57.930 responds with a TLS Finished message.

00:08:00.423 This concludes the handshake, and carries the

00:08:03.331 first block of secure data. Following this,

00:08:06.240 the client and the server switch to

00:08:09.148 running the TLS record protocol over the

00:08:12.056 TCP connection, and exchange further secure data

00:08:14.965 blocks.

 

00:08:15.480 As can be seen the TLS handshake

00:08:18.008 adds an additional round trip time to

00:08:20.536 the connection establishment.

 

00:08:21.720 At the start of the connection,

00:08:23.517 there's an initial round trip time while

00:08:25.613 TCP connection is set up.

 

00:08:27.210 And then this is followed by an

00:08:29.517 additional round trip, while the TLS connection

00:08:31.825 and the security parameters are negotiated,

00:08:33.802 before the data can be set.

 

00:08:35.880 There's a minimum of two round trip

00:08:38.629 times from the start of the TCP

00:08:41.377 connection to the conclusion of the TLS

00:08:44.126 handshake and the first secure data segment

00:08:46.875 being sent.

 

00:08:47.760 The first part of the TLS handshake

00:08:50.255 is the ClientHello message. This is sent

00:08:52.750 from the client to the server,

00:08:54.889 and begins the negotiation of the security

00:08:57.384 parameters.

 

00:08:57.840 The ClientHello message does three things.

00:09:00.199 It's indicates the version TLS that is

00:09:02.950 to be used. It indicates the cryptographic

00:09:05.702 algorithms that the client supports, and provides

00:09:08.454 its initial keying material. And it indicates

00:09:11.206 the name of the server to which

00:09:13.958 the client is connecting.

 

00:09:15.630 You may wonder why the ClientHello message

00:09:17.961 needs to indicate server name, given that

00:09:20.291 it's running over a TCP connection that's

00:09:22.622 just been established to that server.

 

00:09:24.720 The reason for this, is that TLS

00:09:26.750 is often used with web hosting,

00:09:28.490 and it's common for web servers to

00:09:30.520 host more than one website,

 

00:09:32.070 so the server name provided in the

00:09:34.876 TLS ClientHello indicates which of the sites,

00:09:37.682 which are accessible over that TCP connection,

00:09:40.488 the TLS message is trying to establish

00:09:43.294 a connection, establish a secure connection,

00:09:45.699 to.

 

00:09:46.200 The ClientHello message also indicates which version

00:09:48.797 of TLS is to be used.

00:09:51.022 What you would expect to happen here,

00:09:53.619 is that it would indicate that it

00:09:56.215 wishes to use TLS 1.3.

 

00:09:58.170 What actually happens, though, is that the

00:10:01.053 ClientHello message includes a version number indicating

00:10:03.936 that it wants to use TLS version

00:10:06.819 1.2, the previous version of TLS.

 

00:10:09.390 The ClientHello message includes an optional set

00:10:12.382 of extension headers, and one of those

00:10:15.374 extension headers includes an extension which says

00:10:18.366 “actually I’m really TLS version 1.3”.

 

00:10:21.030 The reason the version negotiation happens in

00:10:23.366 such a weird way, specifying an old

00:10:25.701 version of TLS in the version field,

00:10:28.037 and using an extension to indicate the

00:10:30.373 real version,

 

00:10:31.140 Is because there are too many middle

00:10:33.567 boxes, too many devices which try to

00:10:35.995 inspect TLS traffic in the network,

00:10:38.076 and which fail if the version number

00:10:40.503 changes.

 

00:10:40.950 The protocol has become ossified. We waited

00:10:43.985 too long between versions of TLS.

00:10:46.586 Too many devices were deployed, to many

00:10:49.621 endpoints were deployed, which only understood version

00:10:52.656 1.2

 

00:10:53.190 and which didn't correctly support the version

00:10:55.741 negotiation. And then, when it came to

00:10:58.292 deploying a new version, and people tried

00:11:00.843 with early versions of TLS to just

00:11:03.394 change the version number to 1.3,

00:11:05.581 is was found that those new versions

00:11:08.132 didn't support the change.

 

00:11:09.690 The result was that connections that indicated

00:11:12.206 TLS version 1.3 in the header would

00:11:14.722 tend to fail,

 

00:11:15.900 whereas those that pretended to be TLS

00:11:18.591 version 1.2, using an extension header to

00:11:21.282 upgrade the version number, would work through

00:11:23.973 those middleboxes, and the connection could succeed

00:11:26.664 and proceed with the new version.

 

00:11:29.070 The ClientHello message is the first part

00:11:32.321 of the connection setup handshake. It doesn't

00:11:35.572 carry any new data.

 

00:11:37.530 Following the ClientHello, the server responds with

00:11:41.345 a ServerHello message.

 

00:11:43.080 The ServerHello message also indicates the version

00:11:45.864 of TLS which is to be used

00:11:48.649 and, like the ClientHello, it indicates that

00:11:51.433 the version is actually TLS version 1.2

00:11:54.218 and includes an extension header to say

00:11:57.002 that it’s really a TLS 1.3 connection

00:11:59.787 that's being established

 

00:12:01.080 In addition to the version negotiation.

00:12:03.437 The TLS ServerHello includes the cryptographic algorithms

00:12:06.187 selected by the server, which are a

00:12:08.937 subset of the set suggested by the

00:12:11.687 client.

 

00:12:12.180 That is, the client suggests the cryptographic

00:12:14.744 algorithms which it supports, and the server

00:12:17.307 looks at those, finds the subset of

00:12:19.871 them which are acceptable to it,

00:12:22.068 picks one of them, and includes that

00:12:24.631 in its response.

 

00:12:25.830 The ServerHello message also includes the server’s

00:12:28.050 public key, and a digital signature which

00:12:30.269 can be used to verify the identity

00:12:32.489 of the server.

 

00:12:33.540 Like the ClientHello, it doesn't include any

00:12:37.679 data.

 

00:12:38.370 Finally, the TLS handshake concludes with a

00:12:40.923 Finished message, which flows from the client

00:12:43.477 to the server. The TLS Finished message

00:12:46.030 includes the clients public key and optionally,

00:12:48.583 it includes a certificate which is used

00:12:51.137 to authenticate the client to the server.

 

00:12:53.790 The TLS Finished message concludes the connection

00:12:57.539 setup handshake.

 

00:12:58.710 In addition to the connection setup,

00:13:00.904 it may therefore include the first part

00:13:03.463 of application data that is sent from

00:13:06.022 the client to the server.

 

00:13:07.950 TLS uses the ephemeral elliptic curve Diffie-Hellman

00:13:11.267 key exchange algorithm in order to derive

00:13:14.583 the keys used for the symmetric encryption.

 

00:13:18.000 The client and the server exchange that

00:13:20.314 public keys, as part of the connection

00:13:22.628 setup handshake, and they then combine those

00:13:24.942 two public keys to derive the key

00:13:27.256 that's used for the symmetric cryptography.

 

00:13:29.340 The maths of how this works is

00:13:31.399 complex. I'm not going to attempt to

00:13:33.458 describe it here.

 

00:13:34.440 What's important though, is that the symmetric

00:13:36.918 key is never exchanged over the wire.

00:13:39.397 The client and the server only exchange

00:13:41.875 their public keys, and the symmetric key

00:13:44.354 is derived from those.

 

00:13:45.870 A TLS server provides a certificate that

00:13:48.617 allows the client to verify its identity

00:13:51.365 as part of the ServerHello message.

00:13:53.720 The client can optionally provide this information

00:13:56.467 along with its Finished message.

 

00:13:58.530 Result is that the client can always

00:14:01.012 verify the identity of the server,

00:14:03.140 and the server can optionally verify the

00:14:05.622 identity of the client.

 

00:14:07.140 The choice of encryption algorithm is driven

00:14:09.642 by the client, which provides the list

00:14:12.143 of the symmetric encryption algorithms that it

00:14:14.645 supports as part of its ClientHello message.

00:14:17.146 The server picks from these, and replies

00:14:19.648 in its ServerHello.

 

00:14:20.820 The usual result is that either the

00:14:24.762 Advanced Encryption Standard, AES, or the ChaCha20

00:14:28.704 symmetric encryption algorithm is chosen.

 

00:14:31.620 Once the TLS connection establishment protocol,

00:14:34.175 the handshake protocol, has completed the TLS

00:14:37.156 record protocol starts. The record protocol allows

00:14:40.138 the client and the server to exchange

00:14:43.119 records of data over the TCP connection.

 

00:14:46.200 Each record can contain up to two

00:14:49.042 to the power 14 bytes of data,

00:14:51.884 and is both encrypted and authenticated.

 

00:14:54.420 Records of data have a sequence number,

00:14:56.927 and they are delivered reliably, securely,

00:14:59.076 and in the order in which they

00:15:01.584 were sent.

 

00:15:02.400 The underlying TCP connection does not preserve

00:15:05.227 record boundaries. TLS adds framing to the

00:15:08.054 connection so that it does so,

00:15:10.478 and reading from a TLS connection will

00:15:13.305 block until a complete record of data

00:15:16.132 is received.

 

00:15:17.040 A TLS connection usually uses the same

00:15:19.881 encryption key to protect data for the

00:15:22.723 entire connection. However, in principle, it can

00:15:25.564 renegotiate encryption keys between records, if there's

00:15:28.405 a need to change the encryption key

00:15:31.246 partway through a connection.

 

00:15:32.970 The TLS record protocol allows the client

00:15:35.535 and the server to exchange records,

00:15:37.733 to send and receive data as they

00:15:40.297 see fit.

 

00:15:41.130 Once they finish doing so, they close

00:15:44.821 the connection, which closes the underlying TCP

00:15:48.513 connection.

 

00:15:49.140 TLS 1.3 usually takes one round trip

00:15:52.053 time to establish the connection after the

00:15:54.966 TCP connection set up.

 

00:15:56.730 That is, there's the TCP SYN,

00:15:59.550 SYN-ACK, ACK handshake to establish the TCP

00:16:02.840 connection, and then an additional round trip

00:16:06.130 time for the TLS ClientHello, ServerHello,

00:16:08.950 Finished exchange.

 

00:16:09.990 However, if the client and the server

00:16:12.733 have previously communicated, TLS 1.3 allows them

00:16:15.475 to reuse some of the connection setup

00:16:18.218 parameters, and re-use the same encryption key.

 

00:16:21.060 The way this works is that the

00:16:23.251 server can send an additional encryption key

00:16:25.442 as part of its ServerHello message,

 

00:16:27.420 and the client can remember that key,

00:16:29.509 and use it the next time it

00:16:31.598 connects to the server. This is known

00:16:33.686 as a pre-shared key.

 

00:16:34.980 When the client next connects to that

00:16:37.765 server, it sends its ClientHello message as

00:16:40.550 normal. However, in addition to that ClientHello

00:16:43.335 message, it can also include some data,

00:16:46.119 and that data is encrypted using the

00:16:48.904 pre-shared key.

 

00:16:49.800 The ServerHello also proceeds as normal.

00:16:52.039 But again, can contain data encrypted using

00:16:54.652 the pre-shared key, and sent in reply

00:16:57.265 to the client, to the data included

00:16:59.877 in the ClientHello message.

 

00:17:01.470 The use of the pre-shared key therefore

00:17:03.783 allows the client and the server to

00:17:06.096 exchange data along with the initial connection

00:17:08.410 setup handshake. It allows data to be

00:17:10.723 exchanged within zero RTTs of the connection

00:17:13.036 set up, as part of the first

00:17:15.349 round trip.

 

00:17:16.110 This extension is therefore known as the

00:17:20.094 0-RTT mode of TLS 1.3.

 

00:17:23.040 The 0-RTT mode is useful, because it

00:17:25.782 allows connections to start sending data much

00:17:28.524 earlier. It removes one round trip times

00:17:31.266 worth of latency. However, it has a

00:17:34.008 limitation.

 

00:17:34.500 The limitation is that, unlike the record

00:17:38.094 packets which contain a sequence number,

00:17:41.175 TLS ClientHello and ServerHello messages don't contain

00:17:44.770 a sequence number.

 

00:17:46.410 A consequence of this, is that data

00:17:48.943 sent as part of a ClientHello,

00:17:51.114 or a ServerHello, may be duplicated,

00:17:53.285 and TLS has no way of stopping

00:17:55.818 this.

 

00:17:56.280 If you're writing an application that uses

00:17:58.710 TLS in 0-RTT mode you need to

00:18:01.139 be careful, and only send what's known

00:18:03.569 as idempotent data,

 

00:18:04.710 data where it doesn't matter if that

00:18:07.310 data is delivered more than once to

00:18:09.911 the server, in the 0-RTT packets.

 

00:18:12.240 Data that is sent after the first

00:18:15.025 round trip time has concluded, as part

00:18:17.810 of the regular TLS connection, doesn't suffer

00:18:20.595 from this problem, and is only ever

00:18:23.381 delivered to the application once.

 

00:18:25.470 A TLS connection is secure, but it

00:18:28.317 has a number of limitations.

 

00:18:30.450 TLS operates within a TCP connection.

 

00:18:33.960 A consequence of this, is that the

00:18:36.674 IP addresses and the TCP port numbers

00:18:39.387 are not protected. This exposes information about

00:18:42.101 who is communicating, and what application is

00:18:44.815 being used.

 

00:18:45.690 Further, the TLS ClientHello message includes the

00:18:48.490 server name, but doesn't encrypt that.

00:18:50.890 This exposes the host name of the

00:18:53.690 server to which the connection is being

00:18:56.490 made, and may be a significant privacy

00:18:59.290 leak.

 

00:18:59.790 An extension, known as Encrypted Server Name

00:19:02.273 Indication, is under development, but this is

00:19:04.755 not finished yet, and there are some

00:19:07.238 concerns that it may be very difficult

00:19:09.721 to deploy.

 

00:19:10.530 TLS also relies on a public key

00:19:13.157 infrastructure to validate the keys, and to

00:19:15.783 verify the identity of clients and servers.

 

00:19:18.510 There are some significant concerns about the

00:19:21.759 trustworthiness this public key infrastructure.

 

00:19:24.180 The reasons for this are not that

00:19:26.894 the the cryptographic algorithms or the mechanisms

00:19:29.609 are insecure, they’re that the browsers tend

00:19:32.323 to trust a very large range of

00:19:35.038 certificate authorities, and it's not clear to

00:19:37.752 which extent all of these certificates authorities

00:19:40.467 are actually trustworthy.

 

00:19:41.730 The final limitation of TLS is that

00:19:44.692 the 0-RTT extension may deliver data more

00:19:47.654 than once.

 

00:19:48.600 0-RTT is a very useful extension,

00:19:50.911 because it allows data to be delivered

00:19:53.608 with low latency at the start of

00:19:56.305 the connection, but it runs the risk

00:19:59.002 that that data is delivered multiple times,

00:20:01.699 so must be used with care.

 

00:20:04.110 That concludes the discussion TLS. I spoke

00:20:07.120 about what is TLS. I've talked about

00:20:10.130 the TLS handshake protocol, that establishes the

00:20:13.140 connection using the ClientHello, ServerHello, and Finished

00:20:16.150 messages,

 

00:20:16.680 and that agrees the appropriate cryptographic parameters.

00:20:19.179 And I spoke about the TLS record

00:20:21.677 protocol, which is used to actually exchange

00:20:24.176 the data.

 

00:20:24.990 The TLS 0-RTT extension allows for faster

00:20:27.817 data transfer at the beginning of the

00:20:30.644 connection, but comes with some risks of

00:20:33.470 data replay attack. Finally, I spoke about

00:20:36.297 some of the limitations of TLS.

 

00:20:38.820 The TLS protocol has actually been wildly

00:20:41.713 successful. It's used to secure all the

00:20:44.607 traffic sent over the web. And when

00:20:47.500 used correctly, is very much a secure

00:20:50.393 protocol, that performs very well.

 

00:20:52.560 In the final part of the lecture,

00:20:54.042 I'll move on from talking about the

00:20:55.525 details of the cryptographic mechanisms, and the

00:20:57.007 transport protocols, to talk about some of

00:20:58.489 the issues with writing secure software.

Part 4: Discussion

The final part of the lecture discusses systems aspects of providing secure communication. It reviews the need for end-to-end security to protect communications. It discusses the robustness principle, and its implications for the design on input parsers and other aspects of networked systems. And it briefly reviews some of the challenges in writing secure code.

00:00:00.000 In the previous parts, I’ve spoken about

00:00:03.677 the general principles underlying secure communication,

00:00:05.972 and about the Transport Layer Security protocol,

00:00:08.649 TLS 1.3, that protects most Internet communications.

00:00:11.326 In this final part of the lecture,

00:00:14.104 I want to raise some issues to

00:00:16.781 consider when developing secure networked applications.

00:00:19.075 In particular, I want to discuss the

00:00:21.853 need for end-to-end security, and the problems

00:00:24.530 of making secure communication in the presence

00:00:27.207 of content distribution networks, servers, and middleboxes.

00:00:29.884 I want to talk about the robustness

00:00:32.661 principle, and the difficulty in designing and

00:00:35.339 building networked applications. And I want to

00:00:38.016 talk about the need to carefully validate

00:00:40.693 input data, and part of the issues

00:00:43.370 around writing secure code.

 

00:00:46.000 For communication to be secure, it must

00:00:48.898 be end-to-end.

00:00:49.726 That is, the secure communication must run

00:00:52.724 between the initial sender and the final

00:00:55.622 recipient, and the message must not be

00:00:58.520 decrypted or lose integrity protection at any

00:01:01.418 point along the path.

00:01:03.074 That is harder to arrange than you

00:01:06.072 might imagine.

 

00:01:07.000 If the communication is between a client

00:01:09.488 and a server located in a data

00:01:11.976 centre, it’s easy to understand what is

00:01:14.464 the client endpoint. It’s the phone,

00:01:16.597 tablet, or laptop on which the application

00:01:19.085 making the request is running. What is

00:01:21.573 the endpoint in the data centre though?

00:01:24.061 Does the secure connection terminate at the

00:01:26.550 load balancing device at the entrance to

00:01:29.038 the data centre, that chooses which of

00:01:31.526 the many possible servers responds to the

00:01:34.014 request? If so, does that load balancer

00:01:36.502 make a secure onward connection to the

00:01:38.990 back-end server, or is the connection unprotected

00:01:41.478 within the data centre?

 

00:01:43.000 If the secure connection passes through the

00:01:45.812 load balancer and terminates on the back-end

00:01:48.625 server, are the connections between the back-end

00:01:51.437 servers and the databases, compute servers,

00:01:53.847 and storage servers in other parts of

00:01:56.660 the data centre secure? And, once the

00:01:59.472 request has been handled, how is the

00:02:02.284 data protected once it’s stored in the

00:02:05.096 data centre?

 

00:02:06.000 What is your threat model? Are you

00:02:08.791 concerned about protecting your communication as it

00:02:11.582 traverses the wide area network between your

00:02:14.374 client and the data centre? Or are

00:02:17.165 you also concerned with protecting communications within

00:02:19.956 the data centre? If you’re concerned about

00:02:22.747 communications and data storage within the data

00:02:25.539 centre, are you trying to protect against

00:02:28.330 other tenants of the data centre? Or

00:02:31.121 against malicious users that may have compromised

00:02:33.912 the data centre infrastructure? Or against the

00:02:36.704 data centre operator?

 

00:02:38.000 Similar issues arise with content distribution networks.

00:02:41.304 CDNs, such as Akamai, are widely used

00:02:44.607 as the backend infrastructure for websites,

00:02:47.439 software updates, streaming video services, and gaming

00:02:50.742 services. Applications like the Steam store,

00:02:53.574 the BBC iPlayer, Netflix, and Windows Update,

00:02:56.877 have all run on CDNs at various

00:03:00.181 times, although many of them now use

00:03:03.484 their own infrastructure.

 

00:03:05.000 CDNs are essentially large-scale highly distributed web

00:03:08.000 caches. They provide local copies of data,

00:03:11.000 to improve performance compared to having to

00:03:14.000 fetch the content from the master site.

00:03:17.000 The secure HTTPS connection is therefore from

00:03:19.967 the client to the CDN, rather than

00:03:22.933 from the client to the original site.

 

00:03:26.000 This introduces an intermediary into the path.

00:03:29.360 The CDN now has visibility into what

00:03:32.720 requests a client is making, in addition

00:03:36.080 to the original service.

00:03:38.000 Performance is better, but you’re forced to

00:03:40.221 trust a third party with information about

00:03:42.443 what sites you’re visiting.

00:03:43.712 Equally, the data has to get to

00:03:46.033 the CDN caches somehow, and has to

00:03:48.255 be protected as its fetched from the

00:03:50.476 original server to populate the cache.

00:03:52.380 You have to trust the CDN to

00:03:54.601 do this correctly. As a user of

00:03:56.823 the CDN, you have know way of

00:03:59.044 knowing how, or indeed if, that data

00:04:01.265 is secure.

 

00:04:02.000 In many cases, data is moving between

00:04:04.849 two users. Is that data encrypted end-to-end

00:04:07.699 between the two users? Or is the

00:04:10.548 data encrypted between the users and some

00:04:13.397 data centre, but visible to the data

00:04:16.246 centre? The difference can matter: if the

00:04:19.096 data centre has access to the unprotected

00:04:21.945 data, it may be used to target

00:04:24.794 advertising, and it’s much more likely to

00:04:27.644 be accessible to law enforcement or government

00:04:30.493 monitoring.

 

00:04:32.000 Many applications use some form of in-network

00:04:34.781 processing. For example, video conferencing systems often

00:04:37.563 use a central server to perform audio

00:04:40.344 mixing and to scale the video to

00:04:43.125 produce thumbnails.

00:04:43.920 For example, in a large video conference,

00:04:46.801 if many users are sending video,

00:04:49.185 then all the video goes to a

00:04:51.967 central server. That server only forwards high

00:04:54.748 quality video for the active speaker,

00:04:57.132 and sends a smaller, more heavily compressed,

00:04:59.913 version for the other participants.

 

00:05:02.000 This reduces the amount of video sent

00:05:04.887 out to each of the participants,

00:05:07.363 and prevents overloading their network connections.

00:05:09.838 This is a good thing.

 

00:05:12.000 But, it also means that the central

00:05:14.544 server has access to the audio and

00:05:17.088 video. The server can record that video,

00:05:19.632 if it so chooses, and potentially share

00:05:22.176 it with others. That may be a

00:05:24.720 concern, depending on what’s being discussed.

 

00:05:27.000 An alternative way of building such an

00:05:29.791 application leaves the data encrypted, and doesn’t

00:05:32.581 give the server access. This increases the

00:05:35.372 privacy of the users, since the data

00:05:38.163 is encrypted end-to-end and isn’t available to

00:05:40.953 the server, but means that the server

00:05:43.744 can’t help compress the data and manage

00:05:46.535 the load, and it means that server-based

00:05:49.325 features, like cloud recording and captioning become

00:05:52.116 much harder to provide. It trades-off features

00:05:54.907 and performance, for increased privacy.

 

00:05:58.000 When building networked applications, it’s important to

00:06:01.103 consider how the network protocol is implemented.

00:06:04.206 Network protocols can be reasonably complex,

00:06:06.966 and difficult to implement. They have a

00:06:10.069 syntax and semantics, in many ways similar

00:06:13.172 to a programming language. And, like a

00:06:16.275 program, the protocol messages your application receives

00:06:19.378 may contain syntax errors or other bugs.

00:06:22.481 What do you if, if the protocol

00:06:25.684 data you receive is incorrect?

 

00:06:28.000 A frequently quoted guideline is Postel’s law.

00:06:31.161 This is named after Jon Postel,

00:06:33.870 the original editor of what became the

00:06:37.030 IETF’S RFC series of documents, and an

00:06:40.191 influential contributor to the early Internet.

 

00:06:43.000 Postel’s law can be summarised as “Be

00:06:46.232 liberal in what you accept, and conservative

00:06:49.463 in what you send”.

00:06:51.310 That is, when generating protocol messages,

00:06:54.179 try your hardest to do so correctly.

00:06:57.411 Make sure the messages you send strictly

00:07:00.642 conform to the protocol specification.

00:07:02.951 But, when receiving messages, accept that the

00:07:06.282 generator of those messages may be imperfect.

00:07:09.514 If a message is malformed, but unambiguous

00:07:12.745 and understandable, Postel’s law suggests to accept

00:07:15.977 it anyway.

 

00:07:17.000 That’s fine, but i’s important to balance

00:07:19.980 interoperability with security. Don’t be too liberal

00:07:22.960 in what you try to accept.

00:07:25.514 Having a clear specification of how and

00:07:28.494 when you will fail might be more

00:07:31.474 appropriate.

 

00:07:33.000 Postel’s law says “Be liberal in what

00:07:35.785 you accept, and conservative in what you

00:07:38.570 send”.

00:07:39.718 That makes sense if you trust the

00:07:42.603 other devices on the network.

00:07:44.593 It makes sense if the problems with

00:07:47.478 the messages they send are honest mistakes,

00:07:50.263 and not intended to be malicious.

 

00:07:53.000 The network has changed since Postel’s time,

00:07:56.039 though.

00:07:57.223 As Poul-Henning Kamp, one of the FreeBSD

00:08:00.362 developers, says “Postel lived on a network

00:08:03.401 with all his friends. We live on

00:08:06.440 a network with all our enemies.

00:08:09.045 Postel was wrong for todays internet”.

 

00:08:12.000 This is an important point.

 

00:08:15.000 Any networked system is frequently attacked.

00:08:17.670 There are many people scanning the network

00:08:20.885 for vulnerabilities. Actively trying to break your

00:08:24.000 applications. If you write a server,

00:08:26.670 and make it accessible on the Internet,

00:08:29.785 then people will try to break it.

 

00:08:33.000 This is not because you’re a target.

00:08:35.843 It’s because machines and network connections are

00:08:38.686 now fast enough that it’s possible to

00:08:41.529 scan every machine on the Internet,

00:08:43.965 to see if it’s vulnerable to a

00:08:46.808 particular problem, within a few hours.

00:08:49.245 It’s not personal. But your server will

00:08:52.088 be attacked.

 

00:08:53.000 The paper shown on the slide,

00:08:55.441 on “The Harmful Consequences of the Robustness

00:08:58.289 Principle”, by Martin Thomson, talks about this

00:09:01.136 in detail, and gives detailed guidance on

00:09:03.984 how to handle malformed messages. If you

00:09:06.832 write networked, applications, I strongly encourage you

00:09:09.680 to read it.

 

00:09:12.000 One of the key points made is

00:09:14.928 that networked applications work with data supplied

00:09:17.856 by un-trusted third parties.

00:09:19.530 As we’ve discussed, data read from the

00:09:22.558 network may not conform to the protocol

00:09:25.486 specification. This may be due to ignorance,

00:09:28.414 bugs, malice, or a desire to disrupt

00:09:31.342 services.

00:09:32.511 One of the most critical lessons is

00:09:35.539 that you must carefully validate all data

00:09:38.467 received from the network before you make

00:09:41.395 use of it.

 

00:09:42.000 Don’t trust arbitrary data that comes from

00:09:44.900 another device over the network. Check it

00:09:47.800 carefully, and make sure it contains what

00:09:50.700 you expect, before use.

00:09:52.357 This is especially important when working in

00:09:55.357 scripting language, that often contain escape characters

00:09:58.257 that trigger special processing. The cartoon on

00:10:01.157 the slide is an example. The idea

00:10:04.057 is that the software processing the student’s

00:10:06.957 name sees the closing quote, and interprets

00:10:09.857 the rest of the name as an

00:10:12.757 SQL commands to delete the student records

00:10:15.657 from the database.

 

00:10:17.000 It’s a silly example.

00:10:18.853 But it’s surprising how often similar problems,

00:10:22.195 known as SQL injection attacks, occur in

00:10:25.437 practice.

 

00:10:26.000 And similar problems occur in many other

00:10:29.118 programming languages. This is not just an

00:10:32.236 SQL-related problem.

00:10:33.127 Be careful how you process data.

 

00:10:37.000 And, in general, be careful how you

00:10:40.900 write networked applications.

00:10:42.571 The network is hostile.

 

00:10:45.000 Any networked application is security critical.

00:10:48.337 Anything that receives data from the network

00:10:52.231 will be attacked.

 

00:10:54.000 When writing networked applications, carefully specify how

00:10:57.213 they should behave with both correct and

00:11:00.426 incorrect inputs. Carefully validate inputs and handle

00:11:03.638 errors. And check that your code behaves

00:11:06.851 as expected. Try to break your application,

00:11:10.064 before someone else does.

 

00:11:12.000 If you’re writing your application using a

00:11:15.168 type- or memory-unsafe language, such as C

00:11:18.337 and C++, take extra case, since these

00:11:21.505 languages have additional failure modes.

00:11:23.768 It’s very easy to write a C

00:11:27.037 or C++ program that suffers from buffer

00:11:30.205 overflows, use after free bugs, race conditions,

00:11:33.374 and so on. Such bugs are almost

00:11:36.542 certainly security vulnerabilities.

 

00:11:38.000 As a rule of thumb, if you’ve

00:11:40.596 written a C or C++ program,

00:11:42.821 and can cause it to crash with

00:11:45.417 a “segmentation violation” message, then that’s probably

00:11:48.012 exploitable as a security vulnerability.

00:11:49.867 Have you ever managed to write a

00:11:52.562 non-trivial C program that never crashes in

00:11:55.158 that way?

 

00:11:56.000 This is why network programming is difficult.

00:11:59.355 The network, today, is an extremely hostile

00:12:02.710 environment. Networked applications are security critical,

00:12:05.586 and writing secure code is a very

00:12:08.941 difficult skill.

 

00:12:10.000 If you have the choice, use popular,

00:12:13.565 well-tested, pre-existing software libraries for network protocols

00:12:17.130 where possible, especially do so for implementations

00:12:20.695 of security protocols such as TLS.

00:12:23.751 And make sure to update these libraries

00:12:27.316 regularly, because problems and security vulnerabilities are

00:12:30.881 found frequently.

 

00:12:32.000 The best encryption in the world doesn’t

00:12:35.150 help you, if the endpoints can be

00:12:38.300 compromised and the data stolen before it’s

00:12:41.450 encrypted.

 

00:12:43.000 This concludes our discussion of secure communications.

00:12:45.607 In the first part, I spoke about

00:12:48.314 the need for secure communication, and some

00:12:50.921 of the challenges and trade-offs in enabling

00:12:53.528 security.

 

00:12:54.000 In the second part, I discussed the

00:12:57.262 principles of secure communication in abstract terms,

00:13:00.523 talking about symmetric and public key encryption,

00:13:03.785 and how these are combined to give

00:13:07.047 hybrid encryption protocols. I spoke about digital

00:13:10.309 signatures to authenticate data, and about public

00:13:13.570 key infrastructure and certificate authorities.

 

00:13:16.000 I spoke about the Transport Layer Security

00:13:19.355 protocol, TLS 1.3, that instantiates hybrid encryption

00:13:22.710 and digital signatures into a concrete network

00:13:26.066 protocol, that secures web traffic and other

00:13:29.421 applications.

 

00:13:30.000 And, finally, I’ve discussed some issues to

00:13:33.442 consider when writing networked applications.

 

00:13:36.000 Ensuring communications security is a difficult problem.

00:13:39.280 It’s technically difficult, because you need to

00:13:42.561 write extremely robust software, and need to

00:13:45.841 design secure network protocols that use sophisticated

00:13:49.122 cryptographic mechanisms. And it’s politically difficult,

00:13:51.933 because there are some extremely sensitive policy

00:13:55.214 questions around what information should be protected,

00:13:58.494 and against whom.

 

00:14:00.000 The TLS 1.3 protocol is the current

00:14:02.854 state-of-the-art in secure communications. In the next

00:14:05.708 lecture, we’ll move on to further discuss

00:14:08.562 its limitations, and some of the ways

00:14:11.415 in which people are trying to improve

00:14:14.269 network security and performance.

Discussion

Lecture 3 discussed secure communication. It started with a discussion of the need for security, and the issues with balancing security, privacy, and the needs of law enforcement, regulatory compliance for businesses, and the need to effectively manage networks. It then moved on to discus the principles by which secure communication can be achieved, via a mix of symmetric and public key encryption and digital signatures. And it outlined how these are used in the transport layer security protocol, TLS.

The focus of the discussion will be to check your understanding of the principles of security. In outline, how do symmetric and public key encryption work, and how are they combined in practice? In outline, how do digital signatures work? The maths of how these work is very far outside the scope of this course, and will not be discussed.

And in outline, how does TLS use these techniques to ensure security? This is setting the scene for the more detailed review of TLS in the lab exercise.

The discussion will also focus on the need to consider the different impacts of providing secure communication. There are clear benefits to providing security, but also some unexpected costs that can lead to tension between users, vendors, network operators, businesses and governments. The discussion will start to highlight some of these issues.