All right. Good afternoon, everyone. My name is Colin, and I'm here to talk about modern odometer manipulation. So, unfortunately, they told me that the slides aren't going to be working today. They should be sharing them in the recording after this. So, there is some good stuff in the slides I'll try to talk through, but it might be difficult to follow a bit of the attack path and such. Not right now. DEF CON will give them out. All right. So, the agenda for today, I'm going to tell everyone a little bit about me and how I got to be here. I'll talk a presentation, which is reverse engineering a device I found online that claims to be able to manipulate the odometer of various models of cars across 53 different makes. So, pretty much every car I could think of. And finally, we'll conclude with who cares and a little bit of why this matters, as well as how we can maybe look for it when we're buying a car. So, before I get into it, disclaimer, odometer fraud is a federal crime. You are not allowed to advertise, sell, or use any odometer manipulation devices. So, this presentation is just to be educational on how they work. Do not do this. A little bit about me. So, I've always liked to make things work the way that I want them to. This means manipulating things. I started off with iOS jailbreaking. I wanted my iPod touch to look a little different, wanted to kind of cheat in some of the games, and had a lot of fun with that. Moved into hacking some AAA video games and reverse engineering anti-cheats. And after that, I got into the field of cybersecurity because I found I loved reverse engineering and exploitation. In the field of cybersecurity, I started with voltage fault injection, looking to extract firmware from flash-protected chips. And lately, I've been working on MCU emulation in order to help understand a little bit of the firmware I've extracted, as well as do some exploitation. All right. So, getting into odometers. Imagine two identical cars. They're on the lot. They're the same year, the same make, and the same model. How can you tell which one is worth more? Typically, the odometer drives the value. So, the odometer on a car represents the wear and tear that a car has been through. It's made of a bunch of consumable parts , and over time, those parts are worth less. So, it's very important that the odometer should only ever increment as it's a proxy for wear and tear. It should never reset to zero and should never decrease. So, my understanding was that you cannot easily roll back an odometer on modern cars. Until I came across an interesting discussion on an automotive forum, where a couple users were talking about a device that doesn't say it can roll back an odometer, but it can manipulate the odometer in a different way. Instead of rolling it back, it would prevent the odometer value from ever increasing in the first place. And this was a new idea to me. So, I started digging into it, and I found that there's a web store online where they're advertising these devices. And like I mentioned, they're covering 53 different makes and countless models of vehicles. They offer some advanced features like configurable modes, meaning you can have it prevent any miles from being added to the odometer, turn that off and have all miles show up on the odometer, or even have a fractional amount of the miles that you drive register on the odometer, which is really quite a fraudulent feature. It would help get around our Carfax checks every time you do an oil change. They also had a Bluetooth app control feature, which I thought was funny. It was just clearly a large operation. And they sell these devices for anywhere between 300 and 600 euros. So, that price makes me think there's money or value to be had by committing this fraud for sure. When I go to get a lease, if I want to upgrade my miles by 2,000, it's probably going to cost me just as much, if not more. And that concerns me about how widespread the use of these devices might be. So, the other thing to mention is that this web store was a European website. They were completely open about what this device was and the pricing and exactly how it worked. They had videos of demos on all sorts of different cars, but they did not ship to the U.S. and I presume that's because of the laws here. But they did have a kind of shadow sister site, where they used the same web infrastructure and the same pictures, but just changed all the text descriptions and made up some bogus functionality that it doesn't have in order to sell these devices in the U.S. So, my curiosity got the best of me and I bought one of these devices. And unfortunately, you can't see it, but what it looks like is a tiny PCB that is wired into a nice harness that has two ends of the same connector on it. And so, from that, you can probably guess that the device is intended to be used in a man-in-the-middle configuration. They advise on their website that you plug it into the back of your instrument panel cluster, where you unplugged the original connection, and plug that into this device. So, having a man-in-the-middle position here gives the device full control of messages flowing in either direction, whether that's to the instrument panel cluster from the rest of the car, or back out to the rest of the car from the instrument panel cluster. The PCB on the device connects to both power and ground on either side of the connector, as well as has a CAN bus pair that goes to either side. Components of the device are pretty simple. It was an STM32 microcontroller, some power circuitry to step 15 volts down to 5, and then regulated to 3.3, and two CAN transceivers for either end of the connector. So, with my goal being to understand how this device works, I wanted to obtain the code from inside the STM32. I figure the firmware is where the logic will be. And whenever I want to interface with a microcontroller, the first place that I look is for the debug protocol, like SWD, JTAG, DAP, BDM, for two reasons. The first is that that protocol is almost always available somewhere on hardware. If you think about it, when the manufacturer builds the board, they're going to do that through the debugging protocol. And then the second reason is that that interface gives you such high level of access. You're going to be able to read and write all the flash and do everything that I want to do. So, being an STM32, this is an ARM microcontroller that has SWD or single-wire debug. And there was an unpopulated three-pin header on this device. So, I got my multimeter out and traced a bunch of connections and pretty quickly realized that that unpopulated header provided SWD access, and hooked up to the device using a cheap ST debugger, and hooked up some power to the device. And I just want to mention something I've recently been doing for powering automotive components. I don't know if you guys have heard of these USB-C power delivery decoy modules, but they're tiny little chips that have a USB-C port and you can use them with any of your typical USB-C chargers to get a set DC voltage out. And so, I love these things. They're tiny and I just solder a little thing to say give me 15 volts and then I solder them up to my ECUs and I can take my ECUs or other automotive parts with me anywhere and just plug in a typical laptop charger to power them on. So, really, really nice class of device if you're powering a lot of these things. So, after soldering that up to provide 15 volts to our target device, I ran OpenOCD and everything looked great at the start. I was able to connect, read the registers, I saw that the program counter was in flash, it all looked right, but upon trying to read the flash, I was getting all zeros back. And I hadn't worked with a ton of STM32s, so I had to do some research and found that this STM32 product had flash read protection enabled. So, doing some research, I googled STM32 F1 flash readout bypass vulnerability just to get all the keywords in there and actually found a very promising result, an attack detailed in a paper called one exploit to rule them all. And this paper was really interesting because it didn't just have one attack, as the name kind of suggests, but it actually covered, I think, five or six different attacks, all based on extracting protected flash from microcontrollers. And what was really cool about this paper is as you read through the attacks, you can kind of see how flash protection evolved over time and how the exploits evolved over time to counteract that. And so, I really enjoyed reading that and seeing the game of cat and mouse go by. But the attack we'll talk about here today is called shellcode execution via glitch and flash patch block. And I will try to detail it without the slide, but we'll see how that goes. Before I do that, I want to just talk a little bit about flash protection, what we're up against here. So, on STM32 microcontrollers, flash protection will prevent any reads from flash by just returning zeros instead of the actual data. And it will be enabled in three different conditions. The first condition is if a debugger is connected. And then the other two conditions are if you boot to the bootloader or boot to SRAM. So, those latter two conditions can be cleared by a simple reset. But the first condition of having a debugger connected can only be cleared on a full power cycle. All right. So, to explain how this attack works, I'm just going to start here with the steps and we'll see how this goes. The first step is to prepare SRAM with a two-stage payload. You put those two pieces of code into RAM. And at that time, since the debugger has been connected, the flash is protected until the power cycle occurs. The trick, the first trick of this attack is to do a power cycle very, very quickly and abuse SRAM data retention in order to keep our payloads in SRAM while clearing the lock. After that, we can boot to SRAM and our flash protection lock from the debugger connected is cleared, but we now have a lock from booting to SRAM. And our second trick occurs here in stage one of our SRAM payload. The first thing we'll do is set up what's called a flash patch block. And this is a debugging feature on STM32s. It's really interesting because what it does is it has two registers, a comparator and an override value. You give it an address and when the microcontroller attempts to read flash and it matches the address you set up in the flash patch block, it will return your override value instead of what's actually in flash. And since this is a debugging feature, it will actually persist across resets. So, by setting up a flash patch block on the flash entry point to point to our stage two payload in RAM, we can then reboot to flash, which will clear our lock. And because we have the flash patch block set up, when it boots, execution will be redirected to our code in RAM stage two, which just transmits the contents back to us over UART. So, luckily, this attack was implemented on GitHub already. There's a nice repo by CTXZ that explains it all and uses a PyPICO , making it really easy. But in order to actually do this attack, we're going to need to modify the hardware we have. To do that really quick power cycle, we're going to need to have tight control over the VCC pin and we're also going to need to be able to react very quickly to changes in NReset. And so, to do that, we're going to remove the capacitors on those two lines as the capacitors there will resist changes in voltage. We're also going to remove some resistors on the boot config pins, boot zero and boot one, so that our Pico can control the boot mode throughout the attack. After that, we can connect the target device to our Pico. Again, the Pico is providing power, watching NReset, controlling the boot configs and listening to UART for when our stage two payload finally starts sending out the flash contents. So, when we run the attack, I have a saley screenshot that you can't see of the power glitch, but what it shows is that VCC begins dropping and NReset follows it down. As VCC and NReset drop, eventually NReset hits what the Pico will consider logic level low. And when it does that, the Pico immediately restores power to VCC. And so, by doing this, the STM32 really only loses power for about two microseconds. A very, very short amount of time, enabling SRAM to retain its data at room temperature without much issue. Meanwhile, though, NReset will continue all the way down and perform that full power cycle. And here, this screenshot for the recording, this shows the full attack where the power cycle that we just talked about is this little dip here. So, finally, we have the code, we have the flash, we can begin reverse engineering this. Let's get into Ghidra. From looking at the datasheet, we can see where RAM goes, where flash goes, and that this STM32 mirrors flash at the zero address. So, we can set up those sections in Ghidra and select Cortex Little Endian. And the next tip that I want to explain is using SVD loader when you're reverse engineering ARM firmware. So, if you're unfamiliar with SVD loader, it is a fantastic Ghidra script by LevelDown Security, which will save you a ton of time in setting up both the memory regions and the peripheral labels in Ghidra. So, all the different peripherals, timers, watchdogs, the SPI, the CAN controllers, everything will be labeled automatically by this SVD loader script. And the reason that's so easy is because ARM provides SVD files for the chips that contain this information. So, by doing that, a bunch of information which was completely unlabeled before gets labeled. So, all these properties on a CAN register, for example, will be labeled, and it really facilitates reverse engineering, makes it much quicker to go through. So, in ARM, to get to the meat of this program, we have to start at the entry point. And luckily, that's well defined. So, Ghidra even knows that at address zero, we'll have the stack pointer, and at address four, the reset interrupt pointer. So, if we follow that, we see the entry point function. And I've had great success when reverse engineering embedded firmware by just following the last call of each function until I hit a loop. And very often, that's where most of the functionality is. So, by doing that here, we get to a do while loop and the full app loop functionality. I spent some time to reverse engineer all of this, but the real meat is in two functions, which are hooks that intercept CAN messages coming in from either direction and forward them out the other direction. So, this is where the actual odometer manipulation is taking place. Kama AI's open DBC project on GitHub was a huge help to me in doing this. I did not hook this up to a real car, but used their message definitions to see what was actually being modified. And I'll explain the code that is actually in the function modifying the odometer now here. So, the device is looking for a specific arbitration ID and a specific DLC. If it sees that, it iterates, checks through which mode it's in. Again, that's whether it's going to add all the miles to the odometer, none of them to the odometer, or some fraction in between. And then it just modifies one byte of the message before forwarding it. And that is all it does. The sixth byte in the message, Kama AI open DBC labeled as odo count, seems awfully related to the odometer. And in mode one, they're just zeroing it out. And in other modes, dividing it by a divisor. So, that seemed really, really simple. I expected there to be a little more logic, something else going on. So, I kept digging through the firmware, and I found some other interesting functionality. I found that in order to change modes on this device, if you didn't buy the Bluetooth adapter, they were actually also listening to buttons on the steering wheel, which is pretty cool. So, by holding down the up or down buttons on the steering wheel, you could change your mode, and it would toggle through. It would also give you feedback to let you know what mode you're in by sending a hard-coded message to the instrument panel cluster that would completely blink it on and off. But I didn't see anything else that had to do with the odometer. I was really, really surprised by this. So, my overall analysis is that the device simply modifies one specific message before it reaches the instrument panel cluster to achieve odometer manipulation. So, this got me wondering, who cares if odometers are manipulated? Obviously, people buying used cars, which includes me. We care a lot. But also, warranty providers. When they provide a warranty, it's often for a certain number of miles based on the odometer. And lease providers also, when they calculate the residual value, what a car is going to be worth when they get it back, they are counting on the odometer. So, in both of those scenarios, OEMs are involved. OEMs are obviously big warranty providers, but in some cases, they're also lease providers. And I just thought that was pretty interesting. So, maybe the threat model was to prevent rolling back, to prevent being able to just rewrite the value, and never increasing was just not considered. So, I have a little bit of advice for buyers here. Obviously, do a pre-purchase inspection. The service techs and service advisors will know best. And then, beyond that, looking at the wear of consumables can help tell if an odometer is manipulated. But I think the main area that I want to focus in is the diagnostic reporting. And I didn't get as far as I wanted to. I wanted to find a couple of indicators to be able to say, hey, you can check for these things on your car, and this will tell you if this device has probably been used or not. But I'm still working on that, so I hope to release something soon. But I have noticed a couple cases, and I'll talk about those. So, looking at a diagnostic report, I've seen that a lot of cars will track the odometer value on multiple ECUs. That might be, like, the gateway or the transmission, other modules as well. But if you pull a full diagnostic report and compare those values, they should be pretty darn similar. And if they're not, something's up. But you can also look for engine hours or other diagnostic attributes that may relate to how much a vehicle's been used. So, one example, I found a Jeep Grand Cherokee 2018, where the odometer showed 19,000 miles on the dash, and all looked great. But when I read from the secure gateway, it told me that the vehicle had over 30,000 miles. So, I'm not 100% sure that that means this device has been used. It certainly is an indicator of something, though. All right. And that brings me to the end. What questions do you have? It's in the manipulation device is an STM32. I'm not sure about the cluster. I'm sorry, can you repeat that? That's correct. I believe in the future STM32s, they've patched it by zeroing RAM when it boots. Yes? The location of the data within the messages varies between manufacturers and even sometimes within a particular vehicle for a single manufacturer. How did this device support multiple manufacturers? Well, that's a great question. So, this device, to be very clear, this device supports one specific manufacturer and one specific vehicle. But the site advertises these devices for many, many different ones. Of course, you'd have to buy a different one for each vehicle. Great question. Yes? I would love to. I certainly want to see if other brands are as simple as this. I think it would be a really interesting investigation. I want to find some indicators first, but that's a great idea. Yes? Unfortunately, not. It's illegal to advertise these devices. I would love to. Anything else? After you register the device, does the device block some of the messages or is it sent to the developer? It just changes one field in one specific message headed towards that instrument panel cluster. Absolutely. And so that's an interesting area of thought as well, right? They could compare these things while the vehicle is running, but with this position where the device is man-in-the-middle between the instrument panel cluster and the vehicle, it really has so much power that that's a difficult strategy. For example, if you wanted to compare the two values, the odometer blocking device could just lie and say, I'm showing the right mileage on the odometer, or when you go to set the malfunction indicator lamp, it could ignore that as well, so the user never knows that the comparison failed. But it certainly is an area of thought. Checking on signal makers, so you're doing this mechanism of checking only one time, but you have to go to the whole algorithm? I believe so, but yes, I've only reverse-engineered one of these devices. Yes? Right, it's only more effort, so it is a cat and mouse thing. I think there are probably better ways to solve it, but I don't have any to recommend today. Yes? I, you know, I saw a bunch of light-duty vehicles. I don't know if I saw heavy duties on there, so I'd have to check that. Yeah, I'm not sure if they were making devices for those vehicles at all. Yeah. Yes? At least on this device that I saw, it was not doing any of that. So it was not doing anything with the oil life indicator. That could be another thing to check. Right. Oh, that's a great question. Yeah, that was an indicator I haven't thought of before, because yeah, how many times that's reset would certainly be a great thing to look for. And it's a set number of miles about every time, so that's a great idea. Thank you. Yes, sir? Yeah, my confidence is very, very high. Very, very, very high. And I believe this does work, but yes, that's all I'll say. It's very uncommon that a software update will change the CAN bus specification as those messages are processed by so many ECUs. And that's possible that they could do some prevention. Yes? So that's true, but you can't tell at the database level the same, but there are other factors and other communications they make that may change. So especially in like the industry. So I guess that would be my question. It sounds like you think that it would be viable to look to your function. Well, yeah, I think it depends how much they change. I think it's possible somebody could make an update that makes these stop working. Absolutely. But I don't think that's, you know, something they commonly do. Yeah. So I can, there's no security involved. This is just a normal message. It's not UDS or anything. It's just normal CAN protocol. So the, in the slides, I do show the message arbitration ID and definition. So you can look at the whole definition in Kama AI's OpenDBC as well. And that's one of the ideas that, you know, maybe that is a solution here, right? Maybe that this is a great use case of SECOC. It's kind of crazy that this is so unprotected, in my opinion. Yes, sir. I mean, honestly, I dumped the firmware and reverse engineered most of it in a day. I did this last fall. It took a while to get the actual device once I ordered it online. But yeah, I just reverse engineered it statically. So it was pretty quick. Yes. So I haven't seen any, but that certainly could be an option that someone could use to defend against this. I just haven't seen it yet. Yes. That is a great question. I can tell you Kama AI labeled the field as unsigned, but I don't know, you know, in practice, I would assume it's unsigned, but that is a funny question. I haven't tested. Dangerous one to test. Cool. Anything else? Well, thank you all for sticking with me. Sorry that the slides weren't there.