00:00:00.033-->00:00:05.706 >>A little bit about myself. I’m malak on Twitter. I’m 18, I’m a student from the Bay area and I 00:00:05.706-->00:00:10.510 really like locks and computers. Lately I’ve been getting really interested in duplicating high 00:00:10.510-->00:00:16.416 security keys. Uh this my second time going to DefCon and my first time speaking and if 00:00:16.416-->00:00:20.521 you’re working on any interesting lock projects, come say hi. I’d love to hear about 00:00:20.521-->00:00:25.692 them. So you’ve probably seen these things before. There’s a good chance you even live or 00:00:25.692-->00:00:30.297 work in a building that has one. And these boxes contain the keys to the building. So when the 00:00:30.297-->00:00:34.201 firefighters show up in an emergency, they don’t have to start breaking stuff to get 00:00:34.201-->00:00:39.206 where they need to bed. They can just open the box, get the keys and let themselves in. A low 00:00:39.206-->00:00:42.543 tech way of doing this would be to just keep copies of everyone’s keys in the fire 00:00:42.543-->00:00:48.348 station, but having a single key for an entire area saves a lot of time on an emergency. Uh the 00:00:48.348-->00:00:53.253 most popular rapid entry system is made by Knox and the Knox box is mostly what I’ll focus on 00:00:53.253-->00:00:58.825 today. And a lot of places these things are required by law on commercial buildings. So you can 00:00:58.825-->00:01:02.763 have the best high security locks in the world on your doors. But you still have to put 00:01:02.763-->00:01:07.334 your keys in this metal box so that firefighters can get in. Uh sometimes these things even have 00:01:07.334-->00:01:12.406 alarm codes in them. They make really big ones for commercial buildings and tiny ones for 00:01:12.406-->00:01:16.810 people’s houses. Again same idea, you put your keys in the box and the firefighters can 00:01:16.810-->00:01:22.449 open the box. They also make padlocks and key switches for overriding gates and even boxes 00:01:22.449-->00:01:26.820 with circuit breakers inside. And all of these devices take the same keys, which are held by 00:01:26.820-->00:01:31.291 the local fire department. Sometimes one fire department will get their own unique Knox 00:01:31.291-->00:01:36.163 key and sometimes many departments will share the same system. Sometimes even an entire 00:01:36.163-->00:01:41.735 state will use a single Knox key throughout. So this is basically a physical backdoor to an entire 00:01:41.735-->00:01:46.873 city or even state. Bruce Schneier referred to it as physical key escrow and as I’m 00:01:46.873-->00:01:51.979 sure you all know by now, key escrow isn’t really that great for security. These are pretty 00:01:51.979-->00:01:56.516 powerful keys and as you can probably imagine, it’s kind of bad when they fall into the 00:01:56.516-->00:02:01.955 wrong hands. Here’s some footage from a burglary in Seattle, this guy walks up and starts messing 00:02:01.955-->00:02:06.560 with something on the wall and then he comes back with someone else and enters the code into 00:02:06.560-->00:02:10.864 their keypad that was supposed to be reserved for the fire department and they open the 00:02:10.864-->00:02:15.002 door, go in the building and leave with some packages that they were not supposed to leave 00:02:15.002-->00:02:20.774 with. Seattle then spent half a million dollars to rekey their Knox boxes. Something similar 00:02:20.774-->00:02:25.612 happened in Austin. Someone used a Knox key to break into a children’s hospital and steal 31 00:02:25.612-->00:02:31.151 thousand dollars. Austin then spent 300 thousand dollars to rekey their Knox boxes and one 00:02:31.151-->00:02:35.856 and a half million to make sure it never happened again. They also didn’t know how many Knox 00:02:35.856-->00:02:42.129 boxes they had in their city, but they thought it was around 6-->000. Also Knox’s website seems 00:02:42.129-->00:02:46.633 to be claiming that only the fire departments have these keys. They got some videos on 00:02:46.633-->00:02:52.205 their website where people say like, only the fire department has access to that box. Or only 00:02:52.205-->00:02:57.210 we have a key to open it. And I’m just not sure if that’s 100 percent accurate. I mean, this 00:02:59.513-->00:03:06.019 Phoenix fire department somehow managed to lose 850 of these keys. And they didn’t even 00:03:06.019-->00:03:11.391 notice until they counted them after hearing about the burglaries in Seattle. So who 00:03:11.391-->00:03:17.330 knows where they are. Uh, people can also get in a lot of trouble for refusing to install these 00:03:17.330-->00:03:22.102 things. There was an article last year about a butcher from Pennsylvania who didn’t want to 00:03:22.102-->00:03:27.207 install a Knox box because he didn’t like the idea of giving strangers access to his keys. 00:03:27.207-->00:03:32.079 The city threatened to put him in jail for 30 days, fine him 1-->000 dollars and condemn his 00:03:32.079-->00:03:37.517 building as a fire hazard. So if people are going to be forced to use these, I think they have a 00:03:37.517-->00:03:41.288 right to know to know what’s inside of them. A couple years ago I got in touch with Knox to 00:03:41.288-->00:03:46.259 ask about the locks they’re using and they pretty much told me to pound sand. They did not 00:03:46.259-->00:03:52.966 want to talk to me at all. So Knox boxes almost exclusively use Medeco 72 series cam-loks. 00:03:52.966-->00:03:58.538 Older ones use the biaxial and newer ones uses the M3. These are really cool locks that work 00:03:58.538-->00:04:02.075 a little bit differently than what most people are used to. I don’t really have time to go 00:04:02.075-->00:04:06.446 into exactly like they work, but basically the cuts on the key can have different angles as 00:04:06.446-->00:04:10.951 well as depths. With the normal key, the only thing that really matters is how deep the cuts 00:04:10.951-->00:04:16.690 are, but with Medeco’s the angle of the cuts is also important. The key rotates the pins as well 00:04:16.690-->00:04:21.161 as lifting them up, so if you look at a Medeco key from the top down you can see that some 00:04:21.161-->00:04:25.799 of the cuts have been twisted one way and some have been twisted the other. They also 00:04:25.799-->00:04:29.936 don’t have any driver pins uh this is what the key pins look like and I think it’s a very 00:04:29.936-->00:04:35.976 clever design. These things are physically very tough and the lock is super hard to pick. It’s 00:04:35.976-->00:04:40.447 rated by UL to withstand many different types of attacks for 30 minutes. I only know a 00:04:40.447-->00:04:45.485 handful of people who can pick these things, but unfortunately I don’t think they offer enough 00:04:45.485-->00:04:51.024 protection against of unauthorized replication of keys. Uh Knox is pretty serious 00:04:51.024-->00:04:55.428 about key control. Uh the keys are supposed to be kept inside these electronic boxes, which 00:04:55.428-->00:05:00.500 I’m sure are completely unhackable. They’re also connected to radio and wi-fi 00:05:00.500-->00:05:06.173 sometimes. Which is great, but the firefighter has to enter a pin in order to remove the key 00:05:06.173-->00:05:10.544 and it keeps track of when that happens. So these are pretty well protected. But even if 00:05:10.544-->00:05:15.482 someone has physical access to a key for just a few seconds, they can still gain a lot of useful 00:05:15.482-->00:05:20.220 information about it. Someone can make measurements of it by taking a clay impression or by 00:05:20.220-->00:05:26.359 using a key decoder or just a photograph. You don’t even need a good photo in 2008 some 00:05:26.359-->00:05:30.764 students at UC San Diego showed that they were able to copy a key that was photographed from 00:05:30.764-->00:05:35.602 around 200 feet away. And sometimes it’s not even necessary to take your own 00:05:35.602-->00:05:41.942 photo. After about 10 minutes of searching on YouTube, I saw several videos of people showing 00:05:41.942-->00:05:48.648 off Knox keys. It’s probably not good that these keys are being posted to the internet. A, a key 00:05:48.648-->00:05:53.720 is pretty much just a metal password. Anyone who can read it, can copy it. That being 00:05:53.720-->00:05:57.791 said, it’s not always easy to replicate a Medeco key. You wouldn’t just be able to get one 00:05:57.791-->00:06:02.162 copied at the hardware store because they use special restricted key blanks and only 00:06:02.162-->00:06:07.267 certain people are allowed to make copies. But these keys are just chunks of metal and with 00:06:07.267-->00:06:12.606 the right tools, any chunk of metal can be reproduced. If you already have the blank, you can 00:06:12.606-->00:06:18.445 make the cuts on the certain key machines, or even just by hand with the metal file. But getting 00:06:18.445-->00:06:23.516 restricted key blanks can be kind of tricky. There are plenty of ways to make key blanks 00:06:23.516-->00:06:29.389 though. For example, modifying another similar blank until it fits into the lock and there 00:06:29.389-->00:06:34.060 have been some attacks presented at DefCon before. In some situations you can make a key 00:06:34.060-->00:06:38.898 blank out of a thin piece of metal or plastic, like a credit card. Uh this will work if the 00:06:38.898-->00:06:44.804 keyway is wide open, but not so much on the more paracentric key ways. If you want to make a 00:06:44.804-->00:06:49.809 better blank, milling is a pretty good way to go. CNC is good, uh there are also mills 00:06:49.809-->00:06:53.980 built specifically for duplicating key blanks, but they are very expensive and have some 00:06:53.980-->00:06:59.819 drawbacks. If you don’t have access to one, a good 3D printer will work too. Cheap FDM 00:06:59.819-->00:07:04.357 printers are usually precise enough to duplicate something like a house key pretty easily, 00:07:04.357-->00:07:08.161 but with higher security locks, sometimes you need more precision to make a reliable 00:07:08.161-->00:07:12.966 key. SLA printers are really good for this and shapeways has some extremely precise 00:07:12.966-->00:07:17.337 materials. Shapeways is a service that will 3D print things for you. You just upload 00:07:17.337-->00:07:21.841 your file, choose your printer, pay a couple bucks and they mail it to you. I’ve tested most of 00:07:21.841-->00:07:27.781 their materials and I like their MJF process the best. So I’ve been wondering how hard it would 00:07:27.781-->00:07:32.886 be to print one of these keys from scratch. It turns out it’s really not that difficult. The 00:07:32.886-->00:07:37.424 printing is pretty easy, but the real fun begins when you start trying to model the key. 00:07:37.424-->00:07:42.228 Obviously I don’t have access to the original key to begin with and I can’t easily get a hold of 00:07:42.228-->00:07:46.933 one, I mean, all things considered, I think Knox is doing a pretty good job of key 00:07:46.933-->00:07:51.037 control. They’re using patent protected keys, that are slightly harder to duplicate 00:07:51.037-->00:07:56.443 with the normal keys and the keys are kept in special boxes and obviously they won’t just 00:07:56.443-->00:08:02.816 sell you the key, but what they will sell you is the box and the interesting thing is, the lock 00:08:02.816-->00:08:07.654 in the box contains all of the information necessary to reproduce the key. The lock and 00:08:07.654-->00:08:12.459 the key are pretty much mirror images of each other. I mean, it has to be this way because the 00:08:12.459-->00:08:17.397 lock has to somehow check if the key is correct. There’s no encryption, no challenge 00:08:17.397-->00:08:22.068 response, just some pieces of metal interacting with each other and they’ll sell one to 00:08:22.068-->00:08:27.707 anyone who wants to put one on their building. So I bought one to check it out. [laughter] It 00:08:27.707-->00:08:32.712 came with some cool documents which I immediately ignored and sure enough it shipped with the 00:08:35.749-->00:08:40.920 lock installed. These things also ship open, so it’s really easy to just unscrew the thing 00:08:40.920-->00:08:45.925 and pop the lock out. [applause] So now I have the Knox lock for my city and that means that I 00:08:52.599-->00:08:58.204 effectively have a negative image of the Knox key for my city. And so does everyone else 00:08:58.204-->00:09:02.642 who has one of the boxes. If I can make a key to open my box, then I would have a key to 00:09:02.642-->00:09:07.480 almost every commercial building in my city. I didn’t really want to mess with mine, so I bought 00:09:07.480-->00:09:12.485 some very similar locks on Ebay and started trying to make a model in OpenSCAD. It’s a 3D 00:09:14.788-->00:09:19.492 modeling tool where you define your shape in a language similar to C, but instead of compiling 00:09:19.492-->00:09:24.864 into a computer program, it compiles into a shape and since it’s completely parametric, it’s 00:09:24.864-->00:09:29.135 perfect for modeling things like keys. Once you have your model setup, if you want to change 00:09:29.135-->00:09:34.541 something, it’s as simple as just updating some numbers and recompiling. Uh I’m not the 00:09:34.541-->00:09:39.312 first one to use it to model keys. Nirav Patel, Christian Holler and Eric Van Albert have 00:09:39.312-->00:09:43.416 done that before, but I wanted to try making my tool that suited my needs a little bit 00:09:43.416-->00:09:48.988 better. So one of the first challenges I ran into was modeling the key way. Sometimes 00:09:48.988-->00:09:53.526 Medeco will remove a lot of metal from the face of the plug and this makes it kind of hard 00:09:53.526-->00:09:58.431 to get a good image of the key way. Like if I try to scan or photograph it, the wording is 00:09:58.431-->00:10:03.703 really hard to see because it doesn’t start until about a few millimeters back from the face. 00:10:03.703-->00:10:07.974 But a quick and dirty way around that is to just slice the plug in half and look at a cross 00:10:07.974-->00:10:12.779 section of it. You can just cut it with a hacksaw or something. It doesn’t really matter if it 00:10:12.779-->00:10:17.484 leaves a nasty, rough edge, because you can just lap the face until it’s perfectly even. 00:10:17.484-->00:10:21.654 And then if you polish it and put it down a flatbed scanner, you should get a pretty crisp 00:10:21.654-->00:10:26.459 image of the key way. The next thing to consider is that this cross section is not perfectly 00:10:26.459-->00:10:31.498 circular, we’re taking a cross section of a cylinder and if the face we’re scanning is not 00:10:31.498-->00:10:35.468 absolutely parallel with the front and back of the plug, the picture we’ll get will be 00:10:35.468-->00:10:39.839 slightly elliptical. This is pretty easy to correct for though. I made a program that 00:10:39.839-->00:10:45.678 just transforms the ellipse back into a perfect circle. And then once we have the image, we can 00:10:45.678-->00:10:51.217 bring it into Inkscape, trace it and we have our profile and then if we extrude that profile, we 00:10:51.217-->00:10:56.489 have a blank. Then also if you didn’t thin the profile down at all when you traced it, it 00:10:56.489-->00:11:01.294 probably won’t quite fit into the lock. Maybe it wasn’t traced properly or the image wasn’t 00:11:01.294-->00:11:06.032 completely accurate or the printer wasn’t calibrated properly so I recommend thinning 00:11:06.032-->00:11:10.303 the blank down a little bit to give it some room. Uh you could just try to eyeball it, but I 00:11:10.303-->00:11:14.374 made a program that lets you print a bunch of keys all stuck together like this and it 00:11:14.374-->00:11:19.445 smoothly changes the parameters from one side to another. So you can start it out thick on one 00:11:19.445-->00:11:23.883 side and have it get thinner towards the other and then just snap a part to see which one 00:11:23.883-->00:11:29.789 works the best. Uh and then to model the cuts we can just take the pins out and measure them. 00:11:29.789-->00:11:33.726 The key pins are kind of hard to measure because they all have the same height, so I recommend 00:11:33.726-->00:11:38.765 making a 3D printed measurement tool. I’ll open source mine when I’m done with it and you don’t 00:11:38.765-->00:11:43.202 have to be super precise when measuring pins because you can just compare your measurement to 00:11:43.202-->00:11:48.975 the closest one published by Medeco. Also, the only difference between a biaxial key 00:11:48.975-->00:11:53.813 and a M3 key is this groove that’s been cut out of it so the key can interact with the M3 00:11:53.813-->00:11:59.185 slider element. This element is protected under patent, but it would be trivially easy to print 00:11:59.185-->00:12:03.957 a key with a similar cutout. This element does give the key some legal protection against 00:12:03.957-->00:12:08.428 duplication, but it provides almost zero technical protection. And people have 00:12:08.428-->00:12:13.666 attacked this element at DefCon before. It was shown to be very secure as long as the attacker 00:12:13.666-->00:12:18.671 doesn’t have access to a paper clip or something similar. Um. [laughter] So after some 00:12:20.673-->00:12:25.678 tweaking and trial and error, I was able to make a working Medeco key [audio breaks] 00:12:29.115-->00:12:33.686 sticking out and it won’t go back in unless the correct key is in the lock and here it is 00:12:33.686-->00:12:37.590 with the correct key. It’s a little, yeah. [applause] Um, so that really wasn’t all that 00:12:37.590-->00:12:40.293 hard, uh the process would be exactly the same to produce the Knox key to my city. This means 00:12:40.293-->00:12:42.895 anyone who has access to one of these locks and a good 3D printer could produce one of 00:12:42.895-->00:12:46.165 these keys. Also, if someone really wanted to get a hold of one of these locks, they 00:12:46.165-->00:12:48.468 wouldn’t even need to buy one. When these things are properly installed, they’re really tough 00:12:48.468-->00:12:51.237 to remove if you don’t have the key. Like, good luck getting that thing off. But they’re not 00:12:51.237-->00:12:53.539 always properly installed. [laughter] Here’s a Knox box on a chain link fence, so anyone 00:12:53.539-->00:12:56.743 with some wire cutters could take that thing. Let’s see. It would also probably be pretty 00:12:56.743-->00:13:03.516 easy to take one of the padlocks, if someone had some bolt cutters or lock picks. It 00:13:03.516-->00:13:08.521 would be pretty hard to pick the Knox padlock, but what about that other lock. What if someone 00:13:23.503-->00:13:28.508 just left one open? That lock is available to anyone that has access to a wrench or a pair of 00:13:36.582-->00:13:41.587 pliers. I took this photo about 8 months ago and it’s still like this today. Uh I’m releasing the 00:13:43.756-->00:13:48.795 program I made for this. It’s on GitHub right now. The repository is called Gatekeyper. It’s a 00:13:48.795-->00:13:53.766 couple hundred lines of OpenSCAD code designed to help make keys for locks without requiring 00:13:53.766-->00:13:58.371 access to the original key to begin with. It’s nice necessarily for Medcos, but it 00:13:58.371-->00:14:03.042 can reproduce all of the elements of a biaxial key. Unfortunately I’m not releasing 00:14:03.042-->00:14:07.480 a version which can do this cut out for the M3 slider, because that’s still under patent and 00:14:07.480-->00:14:12.118 I’m not entirely sure if it will do that, but some could modify this program to include that 00:14:12.118-->00:14:18.191 characteristic. So check it out if you’re interested, but please don’t mess with locks that 00:14:18.191-->00:14:21.828 aren’t yours. I’m not talking about this because I want people to start breaking into 00:14:21.828-->00:14:26.199 buildings, I’m just trying to show that these are a security risk. I’m also not trying to 00:14:26.199-->00:14:30.803 talk trash about Medeco, I think the M3 is a very nice lock. I just don’t think it should be 00:14:30.803-->00:14:36.976 used for this application. So how could we improve these? Knox could try switching to a 00:14:36.976-->00:14:42.448 different mechanical lock, but then people like me would just do the same thing to that one. 00:14:42.448-->00:14:46.853 Uh there are some keys which are a real pain in the a*s to duplicate, like the multi-lock 00:14:46.853-->00:14:52.291 interactive or the Evva MCS, but you’re never going to stop people from recreating chunks of 00:14:52.291-->00:14:56.963 metal. I think the best way to avoid this kind of attack would be to avoid key escrow 00:14:56.963-->00:15:02.068 altogether. I think the biggest flaw in the Knox system is that all of the locks in each area 00:15:02.068-->00:15:07.039 are identical. I can reverse engineer my Knox box and gain useful information about my 00:15:07.039-->00:15:13.212 neighbor’s Knox box or the hospital down the street or the bank. Things might be more 00:15:13.212-->00:15:18.084 secure if we switched over to electromechanical locks because electronics let you make it very 00:15:18.084-->00:15:22.455 difficult to extract secret information, since you have challenge response and all that 00:15:22.455-->00:15:28.194 fun stuff. It took years for the Desfire EV1 chip to get broken by a differential power analysis 00:15:28.194-->00:15:33.633 attack. And that’s a lot longer than it took me to make a Medeco key, but the most secure way to 00:15:33.633-->00:15:38.404 do this would be not to store any secret information in the lock. Each lock could have its 00:15:38.404-->00:15:44.243 own unique credential. That way if I reverse engineer my lock, I would have no useful information 00:15:44.243-->00:15:49.248 about my neighbors credential and I think that’s how it should be. And it would be much harder 00:15:49.248-->00:15:54.854 to do stuff like this. Uh there’s a very neat combination lock called the RKS which is 00:15:54.854-->00:15:59.826 like a very tiny safelock that’s dialed with a robotic key. Uh if they use something like this, 00:15:59.826-->00:16:03.763 each building could have it’s own unique combination and they could just load them onto the 00:16:03.763-->00:16:10.036 key when they need to. Knox also recently announced an electronic of their product. Coincidentally 00:16:10.036-->00:16:12.672 they released the promotional video for it. It’s a completely electronic system, kind of like 00:16:12.672-->00:16:14.674 the Medeco XT. I don’t know how they’re doing the electronics, but they say the key can hold 00:16:14.674-->00:16:16.676 100 codes. That’s not very many, so it leads me to believe that they’re not doing away with key 00:16:16.676-->00:16:18.678 escrow altogether. Just making it electronic. So you’re probably wondering what if 00:16:18.678-->00:16:20.680 someone hacks the electronics? Wouldn’t that be really bad? Well, don’t worry, according to 00:16:20.680-->00:16:22.682 Knox, it cannot be hacked. [laughter] They say it is a completely hack proof system. 00:16:22.682-->00:16:27.687 They also say that it can’t be hacked via RF or Bluetooth, which kind if makes sense given 00:16:49.041-->00:16:55.915 the fact that it doesn’t use either of those things. [laughter] Um. But until we do 00:16:55.915-->00:17:00.887 get these 100 percent hack proof locks, what can building owners do to mitigate key duplication 00:17:00.887-->00:17:06.459 attacks? Knox does offer to sell them with a tamper alert, which is nice. Uh it’s got two 00:17:06.459-->00:17:11.063 buttons, one is detect the box coming off of the wall and the other is to detect the door 00:17:11.063-->00:17:15.268 being opened. You hook the up to your burglar alarm so it can go off if someone messes with the 00:17:15.268-->00:17:20.306 box. This is a nice feature, but it’s almost never hooked up. Pretty much nobody uses these 00:17:20.306-->00:17:25.177 things. They probably should though. The tamper alert seems to be pretty well designed, but 00:17:25.177-->00:17:30.182 on the residential 3200 model, Knox was kind enough to include a drain hole on the bottom. This 00:17:32.318-->00:17:36.289 allows me to just hold that button down with a bent piece of wire and defeat the tamper 00:17:36.289-->00:17:41.928 alert. Here’s what that looks like from the inside. Here’s the button and I go in and grab it 00:17:41.928-->00:17:47.800 and I can open the door and the button stays down. And if I let go, it pops back up. Knox’s 00:17:47.800-->00:17:52.571 website says that the tamper alert provides highest security and I really hope this isn’t the 00:17:52.571-->00:17:58.511 best they can do. Uh so if you are using that switch, maybe don’t get one with an exposed 00:17:58.511-->00:18:03.783 drain hole. Also, have cameras pointed at the box, don’t rely completely on locks for your 00:18:03.783-->00:18:09.255 security. Get an alarm and maybe don’t put your alarm code in the box. I know you’re supposed to 00:18:09.255-->00:18:13.960 but if your building is on fire or something, I guess it’s not a huge deal if your burglar alarm 00:18:13.960-->00:18:19.332 goes off. And as for long term solutions, I think we should be switching over to a system where 00:18:19.332-->00:18:24.670 this is just intrinsically not an issue. I’m not saying this is a huge issue, but just that we 00:18:24.670-->00:18:29.775 can do better going forward. If you’re interested, check out the GitHub page for helpful 00:18:29.775-->00:18:35.214 resources and programs I used. Also, huge thanks to the Electronic Frontier Foundation 00:18:35.214-->00:18:40.486 for answering some of my questions about this. Please go do- go donate to them. And thank 00:18:40.486-->00:18:45.491 you for listening. I hope you found this interesting. [applause]