[00:00.000 --> 00:05.200] Next up we have Carl Kosher talking about enabling HTTPS for home network devices using [00:05.200 --> 00:13.900] Let's Encrypt. All right. Thanks. So I'm Carl Kosher. I'm a research scientist at the [00:13.900 --> 00:19.440] University of Washington doing wireless and embedded system security. I'm going to talk [00:19.440 --> 00:27.720] about some of the challenges of using TLS on home network devices or other internal network [00:27.720 --> 00:37.180] devices and a way to easily issue certificates for these devices. So why is TLS important? [00:37.180 --> 00:41.820] Isn't, you know, WPA on your network enough? I mean, it's already encrypting and [00:41.820 --> 00:47.840] authenticating your communication. Well, as it turns out, browsers are really pushing for [00:47.840 --> 00:54.600] TLS these days. Chrome and some other browsers are now requiring TLS to use certain [00:54.600 --> 01:05.500] powerful APIs such as accessing the user's web camera or running service workers or pushing [01:05.500 --> 01:14.080] notifications. And so if you want to write an app that uses these, what they call powerful [01:14.080 --> 01:23.560] features, you need to serve that over TLS. And the problem with that is if you want to make a [01:23.560 --> 01:29.820] web application that uses those features and also communicates with local network devices, [01:29.820 --> 01:38.020] you can't really do that because it also blocks cross-origin requests from a secure origin to [01:38.160 --> 01:47.360] a non-secure origin. And so to make this a bit more concrete, I was trying to write an app for [01:47.360 --> 01:55.140] the Chromecast which requires applications to be served over HTTPS to connect to this HD [01:55.140 --> 02:05.780] home run TV tuner so that I could watch TV channels on my TV through my Chromecast while it [02:05.780 --> 02:17.340] connects to the TV tuner and pulls down the impact stream. The problem is that, so the [02:17.340 --> 02:23.680] HD home run device, it gets its IP address. However, because the HD home run device only [02:23.680 --> 02:30.340] speaks HTTP, it can't actually do that cross-origin request to get that, uh, impact data [02:30.340 --> 02:38.540] stream. And so this is sort of the problem that really, um, uh, caused me to, to look at this [02:38.540 --> 02:47.320] issue. So why is, uh, doing local TLS hard? Well, uh, as I alluded to, um, local TLS is [02:47.940 --> 02:55.960] often discovered by their IP address and not by a particular host name. Uh, TLS certs, on [02:55.960 --> 03:01.940] the other hand, are issued for a specific host name. So, um, in the common name or the, uh, [03:01.940 --> 03:06.860] subject alternate name, you have a list of, uh, fully qualified domain names that a [03:06.860 --> 03:13.100] certificate is valid for. And, um, so if you're just connecting to an IP address, uh, that [03:13.100 --> 03:23.720] doesn't match what it is in the, the certs. Some, uh, device manufacturers will, uh, ship a [03:23.720 --> 03:30.620] cert, uh, on the device, uh, and that certificate is the same across all devices. Uh, however, [03:30.620 --> 03:36.500] that can be easily abused. Um, you might remember the super fish scandal that happened [03:36.500 --> 03:44.660] several years ago. Basically, uh, this software, uh, pre-installed a, uh, certificate, um, that [03:44.660 --> 03:53.440] was, uh, used as a CA certificate that could, uh, sign, uh, any host name, uh, whatsoever. And [03:53.440 --> 04:00.060] the problem there was that the private key was shared across all laptops and so anyone with [04:00.060 --> 04:07.000] the super fish software could then create, uh, certificates for any domain name. Um, so you [04:07.000 --> 04:14.720] can also do that, uh, when you have shared certificates across these network devices. Uh, [04:14.720 --> 04:19.900] even if you do unique certificates, again, because you're, uh, discovering these devices [04:19.900 --> 04:27.820] by IP address, um, they will often be for a common host name like, uh, router dot homeland [04:27.820 --> 04:35.020] dot com or something like that. And so if you have any of these certificates, uh, you can get [04:35.020 --> 04:45.660] them re- you can, um, basically use those to, uh, do man in the middle attacks on, uh, on that [04:45.660 --> 04:53.160] domain name. Um, if you want to do something with, like, let's encrypt, uh, the problem there [04:53.160 --> 04:59.860] is that a lot of end users typically don't own a domain. Uh, I imagine most people in this room [04:59.860 --> 05:06.820] probably do, but, uh, real users don't. Uh, and so there's not really, uh, a domain that [05:06.820 --> 05:14.020] people can use to, uh, get their own certificate. And finally, even if they do have their own [05:14.020 --> 05:20.260] domain name and they want to get a domain with let's encrypt, uh, these local devices aren't [05:20.260 --> 05:26.260] externally facing, so the typical way of using certbot to automatically generate these [05:26.260 --> 05:31.840] certificates, uh, doesn't really work because, uh, let's encrypt can't talk back to the [05:31.840 --> 05:38.900] device to verify, uh, domain ownership or control. So it turns out that one company has [05:38.900 --> 05:46.720] actually solved this issue and that company is Plex. So Plex is, uh, well, it's a little [05:46.720 --> 05:55.740] sketchy, but it's basically, uh, Netflix for your own, uh, home media, um, server. And, uh, [05:55.740 --> 06:06.440] the way that they solved it is they issue each server a 16 byte GUID and then Plex issues a [06:06.440 --> 06:14.240] wildcard cert for this GUID dot Plex dot direct. And so whenever you want to talk to your [06:14.240 --> 06:21.940] Plex server on a particular IP address, you go to IP address dot GUID dot Plex dot direct and [06:21.940 --> 06:28.480] they have name servers set up that automatically resolve that, uh, directly to A dot B dot C [06:28.480 --> 06:35.040] dot D. Now this seems a little weird, but, um, the key here is that by going to that fully [06:35.040 --> 06:41.280] qualified domain name instead of an IP address, um, the, uh, fully qualified domain name [06:41.280 --> 06:47.140] matches with the wildcard cert that the server has, uh, and then the connection is trusted [06:47.140 --> 06:54.160] automatically. And so this allows for, um, uh, friends to connect to your server over the [06:54.160 --> 07:00.720] internet. Even if you have a dynamic, uh, IP address from your ISP, it also, uh, lets you [07:00.720 --> 07:07.800] connect directly, uh, on internal, um, like 192 dot 168, uh, IP addresses as well and [07:07.800 --> 07:14.880] everything is, uh, nice and secure. So, Plex partnered with, uh, certificate authority to [07:14.880 --> 07:21.880] issue these certs and that's kind of costly and, uh, most IOT vendors won't bother doing [07:21.880 --> 07:27.680] this. So, I was wondering if we could actually use Let's Encrypt which provides free [07:27.680 --> 07:34.560] certificates to do this and as it turns out, you actually can. So, let's talk a little bit [07:34.560 --> 07:39.780] about how Let's Encrypt, uh, automatically issues certificates. So, they use what's known [07:39.780 --> 07:44.460] as the ACME protocol, the automation, uh, automated certificate management environment [07:44.460 --> 07:50.980] protocol and this is implemented by, uh, a client called Certbot and by, uh, CA software [07:50.980 --> 07:58.520] called Boulder and this is a way to, uh, basically automate, uh, domain validation to prove [07:58.520 --> 08:06.820] that you have control over a domain that you want, um, a certificate for. Uh, so, the way [08:06.820 --> 08:13.540] that this, that the ACME protocol works is that the certificate authority issues you a [08:13.540 --> 08:19.280] challenge, uh, to prove, uh, control over a domain that you want a certificate for. And [08:19.380 --> 08:23.340] there's a couple of different types of challenges, uh, the two main ones right now are [08:23.340 --> 08:31.080] HTTP01 where the, uh, certificate authority asks you to create a file at a specific URL with, [08:31.080 --> 08:36.500] uh, specific contents and it verifies that you put that file there and if you did, uh, then you [08:36.500 --> 08:41.080] have control over that domain and they give you a certificate for that. There's also DNS01 [08:41.080 --> 08:49.680] where you add a text record, um, for the domain name, uh, with a, a specific content, uh, uh, [08:50.200 --> 08:58.760] secure token, uh, and, uh, this is the only way to get, uh, wild card certificates, um, but it's [08:58.760 --> 09:06.660] nice that they do, uh, give you wild card certificates now. Um, so for accounts, um, [09:06.660 --> 09:13.920] basically they are associated with a public private key pair. Um, you're the, so you [09:13.920 --> 09:19.720] automatically generate this private key, um, and derive the public key from that and that [09:19.720 --> 09:25.580] public key is essentially your account ID. Now they do have sort of, uh, an internal account [09:25.580 --> 09:31.640] ID that you actually use, um, for efficiency and, and other reasons, but basically your [09:31.640 --> 09:37.420] account is this public private key pair and you use this private key that you generate [09:37.420 --> 09:41.480] yourself to sign all requests, including the initial registration with Let's Encrypt [09:41.480 --> 09:47.600] where you tell them that you agree to the terms of service and, and so on and so forth. Uh, so [09:47.600 --> 09:56.880] my proposed solution for, um, using Let's Encrypt, uh, for local devices is, um, this service [09:56.880 --> 10:03.840] that I'm calling TLS my net, which lets you issue wild card certificates for subdomain that [10:03.840 --> 10:11.460] is tied to your Let's Encrypt, uh, account public key. So, time is of the essence and [10:11.480 --> 10:20.040] tying the, um, the subdomain to your Let's Encrypt account, uh, basically lets you verify [10:20.040 --> 10:28.160] legit, legitimacy at an application level. Um, so, uh, you know that you are always going to [10:28.160 --> 10:33.660] talk to your server at a particular subdomain and as long as that subdomain matches, you [10:33.660 --> 10:41.340] know that, um, the private, uh, that at least someone with the corresponding private key, um, [10:41.340 --> 10:47.320] proved, uh, that they had that private key and they, um, got a certificate for that domain. [10:47.840 --> 10:55.220] So, the basic way that this works is you use, uh, Let's Encrypt, um, as normal, but, uh, [10:55.220 --> 11:03.540] instead of proving, um, control over your own domain, you ask a third party, uh, to, uh, [11:03.540 --> 11:11.320] prove control of a subdomain, um, and, uh, that third party then, um, um, can, um, [11:11.960 --> 11:17.800] solves that challenge for you by creating that text record. So, the way that this works is the [11:17.800 --> 11:22.740] device initiates a subdomain wildcard certificate request with Let's Encrypt. Let's [11:22.740 --> 11:28.500] Encrypt says, okay, here's a DNS challenge. Uh, the device then sends that challenge [11:28.500 --> 11:34.960] request to TLS MyNet. This request is signed with the public key using, uh, JSON web [11:34.960 --> 11:42.880] signatures. Uh, the thumbprint of the corresponding public key, um, is used as the [11:42.880 --> 11:48.420] subdomain, uh, and because of limitations of DNS, we actually have to encode this as a base [11:48.420 --> 11:56.720] 36, which is kind of icky, but, um, it, it works. Uh, and basically the, the public private [11:56.720 --> 12:01.880] key pair here is the same, uh, public private key that is tied to your Let's Encrypt [12:01.880 --> 12:10.880] account. Uh, so this is currently implemented in, uh, 2 Python scripts, um, uh, that are on [12:10.880 --> 12:18.040] GitHub right now and I'll, uh, give you that URL later. The first is, uh, DNS server.py and [12:18.040 --> 12:25.840] this does 2 things primarily. One, it resolves, uh, that, uh, IP address dot thumbprint dot [12:25.840 --> 12:31.860] TLS my dot net to that IP address. Um, so it, it handles that for you. The second, uh, [12:31.880 --> 12:38.600] second is that it also resolves these, uh, text records, um, that are used for, uh, [12:38.600 --> 12:46.300] subdomain, uh, verification with Let's Encrypt. Uh, it uses this library called DNSlib, which, [12:46.300 --> 12:53.160] uh, lets you easily create, uh, DNS clients and serve, uh, servers, uh, using Python. Right [12:53.160 --> 12:59.060] now the server is sort of, uh, single threaded and synchronous and so there could [12:59.060 --> 13:04.520] theoretically be some performance issues, but, uh, I'm planning on migrating that to, uh, [13:04.520 --> 13:12.500] Python's async IO, uh, fairly shortly. Uh, the second half of this, uh, system is the, the web [13:12.500 --> 13:18.520] server, which receives these requests, uh, for creating these text records to respond to [13:18.520 --> 13:23.820] these challenges. Uh, this does use async IO, so even though it's single threaded, um, it [13:23.820 --> 13:29.280] can handle multiple requests and while it's waiting on one, it can service another. Uh, and [13:29.280 --> 13:36.460] it uses, uh, also this, uh, JWcrypto library for doing, uh, JSON web signatures and, and JSON [13:36.460 --> 13:40.820] web keys and things like that. And then in between there's just a standard Redis server [13:40.820 --> 13:47.840] that's a temporary, uh, key value store for storing, um, specific text records, uh, for [13:47.840 --> 13:55.780] specific subdomains. Um, and those, uh, those last for 5 minutes. Um, and so the nice thing [13:55.780 --> 14:04.040] here is that really there doesn't need to be any state that you actually store on this server. Uh, [14:04.040 --> 14:11.860] you just need the, the key value store long enough to, uh, do the domain verification. Um, you [14:11.860 --> 14:17.820] don't need accounts because, uh, those are automatically proven by using the public [14:17.840 --> 14:26.680] uh, private key pairs. Uh, and, uh, you know, the resolving an IP address, uh, is, you know, [14:26.680 --> 14:33.580] straightforward. So, currently this is still, uh, a work in progress. Um, there is a test [14:33.580 --> 14:41.960] client right now, uh, on GitHub that, uh, sends a, uh, request to create a challenge, um, to [14:41.960 --> 14:47.480] the web server. Uh, it, it could be better, um, but, you know, hopefully that's coming [14:47.480 --> 14:56.720] soon. Um, I am planning on integrating this with CertBot as a plug-in. However, there's a, a [14:56.720 --> 15:06.100] little, um, issue there where the, uh, CertBot plug-ins don't automatically expose the [15:06.100 --> 15:11.040] account, uh, public and private keys to, uh, the extensions there. So, that's a little [15:11.040 --> 15:16.080] issue I'll, I'll have to work through. The server currently has a little brokenness with case [15:16.080 --> 15:21.640] sensitivity, but, but I'm going to fix that today. Um, it, uh, I have tested it and it does [15:21.640 --> 15:27.920] work and as I said before, uh, the DNS server will be modified to use, uh, async IO for a bit [15:27.920 --> 15:34.920] more performance. Um, so the code is up right now on GitHub, on, uh, github.com slash [15:34.920 --> 15:44.000] superset slash TLS my.net. Uh, so before I, uh, finish this talk, uh, I might want to talk a bit [15:44.000 --> 15:52.020] about the risk model here. Um, this seems a bit, um, non-standard and you might have some [15:52.020 --> 15:58.940] concerns about this and, uh, I'll just talk, uh, a little bit about those. So, the third party [15:58.940 --> 16:05.760] domain that you use, uh, in this instance, TLS my.net is, um, assumed to be trusted because [16:06.280 --> 16:13.980] they can always prove, uh, control over, uh, that domain and any of its subdomains. Uh, but, [16:14.000 --> 16:19.680] the way I envision this being used is that, uh, each device manufacturer runs their own [16:19.680 --> 16:25.960] service for this and you're already trusting that manufacturer anyway, um, so there, there's [16:25.960 --> 16:33.640] some sort of implicit trust there. Um, also, as of, uh, fairly recently, there's these things [16:33.640 --> 16:40.400] called certificate transparency logs where every certificate that is issued is, um, uh, [16:40.400 --> 16:48.960] appended to these, uh, append only logs which, you know, blockchain, whatever, um, basically [16:48.960 --> 16:59.320] to, to prove, um, or to, basically to, uh, show that certificate authorities are not issuing [16:59.320 --> 17:05.300] certificates that are unauthorized. So, if you're concerned about your, uh, third party [17:05.300 --> 17:11.340] domain provider, um, issuing a certificate, uh, for your subdomain or issuing a wildcard [17:11.340 --> 17:15.640] cert for the entire domain, you can go through and search these, uh, certificate [17:15.640 --> 17:22.040] transparency logs to make sure that they are, uh, doing the right thing. Uh, so my plan is [17:22.040 --> 17:28.480] to release, uh, TLS MyNet as a public service, uh, and, um, you know, get this idea out [17:28.480 --> 17:34.440] there perhaps, maybe get, uh, Let's Encrypt to, to support this natively and do the same [17:34.440 --> 17:43.000] DNS resolution, uh, and challenges that, um, uh, that we support right now. Um, I'm, mostly [17:43.000 --> 17:49.540] see this as sort of a proof of concept service, uh, to encourage, uh, TLS adoption for these [17:49.540 --> 17:57.240] local network devices, um, that, uh, are currently hard to get, uh, TLS certificates for. And, [17:57.240 --> 18:03.360] uh, please, please, please bug your manufacturers to, to support TLS. So, even if you have, [18:03.360 --> 18:08.760] um, these certificates, you know, these devices still need a way to, uh, load these [18:08.760 --> 18:15.640] certificates into them, uh, and actually speak HTTPS and, and TLS and these things. And even [18:15.640 --> 18:23.360] if you do get a certificate, uh, the device still needs to talk TLS. Um, so, in summary, I [18:23.360 --> 18:28.840] would say, you know, going forward, TLS, uh, is absolutely essential for, uh, these [18:28.840 --> 18:34.440] innovative web applications. Uh, browsers are demanding it. Devices like the Chromecast are [18:34.440 --> 18:41.740] demanding it. Uh, basically, you need TLS if you want to, um, use a lot of these new powerful [18:41.740 --> 18:48.440] features. Um, currently, they, uh, these TLS certificates are difficult to acquire for, uh, [18:48.440 --> 18:54.680] these internal network devices for a bunch of reasons that I talked about. Um, but I, uh, [18:54.680 --> 19:01.100] proposed here a way of, uh, easily getting these, uh, wildcard certificates, uh, using a [19:01.100 --> 19:06.540] third-party service. Uh, so with that, I'd like to, uh, thank you for your attention. Uh, this [19:06.540 --> 19:13.080] is my email address, my Twitter handle, and the GitHub account for the TLS MyNet service. So, [19:13.080 --> 19:20.860] thanks. Alright. Thank you, Carl. If you have questions, please come up and line up by me. [19:32.230 --> 19:43.430] Did you have any problems with running into, uh, DNS needing a CAA record? So, we, uh, no. So, [19:43.430 --> 19:51.890] we do not return CAA records for that. We could return CAA records for that, but, um, the, so, [19:51.890 --> 20:00.090] for people who don't know, the CAA records, uh, basically, uh, say, or they tell a [20:00.090 --> 20:06.450] certificate authority which CAAs are allowed to issue certificates for a particular domain. Um, [20:06.450 --> 20:14.410] we currently don't, uh, return any CAA records. So, theoretically, any CAA could issue, um, uh, [20:14.410 --> 20:27.090] certs for, uh, TLS MyNet. Um, I, I could add it. Other questions? No? Alright. Well, then let's [20:27.090 --> 20:30.570] give Carl one last big round of applause. Alright. Thanks. Thank you, Carl.