Guys, enjoy. Mmm, breakfast. Alright. Morning DEF CON. Thanks for all coming. Thanks for having us. This is Badge of Shame. Hey, I'm Dan Pietro. I'm a senior security engineer at Bishop Fox. Before that I was a long time pen tester here at Bishop Fox. Yeah, hi everyone. I'm the new speaker here. My name is David Vargas. I'm a senior consultant with the red team at Bishop Fox. Cool. And we're going to be talking about breaking into secure facilities. So this actually all came about as a part of a pen test here at Bishop Fox. Breaking into secure facilities is easily one of the coolest things that we get to do. And if you're already familiar with like breaking into facilities, there's like an ESP key. We'll kind of get into this a little bit more as a tool. And we tried using this on a pen test one time. It just like wasn't working and we were super like curious as to why. It turned out that we had an OSDP installation. We hadn't actually seen one in the wild at that point. And so like I've got a background in cryptographic protocols. Figure why not take a look at this thing. And this presentation is the result of that. Cool. So let's get into it. So one of the other things you should know about me is that I hate slides. But you can't just get away with not having slides. So we made some authentic bespoke one off slides. These slides are like organic. They are allowed to turn fully around in PowerPoint before being used. So you can't export it. So suppose you're trying to break into a secure facility, right? Let's say some undisclosed location in Santa Fe, New Mexico. And you like really want to get into this room, right? It's like very important to you personally. And this room, like a lot of other rooms, has an RFID badge reader that is protecting the entrance to it. Even if you're not familiar with physical security, I'm sure you've seen these things, right? You take a badge out, you sort of beep it to the little thing and it lets you into the room. Cool. So, let's talk a little bit about this. There's lots of ways of attacking these RFID badge reader systems. Some of which we've actually pioneered here at Bishop Fox. This is the Tasic RFID thief. This is a thing that my boss Fran made a while ago. It's basically like a long range RFID reader. So it can like read badges from about like five, six feet away. We developed this cool little maneuver where you like put it into a briefcase and walk up to somebody at Starbucks with like wearing their badge. And you like set it down and then kind of like pull it up and then up onto your shoulder, like the briefcase. And really what you're doing is you're scanning the person from like toe to head, like surreptitiously. This was even featured on an episode of Mr. Robot, actually two I think. And yeah, that's cool. So, the hacking tool my boss Fran made, but the prop in the show I made, we knew the technical advisor for the show at the time and so they just needed a little gizmo that says like, no badges detected. Like when you press a little button. It's just a raspberry pie inside of a plastic case. But that's kind of cool. So, that's not what we're talking about today. We're going to be going over, let's talk a little bit about how RFID badge reader systems work in general because this is going to be pretty important. So on the outside you're going to see three things. You're going to see a door, a lock and a reader. So the reader you present with a badge. So the badge just, at least for passive cards, is just basically a number. It's got a number. Sometimes they're very short too. They're not like big 128 bit numbers or whatever, right? You present the badge to the reader and you're basically just telling it this number. It says here's my, badge number, one, two, three, four. Now importantly, the reader does not perform authentication or authorization in this system. It's not the thing that lets you into the door. In order to do that, it has to talk to a back end controller. The controller is the thing that actually like knows who you are and decides whether you're allowed into this door or not. So the reader then forwards that badge number off to the controller. The controller then says, yeah, sure, this person's allowed into this door and sends it a little like signal that says, flash your green light that says that they're allowed in. Now importantly, again, the reader can't let you in. So it has to have a separate set of wires that is not the same set of wires that like physically unlocks the door because the reader can't control it. Because obviously if the reader controlled whether you could get in, you could just like hack the reader and let you in. It would be super easy. That is not how these things work. Cool. All right. So let's take a look at how everything actually works in the back end. So currently it uses something called the back end controller. It's a little bit more complicated. It's called Wiegand, right? Everything is unencrypted. The card numbers or whatever data just happens to go across the wire. What that means is we can actually make a small device. Right now it's, you know, like an ESP key which you put into the reader. Now what happens is whenever somebody swipes a badge, the ESP key can grab the plain text communication and then we can clone the card. Right? And now we can also replay it, right? We can make our own cards. We can do all sorts of things to gain access to that facility. So that's a problem. And so now comes OSDP. So what's OSDP? OSDP stands for the open supervised device protocol. And it's meant to replace Wiegand. OSDP is built as an encrypted protocol, a secure protocol. It has a couple of other benefits over Wiegand like it's over RS485 which supports multiple readers on the same bus but we'll get to that a little later. Mainly the big thing was that it's supposed to be encrypted. So the same attack we just talked about won't work theoretically. So we started reading about it, right? We started looking into, all right, this sounds interesting. What's up with it? And we came across some very interesting claims. Mainly that it was unhackable as of 2020. And so, you know, that piqued our interest. So we were like, all right, let's take a look at this. So we did a couple of things. To start off we made our own version of an ESP key, a device we dubbed Melon. And so this device just like an ESP key plugs in between the reader and the controller. We also got our hands. David was allowed to call it Melon as long as he said it like Gandalf at least one time. So Melon. All right. And so we got the device and so we got a bunch of readers and we got an Axis A1001 controller. Now everything that we have supports OSDP. So the controller which Dan has over here supports OSDP. We got it on eBay. We got some HID signal 20 readers. So what we expected to see was basically encrypted traffic going across the wire. Let's see what we actually saw. I think the name of the video kind of gives it away, but. Yeah, I did. Here we go. Cool. Yeah. Not encrypted. So what's going on? It's supposed to be encrypted. It's supposed to be encrypted. Everything supports OSDP. Let's see what happened. Well, when we kept looking into it, it turns out OSDP supports but doesn't actually require encryption. OSDP SC, a secure channel extension added to OSDP is what takes care of the encryption. So what does that mean? It actually means that OSDP devices that support OSDP both can choose to encrypt or not to encrypt traffic. And this is going to come playing a role into this a little later on. So let's go to the next slide. Cool. So let's back up a minute and talk about protocol and RS-485 that is underneath OSDP since this is going to be kind of important. So RS-485 is the underlying like physical layer underneath OSDP. It's serial, but it's not that serial. It's the other serial. In particular, RS-485 is multidrop. So that means you've got a controller and a reader and you want to hook up additional readers to this controller. You don't have to like have a separate line out to them. You can hook them all up in like succession like this. You can sort of daisy chain the readers. And importantly in this scenario, all messages are broadcast. So like this is a necessity because of just like not the laws of OSDP but just the laws of physics. Like they're all connected with the same copper wires. And so necessarily if you're going to send a message to like any of the devices, it's going to send them to all of them. So if reader A wants to send a message out to the controller, it has to necessarily also send them out to reader A. So this is not necessarily a vulnerability. It's just like kind of a nice to have. In fact, this is really useful for installers since you don't need to have a separate wire out to every single reader in your entire building. You can kind of daisy chain them around. It reduces the wiring. It makes it actually a lot nicer. This does have a consequence though that if suppose we're back in our undisclosed location in Santa Fe, New Mexico and there's like you know some guard out in front of a top secret door. Like this is the door we really want to get into, right? And there's beards and suspenders. Let's just call him George. That's in front of this room that like is preventing us from getting in yelling something about Targaryens. There might be a second side door that is like not especially secret. That like we wouldn't normally care about getting into. But now you might actually attack this door anyway because it could very well be on the same bus as the secret door. And so if you could listen and sniff badges on this one, you might be sniffing badges to like the rest of the building or you know maybe just the door that you really care about. So. That's kind of a nice little bonus there for attackers. So if red teamers are trying to do this, just find any door and it might be the one you care about. Next is around the client server model of OSDP. This is just kind of a practical thing for the protocol. Which is that in OSDP there's clients and servers. The controller is the client. All the readers are servers. So what that means is that readers, if you wanted to send a message, you can't just asynchronously send a message. It would just get ignored at least. According to the spec it should. And in order to send a message you have to reply to responses. So what this means is that controllers have to constantly pull the readers. In practice this like happens like something on the order of like 100 hertz is pretty typical. Where you see the controller say hey you got anything for me now? No. You got anything for me now? No. And that's how like when you badge in it knows immediately because it's like pulling constantly. This brings us to protocol WTF number one. Something I like to call what do we pain by the bit now? So one of the core functions of a cryptographic protocol is to prevent against replay attacks. So even though it's encrypted, what keeps an attacker from just taking the encrypted packet that has like our badge numbers when somebody badges in, right? And just replaying that packet. Just taking it and forwarding it off to the controller when we want to authenticate. So it's a normally protocols will do this by having your data. Attaching a sequence number to it. So the sequence number makes sure that every packet is fresh. It's live. So it has to either just be monotonically increasing from the last one or it's like the number of days like TCP does this by having like the amount of data increasing the sequence number. There's lots of ways of doing this. But basically the idea is that the receiver knows what the sequence number should be. It's going to be different every time. Keeps you from replaying things along with an HBAC that keeps the attacker from tampering with that data. Because obviously if the attacker could just like modify the sequence number to be the correct one, then that kind of defeats the whole purpose. So we don't have time to get into like what an HBAC is. It's a keyed hash. If you're not familiar with the way to look it up, it's cool. So you might be wondering, alright this sequence number, how many bits does that need to be? Like maybe like 128 bits? Like that would be cryptographically strong, right? You can't enumerate that. That would be really good. Maybe 64 bits? Like that's not bad. That's like the edge of enumeration. Like if you're trying to, you know, brute force something offline, 64 bits is usually the area where you're like, I don't know if that's possible anymore. Like 32 bits? Like that's fine maybe I guess. That's not great. How about two bits? Now I know what you're thinking. Now what you're thinking. Two bits? Those are rookie numbers. We can get that down. How about one and a half bits? Because OSTP actually skips zero in their two bit sequence number scheme. So you start with zero, but then everything going off there just goes one, two, three, one, two, three. So this sequence number exists, but for the purposes of security, might as well not. In fact, I question whether it's useful even for non-security purposes. So let's talk about this HMAC. So OSTP has this system of IV chaining where the HMAC of the previous packet is the IV of the current packet. By the way, we're running in a CBC mode encryption. I can hear the collective groans of all the cryptographers in the room. We don't have time to go over it. It's in CBC mode. Don't question it. So the IVs are sort of chained down the line where every single HMAC is just going to be the IV of the next packet. So this sort of has the effect of providing liveness because like the last packet is going to kind of mutate your current one and so that sort of prevents replay attacks in this kind of like janky sort of set up. But like in practice it sort of kind of works. We're going to have to come back to that. The problem with the HMAC, however, is that we just take most of it and throw it in the trash. So the first 32 bits of the HMAC we keep. And then the last 96 bits we just throw away. The spec even says to reduce the message size and transmission time overhead, only the first four bytes are sent. So that's a problem. Like why would you do this? Like you can't just take like the bits and like reduce the overhead. You know, like those are important bits. Like we needed those bits. You can't just do this. So if we do some back of the envelope math on like what this might look like. So imagine you're just sending badge in attempts with like random MACs, right? Like how long would this take us to enumerate in practice? So that's two to the third. So that's two to the third. That's two to the thirty one attempts on average. Let's assume that we're running at like 115200 baud, which is around the top end of what you can see. I think in practice, technically RS45 can run at 10 megabits. In which case, if you find some installation that's running that fast, then like fuck. But this would be a success after like 35 days. Which is dangerous and sort of scary. Like if you're a defender. But I think as a red teamer, we're unlikely to run that fast. So we're going to really exploit this. Like I can imagine like sending David on a pen test. We're like okay. So we're going to give you a sleeping bag. And you're going to just like hang out in front of the door for 35 days on average. And at some point during that time, you might be asleep. The door is going to beep. And you've got to make a mad dash to it. Because it's going to be open for like three seconds. We have budgets. And I don't think that's going to be within ours. So I think in practice, this is likely not a thing that you're going to see happen. But it's going to be something that you're going to see a ton of. Unless the speed changes. Like if you're running this over a different underlying protocol for some reason that runs at like 10 megabits or like if for some reason your RS45 installation really is that fast, then this could start getting really scary. Next is there's a birthday attack in this. Some of you might have already noticed. So if you just ask the question, like what are the chances that any of these IVs are the same? On average, with only a 32 bit Mac, you're going to get it at about 77,000 packets on average. And what that means is if the data is always the same, like if we're in this polling hack loop, the data is always going to be the same. So our data is just going to loop back around. So like you can actually observe this happening in practice, too. Which is just like bizarre and not a good look for a cryptographic protocol. This isn't a vulnerability as far as I can tell. Because anytime somebody does anything, like if you badge in, it'll perturb the loop and escape you out of the loop and get you into a new loop. Um, but just like this is not a thing that a reasonable protocol should be doing. Where you're just like actually sending the same exact bits, looping back around and reusing IVs is like a thing that has gotten other protocols into a lot of hot water. Um, so like we should just not be doing this. Um, oh and then lastly around this is, uh, the key, not key exchange, um, a key derivation for session keys. So we'll get a bit more into like a key hierarchy that OSTB defines. But the, uh, session keys, the thing that's like actually used to encrypt data, um, only uses 48 bits of entropy from the, uh, backend server. So, uh, session keys are derived by having the controller send the reader a nonce. The, uh, controller then, uh, derives a session key by taking 48 bits of that nonce, for reasons unknown, um, and then encrypting that with the base key, the higher level key. Um, and that becomes the session key basically. And maybe somebody in the audience is cleverer than us and could figure out a way to actually brute force this offline, cause if it were 48 bits you could. Um, but because it's encrypted by the base key, which the attacker in this scenario presumably does not know, um, I don't, I couldn't figure out a good way to enumerate this offline. So. Cool. All right. So let's actually attack this thing. All right. We have some background. We know that OSTB supports, uh, both encrypted and unencrypted connections. So we can do something called a replay attack. Or sorry, a downgrade attack. All right. So let me pause it here, see, explain what's going on. So on the right hand side, we have our controller. So we can see that, um, what it's seeing and we can see on the left hand side, um, the, the communication going between the controller and the reader. So there's a secure channel set up. We can't see anything, right? Everything's secure. We're gonna swipe in. And there's absolutely nothing that we can see. Okay. But let's remember that, again, it supports both, right? So there's sure a way we can mess around with this. So we do it again. This time we try to carry out a downgrade attack. We try to downgrade. And then we swipe in again. And we can actually see the card data. Cool. All right. So let's see what we actually did there to make that happen. To decide if it can establish encryption or not, there's a couple of things that happen first. So the controller first asks the reader what its capabilities are. And the reader replies, its capabilities. The capabilities can be a number of variables. So, for example, if you have a So it is a very interesting thing to us. So it can say, maybe we're talking to a fingerprint reader, right, or an IRA scanner and it supports biometrics. Maybe we're talking to a keypad. It's a keypad entry, so the capabilities are the keypad. The one we're interested in here is communication security. So the communication security bit actually tells the controller whether or not the reader supports encryption. So let's insert our device in the middle here and let's wait for that capabilities request. And now, when we think about the information of the we actually reply, we're going to switch that communication security bit from a one to a zero and so the controller assumes that there's no encryption set up. It doesn't support encryption and we can carry on with everything unencrypted. All right. That brings us to protocol WTF number two. Stop making null ciphers. So Dan explained a little bit about how what happens when a secure channel is set up. There's basically a four step process in which the controller and the reader mutually authenticate to each other to make sure that they each have the same encryption key. Now, as a result of this, when everything works out, there's four message types that can be sent. SES 15 and 17 which are command from the controller to the reader or replies 16 and 18 which are, you know, replies from the reader to the controller. If you read the spec, SES 15 and 16 say that the controller and the reader even though there's a MAC applied, the data is still unencrypted. Which is wild, right? We're supposed to be having a secure channel set up with encryption, but yet the data fields are unencrypted. So that means that in a fully secured session, there is a possibility that the data is just going to go over the wire. Now, it has a MAC applied to it, so we can't just replay it. But, you know, we can still just in the case of car data, watch it, clone it and just authenticate to the readers. Now, to be fair, the spec does say that those message types are not meant to be used with any sort of data, but then why have them in the first place, right? All right. This moves us to demo number three, something we like to call the install mode attack. Ominous sounding. It's going to already play. Okay. Cool. So what you're going to see here on the right is the controller that is going to be running in a terminal. This is an intentionally vulnerable controller software that we wrote that's basically just a lib OSDP sample code, basically, actually. And on the left is an attack script that we're writing. They're going to be performing something we call the install mode attack. So we're going to run this with just a dash dash install flag, run up our server. And this time, we don't just capture a badge number, we actually steal the encryption key right out from underneath the server. So this is just a So, how the heck does that work? Let's talk about it. So, OSTP has something a bit like the SSH security model, which is like a one-time insecure setup. This is not by itself in a vacuum a bad thing. We don't care about, we don't mind SSH's security model so much. The problem is that this has to actually be a one-time insecure setup. Like if somebody told you they found a way of hacking SSH and all you have to do is man the middle of the initial connection and be like, yeah, that's kind of built into the model. That's not clever or anything. The problem is when this turns out to not be so one-time. So, controllers and readers in OSTP have this kind of quasi-official install mode that is specified in the spec, but it's exact semantics aren't exactly laid out, like when are you supposed to do things and how are you supposed to behave. A lot of that is just sort of left up to the individual implementers. So, in this install mode, as the name suggests, this is not the exact packets, but the reader is able to ask it like, hey, what's the encryption key? I'm just trying to get set up here. And the controller just goes, here you go, here's the key. Because like that's what the install mode is supposed to do. The problem happens when this install mode persists. If it happens to last more than just this like short ephemeral moment when you're initially installing a reader. So, if you happen to have a controller that is just like hanging out in install mode persistently, then an attacker can just show up on the bus, ask the controller, hey, what's the encryption key? I'm a reader. And it will just respond to you and say, here's the key. And the keys in this case are unique per reader controller pair. But that ID is just a public ID. In fact, it's usually written on the reader controller. So, it's written on the back of the reader itself. So, like you could just lie about your ID and get the key for any reader on the building. So, this brings us to this point of like where exactly do these vulnerabilities lie? So, we've been kind of picking on the protocol and I think there's a fair number of things to pick about the protocol. But like there's lots of other places depending on how you want to kind of squint and look at it that the vulnerabilities could exist on. So, you could think of this as a library bug, some of these. Like whatever the library does is probably what's going to be out there in practice, right? Like who is going to go out and roll their own library just for this? So, like you could argue that like the behavior of the popular libraries is the thing that needs to change here. That's where the fault really lies. You could argue that this is a configuration problem. A lot of these vulnerabilities can be fixed in configurations. Like you should configure your controllers to not sit around persistently in install mode. And maybe that's not crazy. You could argue that it's a documentation problem. That like the exact behaviors of how these things are supposed to work is like maybe not documented well or maybe it is but nobody knows where that's at. And so, like maybe better documentation could get us out of this problem. You could argue that this is an implementation bug. That the individual like implementers of the controller hardware are responsible for setting these things up properly and what admin is going to go out and tinker with the settings of the fine grain level. Like whatever is out there in implementation is probably what's going to be out there in practice. You could also argue that this is a marketing problem. That a lot of devices such as our AXA 1001 just say that they support OSDP but that's not like a legally defensible like term. Whereas there's actually an OSDP verified like program where you can put your hardware into the people that make the specification and they can like certify it as not like secure in some abstract sense but at least that it like does the protocol and does all of the protocol like the encryption parts. Where like you might just have an entire OSDP set up at home. Probably not at home. At your office. And think like I'm all secure. Like I bought all this stuff. I spent a whole bunch of money upgrading it. And you could very well go back to your office and discover that none of it is encrypted. It's all just plain text. And that's not great. And that's also partly a marketing problem. So, it's pretty much the same thing. It's not pretty easy to see how these vulnerabilities could just pass by people. Because no matter who you are in this setup, there's always somebody else you could possibly blame and think like, well, it's not really my problem. It's whoever is going to configure the stupid thing. Okay. Let's step it up a bit. Let's look at what happens in when everything is set up properly, right? And how the secure channel is supposed to work. So, this is protocol what the fuck number three. Oops. Okay. So, this is what we expected of message 17 and 18. We expected to see the header in plain text and then the command bytes and the data encrypted. But this is what we actually see. So, the only thing that's encrypted in a fully secure channel set up is the data. Now, why does it matter? Why is the command byte important? Well, the command byte is what tells us what the message type is. It tells us what the message type is. It tells us what the command was, what the reply is. So, we know what kind of data it is in that packet. Some of the interesting ones we want to look at are the OSDP raw. All right. This one contains raw card data. So, we see it going over the wire. We might want to look at that packet a little more. There's the FMT packet which has formatted card data. The keypad is self-explanatory. The bioreader, I keep going back to the bioreader ones because they're just very interesting to me. I haven't had a chance to poke at them. Because they have like one of theографical commands and so hoping that's the next step here. Okay. And then there's the OSDP keyset message. So the keyset message is the command from the controller to the reader where the session base key is delivered. And basically then the encryption key for every message is derived from the session base key. So we can get our hands on that base key, we can compromise the communications. Which brings us to the next demo. The weak keys attack. Okay. So once again, we have the controller and our attack script here. And we're testing for weak keys. And we just found a weak key. So we find the weak key, we can decrypt the packets now. And we can intercept that keyset message. Cool. So what happened? First off, before I dive in, this is not a protocol specific issue. This is something of an implementation issue that we've observed with a lot of open source libraries. And it's not a protocol specific issue. This is a type of code we've been using for a while. And I think that's what we started with. We think a lot of the、 i guess the code for it. Okay. So there is a hierarchy of keys here. There's a master key which lives in the controller. The master key never leaves the controller, but it is used to derive the session base key, which is the one we just spoke about. And then there's the encryption key for all the actual messages, which is derived from the base key. Now, in the newer implementations of OSDP, this pack actually is a key that, I guess,'s removed it takes out the master key and it recommends eliminating it and instead somehow generating and delivering the session basically. Now it doesn't say how to do that. So we've seen things like this. We've actually seen hard coded simple keys for the SCBK. And again this isn't just one library we've seen a number of these. So what does that mean from our attacking perspective? Now we're not going to say we're going to brute force the whole 128 bit space. That'd be silly. But what we can do is try say about a thousand weak keys, right? We can try repeating characters, we can try increasing and decreasing characters and so on. If we manage to actually find a reader that's using these hard coded keys then we can recover the encryption key and compromise that session. All right. This brings us to protocol WTF number four. Encryption is not magic fairy dust which was also the very nearly the title of this entire topic. Uh, it's not magic fairy dust. Uh, it's not magic fairy dust. Uh, it's the another possible alternate title was just because you did it on purpose doesn't mean it's not a vulnerability. Um, so let's go back to this. Uh, some bold marketing claims about things being unhackable. Um, while we can all get a good laugh out of this. Um, one thing that it said was true which is that it does in fact use 128 bit AES encryption. That is in fact true. So good on them. Um, the problem however is that we only use AES. As in there's no asymmetric cryptography at all in the spec whatsoever. So naturally cryptographers amongst you are wondering so how do we do key exchange exactly then, right? So if there's no cryptography then like how, how do, how do the reader and the controller exchange keys? Ah, dear listener, this is maybe easier than you think. You just send the key. Um, no, okay, okay, okay. We can't just send the key unencrypted, right? That would be insecure. So we encrypt the key. But, cryptographers amongst you are scratching their heads right now. With what do we encrypt the key? If we are trying to send the key. Ah, that's a good question. We use the SCBKD which is the secure channel base key default. Default meaning that's it. That's the key. It's just the ASCII numbers zero to half, um, in hex. Like this is not how encryption works. Like you can't just like sprinkle some like crypto on something and say like, where are you going? You we encrypted it, boss. There's no point in this whatsoever. It's just like a really fancy encoding mechanism that only serves to give you a false sense of security and thinking, like, I don't know, the thing says it's encrypted right now and I can't read it, so I guess it's good, right? Like, this is not the air bug rules of cryptography where, like, you can't just, like, there's nothing in the rules that says a default key can't be an encryption key. Cool. Okay. So this brings us to our final demo, and actually my favorite one, because just what it actually means. Cool. So, again, we're attacking the controller, and we managed to capture the encryption key. So how do we capture the encryption key? Up to this point, a lot of what we've discussed can be attributed to misconfigurations, right? Not so much, like, other than the WTFs, a lot of it is the reader being left in install mode or supporting both secure channel and unencrypted traffic. So what happens if best practices are followed? First of all, I think a lot of us know that best practices usually aren't followed. But let me walk you through a scenario of how we would attack a completely secure setup. Number one. We insert our listening device. Number two, we need to break a reader. Number three, we need to wait for IT to replace that reader. And number four, we capture the key set command. So this is how it actually works. So let's say we show up on a site where we want to break in, right? We have the top secret door we want to gain access to, and we have maybe a side door that's not so well guarded. Everything is set up correctly. There's no possibility for downgrade attack. Everything is encrypted with a session-based key. Well, we're still going to go and insert our listening device behind the not so very secret door. Again, let's remember that OSDP on RS485 supports multiple readers. So that's kind of a that's what's going to make the attack practical for us. I'm going to go ahead and insert it on that same bus somewhere where that's not well guarded. Now, we need to break the reader we're interested in. How we do that, it's up to you. So you can either use an NDP or you can use the NDP. So we're going to go to the NFC app on your phone, go up to the reader and mess around with its settings, which is actually something you can do with a lot of readers we tested. Or you can literally go up and rip the reader off the wall. Doesn't matter how you do it. You just need to break it. Now, what's going to happen? Well, they're going to need to replace that reader or they're going to need to repair it. And so they need to deliver that key to that reader, right, to set up the secure channel encryption. Well, if we're on the bus listening to everything, we're going to need to do that. We know that that key set message is going to be delivered with the default base key, which means we're going to be in a position where we can capture it when the reader is being set up. Which means after everything is set up, we now have the session base key and we can decrypt all the traffic going to the top secret door. Cool. All right. So what do we do? How do I defend? Let's look at what we can do from the blue team side. First, check your configuration. So we have the default base key, which is actually enforced. We need to make sure that there is no possibility that we can downgrade that. So the readers that support encryption, sorry, the controllers that support encryption usually have an option that just does not allow it to be for communications to carry on unencrypted. And disable the install mode. Now, something that Dan failed to mention is, when we were doing the testing for this, we actually tested this on a production site where the install mode was in this case. So we are going to have to place that in a left on. So it's not, you know, it's not a theoretical misconfiguration. We've actually seen that in production. So whenever it's set up, make sure to disable the install mode. So this is a recommendation that I'm going to give to you that you are definitely not going to do. But I'm going to say it anyway. So to never configure a reader in production, meaning this is basically a way of inventing your own out of band key exchange mechanism. So rather than ever using the production wires as in like the reader on the wall using the wires that are in your building, since the entire point of putting encryption on this thing is assuming that those wires are compromised, there could be somebody listening, that like doing an insecure key exchange over that mechanism is just hazardous. So what you could do is if you need to install a reader, to take the reader off the wall, walk it over to the controller with your feet, plug it into the controller with like a two-foot wire that you're reasonably sure has no listening device on it, do the key configuration there. Do the key exchange there. Take the reader, walk it back to the door with your feet, and then put it back onto the wall. You have to do this every single time a reader has any kind of an error or needs to be reconfigured or replaced. For a significantly large building, this is going to be utterly untenable. But nonetheless, this is a thing you could do. This is a thing you could do. This is a thing you could do. That way, any time the key exchange happens, it's never done over the production wires where somebody is actually listening. So if you're like extremely paranoid and this is a thing you want to do, then go ahead. It sort of defeats the purpose of like having this whole system, but it's a thing that you could do. Never ignore tamper alarms. Modern readers have a little button on the back of them. That is like a tamper alarm. And in practice, when you are a red teamer and you're going to be performing this attack, you're likely to do a tamper alarm. You're likely to do a tamper alarm. It's literally just like a button that when you have the reader against the wall, it's pressed in. And then when you like unscrew it with a Phillips head screwdriver to access the wires behind it, it un-presses that button and then sends a little signal out to the controller that says, I've been tampered with. And like what happens on the controller is kind of up to you as a blue team. Maybe that just goes and gets into a log somewhere that somebody will notice in several months. Don't let that happen. There's often, you know, there's a lot of things that happen. Often other mitigating physical controls around these sorts of doors, especially in physical security systems for high secure facilities. So like maybe take a tamper alarm and like start recording with the camera when that happens or something if there's a camera there. Like whatever you do, don't ignore these things because if you're being attacked for real, you're likely to get one of these things. It is probably possible to like tamper or to get access to the wires behind a reader without triggering a tamper alarm, but that's like a whole tougher thing that we didn't bother getting into because it's sort of its own rabbit hole. Maybe there's a clever little like device you could use to like insert behind it and press the button in and then pull it out. I don't know. That's not me. Buy OSDB verified devices. So if you're a blue teamer or if you're setting up badge control systems for your work, look for this little like check box thing. Don't just buy some random box off the Internet that says it supports OSDB because it might just like not even support encryption. Like we literally bought, bought a device on eBay for like $300 because we wanted to test OSDB encryption and it turned out to not support encryption. So I made that mistake and I bet you could, too. And then lastly, don't trust things just because it's encrypted. Cryptographic protocols are really hard and security is hard. And just because it has encryption on it doesn't make it like secure magically. And then that is all. Thanks a lot. I think that we have time for some questions. There is a microphone right in the middle here. If you'd like to ask a question, you can go up to the microphone there. Alternatively, you can just shout really loud. And I could probably hear you if you do that. If not, then we'll just be kind of milling about here. And then how am I splicing 485? Oh, yeah. You can basically just punch into it. So it's a differential for the question. I'll give you a couple of questions. Repeat the question. How are we interfacing with the RS-485 from a physical perspective? And you can just tap into it, basically, so it's a differential signal. And because it's multi-drop, it's meant to be used in that kind of configuration, basically. So, yeah, you can just kind of tap into it. Also, for our device, I'm tapping into the power line as well just to get power from it. So you get the data lines, it's a differential signal, so you get like power in, power out. So, yeah. Data and then negative data. And then you'll also have power lines. In theory, you could use a battery, but we figured it was just going to be easier to tap into the power lines as well. So, yeah. Yes, all of our, the tools are on our GitHub. It's GitHub.com slash Bishop Fox. You'll find all the code there. We have the hardware schematics for the hardware itself, as well as some code. Oh, yeah. We actually have a bunch of PCBs to give away. We have a hundred, like, melon PCBs if you want to nag one. It doesn't have the rest of the components on them, so you'll have to do some soldering. But, yeah, we've got some PCBs if you want to get one. We have to bug this guy. He's got them. Yes, question? People are going for the shouting option more than I thought they were going to. You have to shout. Yes. So, the spec is open. In fact, it's so open that anyone can purchase it for $200 online. That is the only official way to do it. So, yeah, we've got a bunch of things. So, yeah, that's the only way of getting access to it. So, one of the things you mentioned about parsing a packet and resetting parts of it. Yeah. How would you actually do that if it was sitting on the bus? Yeah. So, the question for those listening is, like, in one of the attacks, the downgrade attack, we're going to modify the capabilities packet. Like, how are we doing that if we're just passively tapping? For that attack, we're just not for the hardware device. We have, kind of, like, two versions of the code. There's one that's Python that's, like, meant to run on a laptop with big RS-485 adapters in the middle. And then for the initial version of our hardware device that's, like, miniaturized down into, like, a one inch by one inch thing, we decided to just make it a passive tap. So, we're not doing the man in the middle attacks. And that would be one of them. So, yeah, that one, the install mode attack is not part of the hardware one at this point. Maybe we'll make a separate one that has, like, a proper man in the middle. But you'd have to, like, snip the wire and then get it in the middle and then, like, I don't know. That seems like a lot for red teaming. So, we would just have avoided it. So, yeah. So, yeah. So, yeah. So, cool. Thanks. Yeah.