Thanks for coming out. This is our talk, Unlocking Doors from Half a Continent Away. I hope you have some fun. My name is Trevor Stavato. I'm the founder of a small cybersecurity company up in Canada called Loudmouth Security. I've been doing offensive stuff for, I think, I counted about 15 years now, but I just stopped counting and put 12 plus in the slides. My biggest personal or professional achievement, it was winning a DEF CON Black Badge back at DEF CON 26. Thank you. Hi, my name is Sam Haskins. I'm a hacker working for Loudmouth Security. I'm also a current computer science student at Carleton University up in Ottawa in the computer and internet security stream. I've been hacking things for a long time. I've been hacking since I was 12, at least. I have two CVEs from ages 16 and 19. That was just last year. This is my second year at DEF CON, and I'm really excited and happy to be here. I'm just a little bit scared. All right, so we're going to be talking about physical access systems. So just to give you a quick background of all the components, you have a card that has the credential on it. The reader that's going to read that credential off the card. Send that information back to a back-end access controller that will validate that credential, make sure it's valid for the door it's trying to open. If it is, it'll send a signal to the lock, opens the door, opens Sesame, you're golden. We're going to be focusing mostly, well, entirely on the card to reader interactions. And in that space, there's quite a few technologies that have been a part of this. And we'll go through some of them just for history's sake, but our attack is going to be on some of the newest technologies. My Fair Deathfire and CEOS. So the purpose of physical access, what it's trying to do is it's trying to validate that there's a physical presence of a credential at a specific time. So that's what the reader is trying to do. And so because of that, there's some ways that we have come up with, people have come up to attack it. The first one is the most basic card cloning attack. If you can see a card, capture the data off of it, write that to a new card. Present that to a reader. It has no idea that it's a different card. So you have a duplicate and you can authenticate as the original card. A kind of offshoot of that one is a downgrade attack. So if you have a technology that can't be cloned, but you can read it with a standard reader, you can take the data that it's trying to send to the back end and code that on a lower frequency or lower security card. And if the reader will accept both, then you've duplicated the card just as effectively. The other category that I don't see very much in the physical security space, but we just put it in for posterity, is the replay attack. So if you can capture a sequence of messages between a card and a reader and then replay that, you may be able to trick a reader into thinking that there is a credential there at that time. And then the final one, the one that we're going to be talking most about and doing the demos of today, is the relay attack. And you might be familiar with this in the space of car thefts, where people are putting readers up next to your door and trying to relay the signal from your key fobs to your car. The same kind of thing that we're doing with RFID cards. We're going to try to relay an RFID card over a very long distance and just show you how that can be done. So to give you some context about how we got started down this path of research, it's good to know what the history of access control technologies are and what the flaws were that kind of led them to where they are today. So one of the original technologies, the HID Prox, a very simplistic technology. Once the card got energized, it broadcasts its ID. Anybody around can listen to it. Super insecure. There's no encryption on it. You can buy a reader from Amazon for very cheap. Fun fact, my very first DEF CON was DEF CON 21. I went to go see the Bishop Fox talk on the task force. He was a classic RFID thief where he took a garage door reader, it was a high-powered garage door reader, and basically tagged onto the data line so he could record the card data. But that extended his read range from a couple of inches to a couple of feet. And he would walk around with that in a briefcase and collect cards. It's a pretty fun talk. I still have the piece that I got from it, and it kind of inspired some of the stuff that moved me forward into this talk. So HID realized, that wasn't a good idea. So they came up with another version called the HID iClass. And it was designed to protect card cloning replays. The way they did that was they had a key between the card and the reader, a shared key that only they knew. HID created one shared key between the card and reader for most of the systems that they released. If you wanted to have a special key, you had to ask HID to create a new one for you, and they called that the Elite Key System. So only your readers, and your cards, would use that shared key. And it was done through a proprietary cipher that they created, which was then reverse engineered by some researchers. And they came up with a key recovery attack, where you can recover the keys of any, not just the standard, but even the elite keyed readers. So now it's trivially simple to create a copy of an iClass card using things like the Proxmark. Another kind of entry in the mid-range RFID is the Mifare Classic. So we don't see this very often used in access control, but it's kind of the precursor to the Desfire EV1 that sometimes does get into access control. So we thought we'd throw it in as well. It uses a different mechanism. It has keys for each sector, and you can have two keys that you can define as a read or a write key. But again, they used a proprietary algorithm for that crypto. And again, it was reverse engineered by a team of researchers. So very easy to copy and clone Mifare Classic cards. I think this is about the point where both HID and NXP, who make the Mifare cards, kind of realized that maybe making proprietary crypto was not a good idea. And you can see that in a lot of their marketing about the new technology. So the new one for HID is CIOS. And Mifare... NXP came out with the Mifare Deck. It's called Desfire. And there's a couple of variants of that, EV1, 2, and 3. And so they all use industry standard ciphers. And the worthwhile thing to note is that EV1 came out in 2006. So 17 years since EV1 came out in CIOS after that in 2012, there's been no public techniques disclosed to clone a CIOS card. The only attack that is currently known... Well, before what we're going to show today, I guess, is the downgrade attack. So if you have a CIOS reader that has a standard key set and your card is in the standard key set, you could read the data off the back end, program that onto a low frequency or a lower security card, and create a duplicate that way. But that can be easily defeated by using elite keyed systems, because then you would have to have a reader that has that same elite key. So if you're targeting a facility, you'd have to go and rip that reader off the wall, and I'm pretty sure they're going to notice that. Or the other thing they can do is they can configure their readers to only accept the CIOS or DESFIRE cards. So if you clone it to a low frequency or lower security card, it's useless because the reader won't accept it. Now you might come into situations where they have different configurations around the building. In a loading bay they might use a dual frequency reader, but most often the secured, protected areas of a high security building are going to be protected by elite keyed CIOS or high frequency only cards. And that was actually the scenario that we faced when we were doing a red team engagement. So that's what led to the motivation. If we can't break the crypto, we go for a relay attack instead. And I'm going to pass it to Sam to talk about how we did that. Thank you. So first I'm just going to talk a bit about the relay attack scenario, so what this would look like from an attacker deployment. So basically you're going to send one of your guys to stand besides a legitimate employee of the place you're trying to access on public transit or some other environment like that, and then they can hold a Proxmark fairly close to the guy's pass. Then you send one of your other guys right up to the door and just badge in, and you need some way of communicating between the two Proxmarks. We use the internet as a backbone, which is super convenient because it's available everywhere with cell networks and stuff, but it theoretically could be anything there. So here's the architecture of our original attack here. The first version used laptops instead of mobile devices. We've since migrated to that. But as you can see, we have the real card and then two Proxmarks acting as a fake reader and a fake card. And then if you follow that green line there, messages go from the real reader all the way to the real card, and then responses go all the way back. You repeat that about 10 or 12 times or whatever, and then the door opens. And even this original attack did use, over the internet, we had a web socket connection between the two laptops. And in this original attack, we also used Bluetooth between the laptop and the Proxmark just to get them a bit further apart and not have to run wires. So because all of the messages are generated by a real card and a real reader, the contents are guaranteed to be correct. If they weren't, the system wouldn't work in the first place, and the legitimate cards would not open the doors. So the only way that readers could detect our attacks is by detecting timing variations. And that's because the round trip time of request response over about an inch between the legitimate scenario versus Ottawa to Vegas is significantly shorter. So we were investigating, can we make the reader's support longer than normal timings? And it turns out that we can. There's a few mechanisms. So all of the high frequency cards that we've discussed so far, so the 13.56 megahertz ones, are based on ISO 14443 TAC4 type A, or just 14A since that's a lot of letter soup. And most access controls would be based on the standard. There's a few that aren't, but most of them are. And this is analogous to how HTTP is built on top of TCP. This provides a messaging layer that the application-specific data would travel over. But before any application layer data, so the CS protocol or the DSR protocol, before any of that happens, the card and the reader must exchange parameters in what we call the 14A handshake. And this is both documented very nicely, it's an ISO standard, but it's also not encrypted or authenticated at all. There's a 16-bit CRC on some parts, but the details of that are public, so we can't mess with that. So let's have a quick look. So this diagram here shows a real handshake that we captured between a real CS card and a real reader. You don't have to understand most of it, the spec is about 100 pages, but there are a few parts I'd like to highlight here. So the first message I'd like to highlight is this UID CLN message. Now, the standard actually has a mechanism for the card to give a UID to the reader. CS doesn't use this because it's completely unauthenticated, as said earlier, but other mechanisms do. But CS actually just provides a random value each time, so you can't even use this with readers who don't support the CS protocol, just by falling back to that number. And then the other thing I'd like to highlight is that ATS message there, and specifically that blue byte, which is interface byte TB1. ATS here is answer select, with our ATS being request answer select. And the important bit of TB1 there is the frame waiting time integer, which is coded in the high nibble. And that's the frame waiting time, and I'll explain what that is in just a second, in accordance with that little equation there. And the FWT tells the reader how long to wait between frames. So after the reader sends a request, it will wait that amount of time before expecting a response from the card, and if it doesn't receive one at that point, it will usually restart the entire authentication attempt from the beginning. However, this is unauthenticated, it's sent by the card, which we are pretending to be, and we can mess with it. And if you notice at just the end of that equation there, there's that exponential term, we can make that go pretty high. So after the 14a handshake is complete, it goes into the CS protocol, which is a bunch of random bytes, and I have no idea what they mean, but who cares, because these are generated by a real card and a real reader, we know they're right, we just need to get them from point A to point B. Yes. A lot of the messages in the 14a handshake are sent before that ATS message, so the modified frame waiting time won't apply yet, and therefore we can't relay them. The latency over any internet connection, even basic ethernet, will be far too long. It's messed up by print statements, in fact. So that initial 14a handshake does have to be handled on the prox marks themselves, but thankfully it can really just be hard-coded for the most part. It doesn't really vary, but we'll get into a few more details on that later. And as for how long we can get the reader to wait between frames, the FWI to its highest value of 14, we can make it wait 4,949 milliseconds, which is almost 5 seconds. I'm not sure why that's supported by the standard, because I don't see a real use case, but it's very convenient for us. There is another technique in the 14a standard that we can use to bypass the RAM trip time check, which is waiting time extensions, and that's a mechanism that applies to just the next message, or subsequent messages. But it can also be repeated, which is nice. So theoretically, if you keep the fake card by the reader for 20 minutes and it just keeps sending these, you could have 20 minutes of time. But in practice, at least with the readers that we tested, we found it was less reliable, so we're mostly relying on modifying the FWT. I think a big problem with the WTX is it does need to be sent for each message, so if it's missed once, the entire authentication attempt fails. So our original design was implemented as an extension to the already existing and open-source HFVBLAE Proxmark Standalone Mode, which was originally written by Salvador Mendoza. That was to relay credit cards, actually, which was pretty cool. And we made some changes to allow protocol, or really any protocol, instead of just credit cards, and also adding the long-range internet component, instead of just over Bluetooth like it was originally. And this original design was strongly coupled with the BlueShark Bluetooth add-on. Messages were conveyed from Proxmark to the laptop, and then sent over IP. We did have a lot of success with this design. The big highlight being unlocking a door in Ottawa with a card in Florida. Because my colleague over here has a vacation home in Florida, so we sent him down with a card and just tried that out, and it worked after a few tries. There were, however, some fairly major reliability issues in this original design. So the BlueShark add-on does come with an integrated rechargeable battery, and we did like that design at first, because it's a lot more convenient for real deployments, like actually standing beside someone on the bus and trying to relay their card, than running a cable up their sleeve. You get to put it a bit further away, you don't have that whole cable to deal with. But the ability of the Proxmark that's pretending to be a reader to read the card, which is its job, is very dependent on the battery level. If it's too high, we get bad reads. If it's too low, we also get bad reads. We're not entirely sure why that happens. We think it's related to the voltage level being output by the battery, but we're not 100% sure on that. It did prove very frustrating. While we were developing this, we developed little rules of thumb, like when it starts failing, plug it in for 12 minutes and try again. And that kind of worked, but it wasn't very nice. The other problem was the latency. We can make the reader accept ridiculous amounts of latency, but on the card side, real cards are designed under the assumption that the reader will respond within at most a few milliseconds, and typically much faster. We blow that assumption out of the water by several orders of magnitude when we're doing this over longer ranges. We find that the card sometimes forgets that it's supposed to be in the middle of an authentication attempt. This happens increasingly often as the latency increases. This isn't necessarily a deal-breaker by itself, because it just means you need to retry from the beginning. So if your guy's still standing beside the guy in public transit, you're good to go. But maybe it's a little suspicious if you're standing beside a reader for two minutes waiting for the door to open. Not the best. And different cards could be more resilient to this. Most of our observations here were with CIOS cards in particular. We actually only tested this one time earlier today before we went to sleep. It was hard to source a card. So between that and the battery issues, the initial design was not reliable. It was usable, not really reliable, but usable within the same city, and even then I'd say this was a practical attack that higher security, higher value facilities would be more concerned about. But it was much harder to make it work over longer distances. And even in the same city it wasn't perfectly reliable. So our revised design, we incorporated quite a few changes. So first off, we swapped laptops with phones. Laptop on your backpack is fine, but phone in your pocket is even better. And then more importantly, we swapped that little Bluetooth link there with a serial link. And we're also powering the Proxmark from the phone over that serial link. So we knocked out the battery, and we knocked out Bluetooth. Bluetooth was nice, but Bluetooth Classic is a horrible protocol, and 50 milliseconds of latency on each side, 100 milliseconds total, when Florida to Ottawa is only a 99 millisecond ping. That's almost doubling it, and we didn't really want to eat that, and getting rid of that really did increase our reliability. Additionally, just to operate it over a cell network, where phones will not have public IPs, instead of them connecting directly to each other via WebSocket, we have a little relay server just hosted in DigitalOcean in between them. So the software in our revised design is called HFCardHopper. It's a new standalone module for Iceman's Proxmark 3 firmware. We will be releasing it later this week, whenever I get around to doing a pull request. It's inspired by Salvador Mendoza's HF Replay, the original design, but doesn't share any code. And it has the code to trick readers into using a longer frame rating time. It can relay any ISO on 4443A... 14A-based protocol. And it actually has support for relaying that initial UID and the ATS. That doesn't matter so much for CIOS, because the UID is random each time, but for Deskfire, that UID actually contributes material to later cryptographic operations. So to get it to match up on both sides, you do need to get that right. Now because that's sent over the ATS, we can't actually relay that in real time, because the modified frame rating time won't apply. But it doesn't actually change. When it matters, it doesn't change. So Deskfire cards always give the same UID. So if you just read it once, then transmit it, then the Proxmark can set itself up to emulate that specific card. And that doesn't have to happen in real time, which is nice. And it works with BlueShark, and our custom hardware, which handles that serial link, which my colleague Trevor will talk to you about. Yeah, so as Sam mentioned, we wanted to swap out the Bluetooth module mainly because of the latency issues. So we came up with another module that is USB to UART bridge, basically. If you're familiar with things like the Shikra, it uses the FT232 chip that's in the Shikra. We just modified the design to have a USB-C, which is much more convenient for connecting to modern phones, and then a ribbon cable for connecting to the Proxmark. So we used a ribbon cable to connect to that interface on the Proxmark for a couple reasons. A, we think it's a little bit faster. We're directly connecting to the Proxmark over USART, whereas if you're connecting to the USB on the side of the Proxmark, that's actually an emulated modem, so that would add a little bit of latency. But also, this makes it completely interchangeable with the BlueShark add-on. So if you wanted to use the BlueShark for wire-free, our emulator, the standalone mode, you can connect in with this interchangeably. We did have one little hiccup when creating these and ordering these for DEF CON. It turns out that just casually mentioning that you need a 14-pin, 0.5 millimeter spaced ribbon cable adapter is not enough to make sure it actually gets ordered properly. So, you know, lessons learned. We managed to get it reordered, rebuilt, props to one of my colleagues who actually disassembled half a dozen of these and if you see one of these, if you come up, I'll show you. There's a lot of tiny little components in here. He took every single component off and resoldered it onto a new board with the right pin header. And that's the board that's being used in Ottawa right now for the other side of this demo. So, appreciate that. That was a lot of hard work, I know. And then the other thing we added is a custom Android app. So, to make it easy to interface with the Proxmark, we have an Android app that will bridge the communication between the FTDI and therefore the Proxmark and the relay server. And it supports card or reader modes. You can alternate it. And it supports COS and Desfire cards. And you can adjust the frame rating values for your specific target. And it also will handle hardware resets because we came across a lot of those. We needed to build that in to be able to quickly reset and start over again. So, it's quite easy to start over with that. Today it is my first Android app. I've never done this before. And we kind of just went function over style. I know it's pretty ugly, but it works. Alright, so let's go over some of the results before we get into the demo. So, we've tested this on a variety of different HID readers. So, the first couple are older generation HID multi-class readers. The RP40 and RPK40. A couple of different models. But these are ones that will accept low frequency and high frequency cards. So, there is some requirement for them to adjust the frame rating time because older cards are a bit slower. So, it makes sense that adjusting them was a successful attack. But the one that was a little more surprising was the Signal readers from HID. Which are their latest and greatest readers. And there's three variants of them. 00, 0102. And that just the difference in those is the protocols that it supports. So, 01 is kind of like your multi-class. It will support the low frequency and high frequency. Sorry, that's the 00. The 01, I think, is the only CEOS protocol. CEOS and Desfire. And then 02 is CEOS, Desfire, and smartphones. So, that one's the one that to me is surprising that the frame rating time attack works on because especially for the 01 and 02 they're only talking to high frequency cards. That are fast, quick responding cards. There's really no need for them to have to accept an increased waiting time. In terms of the card technologies most of our research was focused on CEOS because as I said this was motivated by a specific engagement we were trying to get into a building. But we have since as of last night at 1am in the morning acquired an EV1 card and compatible reader and were able to test and it does work for EV1 cards as well. The other ones that we haven't tested with and we want to are the EV2 and EV3. The problem with that is EV cards are not super common in HID access control systems. And so getting an EV1 card or an EV2 card that is programmed with an HID secure identity object, which is the object that they write in the card for the reader to unpack and pull the identification out of so to get a card coded for that is quite challenging and quite expensive. So we haven't come across those cards yet. But the interesting thing about those is that NXP does have a patent for being able to do the proximity check for communication devices. So based on that, these two technologies should be immune to our relay attack because they should be able to detect the proximity of the card but it's something we would like to verify and try for ourselves. In terms of distances, we started out in our lab across the room 12 feet. One of us took the readers home went back from our house to the office tried that and then as Sam mentioned when I went down to Florida I took the card with me we relayed it from Florida back to Ottawa which is about 1400 miles of distance that we're going across. And then earlier today in the green room we finally got a successful test of doing and I say finally got a successful we just didn't have an opportunity because production issues on the card hoppers it actually worked quite smoothly, quite well so that's about 2400 miles now we've gone. Can we do it on stage? Is that possible? So I better text my colleague on the other side who's waiting for us to say we're ready. So I'll tell them to join now. We also would like to test this further so if there are people here that are interested in collaborating with us if you live far away, Brazil or other places we can try this out and see how far we can push this distance come chat with us afterwards. Alright, so we are good to go they're already on their side let's jump on Hello! Hello! I don't think the sound is working Welcome Noon and Liz to DEFCON Everyone say hello Alright, so Liz is just going to demonstrate right now that she can't get into the door it's locked and just presenting the reader that she has to the door is not going to work because we're not relaying the card at this point so if she puts it up against the door if you put the thing up against the reader it doesn't work because we need to relay the card Alright, you ready to go Sam? Liz, you ready to go? Give me a thumbs up when you're ready. Give me a thumbs up Let's see I think we need to do a reset on her side one sec, sorry This is what happens when we do it live, right? She's working with the pre-production version the one that my colleague put together by hand so it's not the most production ready system We'll give her another second here Alright, she's good to go We're good to go Alright, go for it Sam Put it closer to the reader Yep Alright, we're going to try it one more time If not, we'll switch Just pull back Liz and cancel, we'll try again Give me a thumbs up when you're ready to go If this doesn't work we'll switch to the video of us doing it previously in the green room, just to prove Okay, I think she's good And it's not working Alright, well I guess that's where we're going to jump to video Demo gods prove too much for us Thanks anyway, Liz Noon, thank you Alright, so we kind of planned for this so that's fine. So this is the this is what it should have looked like So when she puts it up to the reader it does take some time because we're relaying these messages one at a time over the internet so it's not as quick as normally when you push it up against the reader but after a certain amount of time it does work, and she can open the door So on the phone side this is what you would have seen if you were looking at the phone So we connect the card hopper Card hopper is the term we're giving this board We connect it to the phone We put the phone into reader mode We don't adjust the frame waiting time because it's fine, and then we start seeing all the the messages flying back and forth You can see there's quite a few of them going back and forth We don't really care what they are and that's the at that point we're done We've opened the door So yeah, I said we don't care about the waiting time We default it to 14, which is the max So we're just leaving it at the max and it's working fine On our side here this is what you would see So this was us in the green room So I put the card up against the reader and wait and it goes through that back and forth And then boom And then boom We're done So it does take more time It is a little bit more conspicuous It's not necessarily the stealthiest of attack But hey, being able to relay a card from here 2,400 miles away I think is pretty good So A couple other slides we wanted to show The prevalence of this to different technologies So unfortunately there's a weird trend in the access control industry that they don't necessarily move to the newest technologies right away We're still using a lot of the old technologies So the 125k HID proc stuff I mentioned still has about 32% of the market Very small market percentage for the CEOS and even smaller for some of the MyFair cards individually But it's interesting to note that these technologies have been around for a while CEOS came out in 2012 EV1 in 2006 So It's unfortunate that the industry has not adopted these as quickly as they probably should have Right, so the other point that we wanted to make was that most of the ones that are currently in use aside from the EV2 and EV3 are vulnerable to some sort of attack at this point So most of the access control industry is still vulnerable So I also want to talk a little bit about HID's response So we did a responsible disclosure of this through Bug Crowd We disclosed it to Bug Crowd on December 9th of 2022 It was triaged by HID on January 17th and then we got their final response on March 10th I'm sorry I'm not showing the presentation mode That's why Alright One of the recommendations we made to HID was that they should limit that frame waiting time integer not accept values over what are strictly necessary and they didn't like that idea because it would put them out of compliance with the ISO spec and it would impact their customers needs for backward compatibility I don't know any customer that needs a 5 second waiting time for backward compatibility but that's what they felt like The other comment that got to me a little bit was that the majority of their end users do not see relay attacks as a viable threat That was the motivation for coming here today for doing the additional work of creating the pieces We wanted to show that this is a viable feasible threat Something that could be done with simple technology like Proxmark a small little add-on and the relay server The one comment that they did make which I think has some good validity is that their end users that are concerned will typically add a second factor PIN or biometric and some will use their mobile credentials But the one problem that we see with this is Okay, now everybody has to enter a six digit PIN Can you imagine the lineups going in and out of that building Six digit PINs or biometrics are good but they're not always the most usable or user friendly especially when you're trying to manage large amounts of people going in and coming out Alright, so that's the end of our presentation We have some extra of the little boards the card hopper boards that we printed the correct ones now So we also run the embedded CTF and so if you come play in the embedded village CTF the three teams will get one of those boards So come and play Or if you're interested in collaborating if you want to try testing this at further distances we're happy to share with you a card and a board and we can see how far we can push this Come chat with us at the side afterwards and thank you very much Any questions? They turn it back on Okay, you asked whether there's a subset of protocols that are supported by this So basically any ISO14443A um any technology that uses that which is most high frequency cards um they would be vulnerable to this kind of relay attack because of that So the most common that we come across in access control are CEOS and EV1, 2, and 3 but I'm sure there are other ones we're just not super familiar with