Hi, today I'd like to share my experience on how to relay NFC traffic for Tesla Model 3. So my name is Kevin2600. I'm currently working for a company called InGeek in Shanghai, China, and we're focused on research and pen testing for smart car security. We also built a project called CarSRC, which is China's first car security response center. So you're welcome to follow me on Twitter on Kevin2600 or just if you're interested and check out a barcode here for a company website, right? Okay, so here's our content for today. First, I'd like to talk about some basic knowledge and the applications regarding to NFC. And then I think maybe I should... And then I will talk about the key fobs architecture for Tesla Model 3. And eventually, I will walk through the challenge we have faced and how do we bypass it during the NFC relay research, right? So NFC 101. I don't think we need to talk about too much on this at this point because a lot of people already know about NFC. But basically, NFC stands for Near Field Communication. It's most likely operating on passive mode and it's really working in close range. We are talking about centimeters here. And the operation frequency is usually going to be 13.56 MHz. And you can use things called NDEF to change the data back and forth, right? So the NFC technology is already widely developed, right? So we can see a lot of applications based on it in today's world. So for example, our payment system, our passport, and our card for access our business buildings are all most likely NFC or RFID based. And then there's a new trend for using NFC for car keys. And here's some of car manufacturers already using it. As we can see, like BMW or BYD and like our main target today, Tesla, they're using it. And they come with different size of forms, right? So interestingly, even Apple has enabled a new feature called car key for the latest. So yeah, I think the digital car keys is really the future. And now speaking of Tesla, Elon Musk, he's so proud of it. He mentioned that Tesla is a sophisticated computer on wheels, right? So if it's a computer, the hackers or security research will be interested in it. And so here's a small list that I grabbed from the Tesla website. As you can see, there are many researches, researchers has found vulnerability and report to Tesla for the past few years. And so for example... Oh, sorry. Okay. So for example, the famous hacks from Tencent King Labs, they were able to exploit the Wi-Fi stack on Tesla Model S. And then they also done a great experiment on Tesla Autopilot. So if you guys are interested, I recommend that you check it out. Also, there's some more independent researcher. So for example, one guy called Richard Zhu, he won the last year Pwn2Own competition. He basically able to pawn the Tesla IVI system. Also, there is another researcher from Belgian. He's able to successfully crack the key, the encryptions used by Tesla Model S. And then he's able to successfully clone the entire key. So I think this is quite cool, right? However, it turns out that not just the hackers or security researchers are interested in Tesla. So are those professional thieves, right? But they don't care about how to write perfect exploits for RCE. They only want to steal the vehicles or something left inside, right? So they only want some very simple way. And it turns out that one of the simplest ways for them is called a key file relay attack. I think this is all over the news for the past few months or even last year. You're going to see some guy come to your neighborhood with some mystery device that it can amplify your key file and then somehow turn on your vehicles and drive away. And this is also the reason why we start to research on Tesla. Because we must try to see if it's possible to do the NFC relay for the Tesla Model 3, right? Okay, so Tesla key file architecture. So let's talk about this. Okay, so before I start, I'd like to talk about some research procedures. The first, usually when we start to research something, we usually start with some reconnaissance, right? So basically, at this stage, we try to read as many as possible the menus regarding your target. And also you can sit down with your friends, your colleagues, and to do some brainstorm to see what kind of attack factors that you can have, right? And once you have that ready, then you can really just sit down and actually implement some attack plans. And then you can go to actually doing it, right? So usually when we're testing for like Tesla here, we are not expecting that it will success in the first time. So usually it will fail, but that's okay. We just try harder and repeat. Eventually, we'll find something, right? Cool. So for Tesla, now in order to access the Model 3, Tesla has provided us three different ways, right? For example, we can use NFC tag, and Tesla also provided mobile apps for us to try to control your car through Bluetooth. And later, they also provided the physical key fob, also have been using Bluetooth and NFC here, okay? And just like any other radio device, Tesla key fobs, we can find a thing called FCCID. So this is important for us at a recon stage, because first we need to know as much as possible regarding your target, right? So from here, we search the FCCID to the website, and then we can find, say, for example, we can find that Tesla Model 3 key fob using a CC2640 chipset. And also, this is also for key fob reader, the reader module, and also having to using CC2640. So by this information, really, we can have even without even actually open the... even without own one of these vehicles, you already know something about it, right? That's pretty cool. Now, regarding the NFC key tag itself, actually, it's just like any other NFC tag, it supports ISO 14443 type A, and also ISO 7864 standards. And basically, it's a Java smart cards. So we can use in some already already exist application to group graph this information, right? There's a lot of application can do as you can see here. Yeah, the difference between those two ISO standards, one is contact, and one is contacts. They are very similar. And on top of application layer, they all the same, just using APTU to talk to your car. Okay, so and, and then I recommend that people serious about researching on RFID security, you definitely need to go get one of the PM ProSmart 3. Yeah, I think this is very important. So basically, we can use in PM3 to, to identify your, your targets, which is key file here. And I can see identify as an XP MyFair DeathFire 4k EV1 type card. Okay, so and here's a little summary here. So the test NFC key tag is seven bytes. He uses seven byte UID. And it is a Java based card. The most important part is here is the actually using the ECDH for a challenge response for authentication. So and as I mentioned, ProSmart 3 is really helpful during the research, as you can see the picture right here. I, we are able to use in ProSmart 3 to talk to, to send different commands, APTU commands to your target, to the tag. And we can able to get some information out, for example, a public key, or different Java updates, like sending different AID to require different Java update to do some testing. So yeah. And right. So now I think it's time for some real hacks, right? Cool. Um, so since our goal here is actually to get NIC relay working, and there are many research has done great jobs in this area already. So in beginning, we don't want to reinvent the wheels. So we've, we just do some research and find there's a very cool application called NLC gate. And NLC gate is basically is Android application is the mean for capture, analyzing, or even modified NLC traffic on file. So basically, it's pretty cool. It's perfect for us, right? And he operated it, basically, we need to mobile phone at running the NLC gate. And we need to set our Wi Fi server in the middle, right? So can true to send to relay through the traffic. Um, so yeah, so for the first for the test run, um, we're, we're trying to target our credit card system to see if we can buy a coffee for free, right? So with someone's, with my colleague's card, basically. So, and so here's the result I would like to show you. Right, so basically, we try to was one of the colleague to pretend to be a bad guys and me just try to read out the someone else's card, right? Yeah, as you can see, the traffic is already go through. We're successfully to buy, to get coffee for free. And by this point, we're very, yeah. Yeah, by this point, we're very happy. So we run to a parking lot for hours to test the Model 3. Unfortunately, it failed for the first attempt, right? As I mentioned, usually it will fail for the first time. But let's find out why it happened. What happened exactly, right? Okay, so and again, we brought out our Porsche Model 3 and start to capture and compare the NX traffic between the actual Tesla key tag and the other which relate by the NFC gate to do some, to see if there's anything I'm, we were missed. And yeah, so here are the traffic data we captured by PM3, Porsche Model 3. And also here are the traffic we captured by NFC gate itself. It has a logging file function. So as you can see, one of the response by the tag is it can convert back to convert the hex string to something we can read as a Tesla logic, which indicate that it is Tesla's NFC key tag. Okay, so let's walk through some those hex strings, try to understand what's going on here. So first, yeah, so this is important here, right? So first, the the reader, the sorry, the reader will send out a request asking for Tesla logic AID for like TBK, which stands for Tesla phone key. But because we are actually using the NFC key tag, our reader, our tag will respond with 6D00, which means instruction invalid, which is, which means this particular AID doesn't exist. So and then the Tesla will send another request, will send another request asking for TKC, which is Tesla key card. And yes, executed successfully by like 9T00. And because we are using Tesla key card, so yeah, it does exist. So then the reader will send and select this particular AID. Okay, now, like this is a Tesla logic update list, right? And then the reader will send out authentication command for this particular AID. And like they send out a vehicle public key and followed by a 16-byte challenge. Now for the tag itself, we have to respond with a 16-byte response. And once we have that sorted out, then we are authenticated to the reader and then we can do action like open the car, open the door or close the door and stuff, something like that, right? So as you can see, the whole authentication process is kind of simple. But why we endlessly read a tag on credit card system, it works. The Model 3 is not. And turns out, the reason is the payment terminal, the POR system is not required to stop the transaction if it takes longer time. But the Tesla, on the other hand, has more restriction on timing. It has to respond in a very specific time. Otherwise, it will be time out. If we say, if we didn't respond to the correct answer on AID on time and then it failed, right? So because we are related, remember we are related traffic through Wi-Fi network and there's a lot lot of things can happen during this transaction. So now our job is to increase our speed. And luckily, there's a great researcher called Stefano. He is kind enough to give us some advice. But unfortunately, this second attempt also failed. But thanks for him. Let's try harder, right? Let's see. And then my colleague, Alex, he came up with some idea to verify because at that point, we're not really sure if it is a timing issue only or maybe something else blocked the way. So his idea is instead related traffic by Wi-Fi, maybe we're using the USB cables because all the traffic then you transfer locally. So it's supposed to be very very fast, right? Let's see if that works. So here's our first video. You can always check out YouTube on this for later, right? Yeah, cool. As you can see, we actually relay by the USB. It works. So it is timing. It is where you have to find a way to increase the speed. But how? And then, yes, we found another trick from the same guy, Salvador, which is inspiring us a lot. Because basically, he has given a talk at DEF CON 26. Basically, he was able to bypass the payment limit by simply replacing a certain value during the transaction. And also, he can able to replay. Also, again, same trick, replace different values in order to instead of using EMV, he actually turned to using MACDRIVE for payment systems. So let's get us thinking. Can we do the same? So let's go back to the traffic we captured by ProSmart 3. So basically, remember we mentioned that the first reader will send out... they're asking for a particular Java update AID, which never exists. It actually starts at 4. And then, because it doesn't exist, it will be failed. So they send another request asking for another Java update called Star Wars 74. So can we do something about here? And definitely, yes. So let's... sorry, I draw a very ugly picture here, but let me try to explain what happened. So basically, first, Test.mod3 will send out... the reader will send out a request looking for a Java update F4. But because it doesn't exist, the tag will reply response with 60.0.0, so it doesn't exist. And so that... instead we redirect the 60.0.0, we send... we actually forwarding... instead of looking for F4, we're forwarding that... you're asking for 74, because we know that 74, a Java update, does exist. And because... and then, obviously, tag will receive this request, will say, okay, you are... you're asking for 74, then we... it doesn't exist, and then we just respond with 90.0.0. And you will... and then we're using another MVC gate to send those response back. Because... and that takes some time here. So by the time we're processing this command, the Test.mod3 will send another request looking for... the actual request sending... looking for 74. And that's the one actual... the real one sent by the models, read module. But we... because we are in the middle, so we drop it, right? We don't need a second 74. So now by the time we finish... we've done this, the 90.0.0 has already arrived. So by this end, so we can just forward it to the Test.mod3. And once Test.mod3... seems interesting here now. Once they... we bypass those AID selection, we go to a challenge response stage. At this stage, it seems... it seems like during the test, it seems like we don't have any time limit anymore. We can send and wait as long as we want, right? So yeah, basically we just dropped one... instead of looking for two different AIDs, like F4 and 74, we just dropped one of them, and sent in... looking for 74 directly. We will simply... by doing this, we successfully bypass the time limit, right? So and here's... we just play this... we do the demo to show the whole process, okay? As you can see, we... because it's a traffic relayed by Wi-Fi, and you can experience a little bit slow, but it still works, right? As you can see, it will open, and you can check out the current phone... the firmware, right? And then we drop... and driving away. Okay, cool. Now, because we want to see how practical this NFC relay attack is, so we're testing with a lot of... we want to see if it works in long distance, right? So here's another video I want to show... demo I want to show you, as we are actually testing in kind of far away. Let's see the results, right? So as you can see, my car is kind of far away in the parking lot. Yeah, it still works, right? Cool, beautiful. So by this stage, we're very happy and report our founding to Tesla, and however, Tesla replied our email and said that the relay attack are no limitation for their systems. And we recommend customers who are concerned about relay attack enable pin-to-drive. So basically, there's no bounty, and they know the vulnerability exists, but they don't think it's very important, because they think they already have something called a pin-to-drive ready. So here's our work result. So first, basically, even... so basically, what we need to... I need to address here is pin-to-drive is actually not protecting from the relay attack. It's only protecting you... once you open the... we open the door, you cannot stop engine. You have to enter in some pin, right? But we are still able to open the door. And so basically, the risk is still there, right? So once we get in, or bad guy get in, they can't... yes, they may not able to steal your vehicle, but they still can steal some stuff inside your car, or even worse, they can put something in, spare camera, or some cheap... and yeah, so I think the pin-to-drive is really a debatable solution from Tesla. But anyway, we apply a CVE, and we get a CVE here, and we're happy enough, right? But what is pin-to-drive anyway? So basically, I found this pin-to-drive description from the Tesla website. The most interesting part here is that pin-to-drive allows you to set a secure four-digit modification, right? Four digits. So what could possibly go wrong there, right? Only four-digit numbers. Now, we also, during the research, we found there's no pin position randomization, so it's always fixed in the middle. Now, at least, because this research has been done for some time now, and at the time we're testing on different firmware version, we can, at least at that moment, there's no brute force rate limitation and no brute force back-off time. But maybe they are fixed now, but a lot of time, it doesn't have anything. So, four-digit numbers, no brute force protections, yeah? You get the idea? So, oops. So, we actually built a hardware based on something called M5Stack. I named it pin-to-crack, right? So, basically, we can use that to... of course, we can do with, maybe we can do it with Raspberry Pi or with Arduino. It doesn't have to be M5Stack. Basically, the idea is just... instead we push the pin number itself, we can do it automatically, right? So, now, but there's a catch though. Oh, by the way, there's another guy doing a similar attack on his Tesla as well. But this is our solution, so similar, same idea. However, the catch is we have to finish the whole setup process under two minutes. Otherwise, we have to relay the Tesla key attack again. Now, by just... what we found is by just setting up those... because we have to focus on the exact position on the screen. By just setting up everything set up already, it's already a lot of times. So, we maybe... instead of using the device, we're just using our first fingers, right? So, here we're going to just show you the first finger will work. So, first, we are able to open the door, we get in, but because there's a pin to drive function already, we have to enter the pin, right? So, as you can see the firmware version, verify the firmware version, right? Yeah, the pin drive. So, as you can see, in the beginning we pretend we don't know anything about a pin, so we just randomly or brute force try to try our luck. Now, the point here is we can see there's no brute force protection. We can just run... maybe not random, we open... we just entering... keep entering a different pin, even try to see if we get a lock. So, let me speed up a little bit. Okay, okay. See, there's nothing stop us to keep entering the pin, right? Let me see... Let me see where's the... actually, I don't know where's the actual key, so I don't know where to start. Oh, see, here, we got it, right? So, as you can see, during this lock... this is only demonstration, the actual attack maybe take longer, but yeah, the point is they don't have anything protecting it, right? So, we can just, using our first finger, maybe you can get them. Yeah, so, good to go. Okay, all right. So, the summary here. So, really, the security by obscurity is not going to work, right? So, the 100% security does not exist. We have to test properly. We need to... even like, vehicles, you may think like those high-end cars are very secure, but once they implement some latest technology, then it actually opens more attack vectors for the attackers. So, we need to really think this carefully, okay? Yeah, so, here are some references. If you guys are interested to continue your research, I definitely recommend you can try those I just mentioned, and you go to... all those guys are very good in this area. Yeah, so, go check them out, all right? Okay, thank you. I'm done.