start	end	text
0	620	All right.
620	1680	Good afternoon, everyone.
1960	5860	My name is Colin, and I'm here to talk about modern odometer manipulation.
6300	9240	So, unfortunately, they told me that the slides aren't going to be working today.
9620	11880	They should be sharing them in the recording after this.
11880	17740	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.
18720	19640	Not right now.
19800	20880	DEF CON will give them out.
21540	21940	All right.
21940	25980	So, the agenda for today, I'm going to tell everyone a little bit about me and how I got to be here.
25980	40580	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.
40660	42840	So, pretty much every car I could think of.
43060	49300	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.
50800	55360	So, before I get into it, disclaimer, odometer fraud is a federal crime.
55500	61380	You are not allowed to advertise, sell, or use any odometer manipulation devices.
61380	64540	So, this presentation is just to be educational on how they work.
64540	65720	Do not do this.
66800	68360	A little bit about me.
68520	72180	So, I've always liked to make things work the way that I want them to.
72460	74640	This means manipulating things.
74640	76920	I started off with iOS jailbreaking.
76920	83060	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.
83060	87460	Moved into hacking some AAA video games and reverse engineering anti-cheats.
87480	92620	And after that, I got into the field of cybersecurity because I found I loved reverse engineering and exploitation.
93480	100120	In the field of cybersecurity, I started with voltage fault injection, looking to extract firmware from flash-protected chips.
100280	107520	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.
109580	109880	All right.
109880	111660	So, getting into odometers.
112100	114200	Imagine two identical cars.
114200	115160	They're on the lot.
115160	118080	They're the same year, the same make, and the same model.
118080	120440	How can you tell which one is worth more?
122660	125060	Typically, the odometer drives the value.
125100	129940	So, the odometer on a car represents the wear and tear that a car has been through.
129940	133860	It's made of a bunch of consumable parts , and over time, those parts are worth less.
134100	139860	So, it's very important that the odometer should only ever increment as it's a proxy for wear and tear.
139860	142840	It should never reset to zero and should never decrease.
144360	149720	So, my understanding was that you cannot easily roll back an odometer on modern cars.
149720	160860	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.
161020	166400	Instead of rolling it back, it would prevent the odometer value from ever increasing in the first place.
166460	168200	And this was a new idea to me.
168440	174080	So, I started digging into it, and I found that there's a web store online where they're advertising these devices.
174720	179540	And like I mentioned, they're covering 53 different makes and countless models of vehicles.
179540	196300	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,
196300	198520	which is really quite a fraudulent feature.
198520	202060	It would help get around our Carfax checks every time you do an oil change.
202720	206580	They also had a Bluetooth app control feature, which I thought was funny.
206580	208660	It was just clearly a large operation.
208820	212780	And they sell these devices for anywhere between 300 and 600 euros.
213080	218740	So, that price makes me think there's money or value to be had by committing this fraud for sure.
218740	224860	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.
225220	228780	And that concerns me about how widespread the use of these devices might be.
229540	233620	So, the other thing to mention is that this web store was a European website.
233860	238760	They were completely open about what this device was and the pricing and exactly how it worked.
238760	243260	They had videos of demos on all sorts of different cars, but they did not ship to the U.S.
243260	245460	and I presume that's because of the laws here.
245940	260520	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.
261280	264520	So, my curiosity got the best of me and I bought one of these devices.
264520	273240	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.
273520	278860	And so, from that, you can probably guess that the device is intended to be used in a man-in-the-middle configuration.
279020	287380	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.
288880	301140	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.
302140	310380	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.
313460	315160	Components of the device are pretty simple.
315160	325280	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.
327020	333320	So, with my goal being to understand how this device works, I wanted to obtain the code from inside the STM32.
333440	335900	I figure the firmware is where the logic will be.
336220	345500	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.
345500	350060	The first is that that protocol is almost always available somewhere on hardware.
350300	357300	If you think about it, when the manufacturer builds the board, they're going to do that through the debugging protocol.
357620	361520	And then the second reason is that that interface gives you such high level of access.
361520	365880	You're going to be able to read and write all the flash and do everything that I want to do.
366560	372520	So, being an STM32, this is an ARM microcontroller that has SWD or single-wire debug.
373100	376620	And there was an unpopulated three-pin header on this device.
376620	391980	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.
391980	396740	And I just want to mention something I've recently been doing for powering automotive components.
396740	409660	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.
409900	411200	And so, I love these things.
411200	421900	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.
421900	426100	So, really, really nice class of device if you're powering a lot of these things.
426700	434720	So, after soldering that up to provide 15 volts to our target device, I ran OpenOCD and everything looked great at the start.
434720	445520	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.
445520	456080	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.
457060	473200	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.
473420	485320	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.
485500	494880	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.
495180	499020	And so, I really enjoyed reading that and seeing the game of cat and mouse go by.
499300	505540	But the attack we'll talk about here today is called shellcode execution via glitch and flash patch block.
506040	509600	And I will try to detail it without the slide, but we'll see how that goes.
509860	514320	Before I do that, I want to just talk a little bit about flash protection, what we're up against here.
514540	522340	So, on STM32 microcontrollers, flash protection will prevent any reads from flash by just returning zeros instead of the actual data.
522440	524880	And it will be enabled in three different conditions.
524920	527660	The first condition is if a debugger is connected.
527940	532380	And then the other two conditions are if you boot to the bootloader or boot to SRAM.
533040	536860	So, those latter two conditions can be cleared by a simple reset.
536860	541840	But the first condition of having a debugger connected can only be cleared on a full power cycle.
545170	546310	All right.
546310	554070	So, to explain how this attack works, I'm just going to start here with the steps and we'll see how this goes.
554410	558590	The first step is to prepare SRAM with a two-stage payload.
559030	561990	You put those two pieces of code into RAM.
561990	567090	And at that time, since the debugger has been connected, the flash is protected until the power cycle occurs.
567590	579210	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.
580090	588630	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.
588630	592910	And our second trick occurs here in stage one of our SRAM payload.
593090	597450	The first thing we'll do is set up what's called a flash patch block.
597450	600670	And this is a debugging feature on STM32s.
600670	606770	It's really interesting because what it does is it has two registers, a comparator and an override value.
606770	617870	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.
618010	622130	And since this is a debugging feature, it will actually persist across resets.
622830	633810	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.
634210	644390	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.
646130	649230	So, luckily, this attack was implemented on GitHub already.
649230	655070	There's a nice repo by CTXZ that explains it all and uses a PyPICO , making it really easy.
655710	660430	But in order to actually do this attack, we're going to need to modify the hardware we have.
660430	669170	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.
669510	675510	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.
676250	684010	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.
685730	688810	After that, we can connect the target device to our Pico.
688810	697930	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.
701160	714240	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.
714240	720980	As VCC and NReset drop, eventually NReset hits what the Pico will consider logic level low.
721020	724980	And when it does that, the Pico immediately restores power to VCC.
725240	731940	And so, by doing this, the STM32 really only loses power for about two microseconds.
731940	738060	A very, very short amount of time, enabling SRAM to retain its data at room temperature without much issue.
738240	742760	Meanwhile, though, NReset will continue all the way down and perform that full power cycle.
745500	754120	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.
755300	759440	So, finally, we have the code, we have the flash, we can begin reverse engineering this.
759440	760720	Let's get into Ghidra.
761340	769940	From looking at the datasheet, we can see where RAM goes, where flash goes, and that this STM32 mirrors flash at the zero address.
772140	776420	So, we can set up those sections in Ghidra and select Cortex Little Endian.
777060	783100	And the next tip that I want to explain is using SVD loader when you're reverse engineering ARM firmware.
783180	794080	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.
794300	804720	So, all the different peripherals, timers, watchdogs, the SPI, the CAN controllers, everything will be labeled automatically by this SVD loader script.
804720	810500	And the reason that's so easy is because ARM provides SVD files for the chips that contain this information.
811860	817220	So, by doing that, a bunch of information which was completely unlabeled before gets labeled.
817220	825060	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.
826660	831320	So, in ARM, to get to the meat of this program, we have to start at the entry point.
831340	833100	And luckily, that's well defined.
833400	840260	So, Ghidra even knows that at address zero, we'll have the stack pointer, and at address four, the reset interrupt pointer.
840760	844400	So, if we follow that, we see the entry point function.
844500	851200	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.
851200	853940	And very often, that's where most of the functionality is.
854160	859680	So, by doing that here, we get to a do while loop and the full app loop functionality.
859760	873120	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.
876810	882070	So, this is where the actual odometer manipulation is taking place.
882910	887390	Kama AI's open DBC project on GitHub was a huge help to me in doing this.
887390	893430	I did not hook this up to a real car, but used their message definitions to see what was actually being modified.
893950	899470	And I'll explain the code that is actually in the function modifying the odometer now here.
899990	904850	So, the device is looking for a specific arbitration ID and a specific DLC.
905110	909610	If it sees that, it iterates, checks through which mode it's in.
909610	915390	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.
915470	920450	And then it just modifies one byte of the message before forwarding it.
920810	922450	And that is all it does.
922450	930290	The sixth byte in the message, Kama AI open DBC labeled as odo count, seems awfully related to the odometer.
930570	932530	And in mode one, they're just zeroing it out.
932530	935330	And in other modes, dividing it by a divisor.
936370	938550	So, that seemed really, really simple.
938550	942430	I expected there to be a little more logic, something else going on.
942710	946430	So, I kept digging through the firmware, and I found some other interesting functionality.
946750	955450	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.
955450	961790	So, by holding down the up or down buttons on the steering wheel, you could change your mode, and it would toggle through.
961970	970190	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.
971090	974930	But I didn't see anything else that had to do with the odometer.
975350	977150	I was really, really surprised by this.
977150	986570	So, my overall analysis is that the device simply modifies one specific message before it reaches the instrument panel cluster to achieve odometer manipulation.
988090	992390	So, this got me wondering, who cares if odometers are manipulated?
993210	996510	Obviously, people buying used cars, which includes me.
996510	997650	We care a lot.
997730	999710	But also, warranty providers.
999710	1004470	When they provide a warranty, it's often for a certain number of miles based on the odometer.
1004710	1012270	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.
1012570	1014970	So, in both of those scenarios, OEMs are involved.
1014970	1019050	OEMs are obviously big warranty providers, but in some cases, they're also lease providers.
1019330	1021010	And I just thought that was pretty interesting.
1022410	1032290	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.
1035640	1038580	So, I have a little bit of advice for buyers here.
1040300	1042280	Obviously, do a pre-purchase inspection.
1042280	1044720	The service techs and service advisors will know best.
1045620	1050600	And then, beyond that, looking at the wear of consumables can help tell if an odometer is manipulated.
1051040	1054820	But I think the main area that I want to focus in is the diagnostic reporting.
1055060	1056460	And I didn't get as far as I wanted to.
1056460	1063880	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.
1063900	1066680	But I'm still working on that, so I hope to release something soon.
1067200	1070260	But I have noticed a couple cases, and I'll talk about those.
1070260	1077080	So, looking at a diagnostic report, I've seen that a lot of cars will track the odometer value on multiple ECUs.
1077140	1081660	That might be, like, the gateway or the transmission, other modules as well.
1081660	1086160	But if you pull a full diagnostic report and compare those values, they should be pretty darn similar.
1086180	1087980	And if they're not, something's up.
1088080	1095440	But you can also look for engine hours or other diagnostic attributes that may relate to how much a vehicle's been used.
1096680	1105380	So, one example, I found a Jeep Grand Cherokee 2018, where the odometer showed 19,000 miles on the dash, and all looked great.
1105380	1109800	But when I read from the secure gateway, it told me that the vehicle had over 30,000 miles.
1109800	1113440	So, I'm not 100% sure that that means this device has been used.
1113440	1115840	It certainly is an indicator of something, though.
1119100	1120120	All right.
1120120	1121720	And that brings me to the end.
1121720	1123100	What questions do you have?
1133810	1138130	It's in the manipulation device is an STM32.
1138630	1140170	I'm not sure about the cluster.
1148580	1150000	I'm sorry, can you repeat that?
1156970	1157810	That's correct.
1157810	1162190	I believe in the future STM32s, they've patched it by zeroing RAM when it boots.
1163650	1164550	Yes?
1164550	1175190	The location of the data within the messages varies between manufacturers and even sometimes within a particular vehicle for a single manufacturer.
1175190	1178390	How did this device support multiple manufacturers?
1178390	1179250	Well, that's a great question.
1179250	1184850	So, this device, to be very clear, this device supports one specific manufacturer and one specific vehicle.
1184930	1189090	But the site advertises these devices for many, many different ones.
1189090	1191490	Of course, you'd have to buy a different one for each vehicle.
1191490	1192530	Great question.
1193310	1194210	Yes?
1195730	1196930	I would love to.
1196930	1200590	I certainly want to see if other brands are as simple as this.
1200670	1203210	I think it would be a really interesting investigation.
1203210	1205710	I want to find some indicators first, but that's a great idea.
1205890	1206370	Yes?
1208390	1209390	Unfortunately, not.
1209390	1211390	It's illegal to advertise these devices.
1212670	1214170	I would love to.
1215910	1217210	Anything else?
1222430	1231510	After you register the device, does the device block some of the messages or is it sent to the developer?
1231970	1237010	It just changes one field in one specific message headed towards that instrument panel cluster.
1237270	1239800	Absolutely.
1242300	1245460	And so that's an interesting area of thought as well, right?
1245460	1257660	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.
1257820	1272780	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.
1272780	1274700	But it certainly is an area of thought.
1275540	1281120	Checking on signal makers, so you're doing this mechanism of checking only one time, but you have to go to the whole algorithm?
1281680	1285560	I believe so, but yes, I've only reverse-engineered one of these devices.
1287620	1288100	Yes?
1307280	1310860	Right, it's only more effort, so it is a cat and mouse thing.
1311220	1314720	I think there are probably better ways to solve it, but I don't have any to recommend today.
1315160	1315880	Yes?
1320540	1324700	I, you know, I saw a bunch of light-duty vehicles.
1324700	1328460	I don't know if I saw heavy duties on there, so I'd have to check that.
1328980	1332360	Yeah, I'm not sure if they were making devices for those vehicles at all.
1332380	1332740	Yeah.
1333760	1334480	Yes?
1345870	1349210	At least on this device that I saw, it was not doing any of that.
1349210	1351970	So it was not doing anything with the oil life indicator.
1351970	1353550	That could be another thing to check.
1354050	1354850	Right.
1360940	1362220	Oh, that's a great question.
1362220	1367860	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.
1369340	1372940	And it's a set number of miles about every time, so that's a great idea.
1373720	1374740	Thank you.
1375440	1376380	Yes, sir?
1386480	1389280	Yeah, my confidence is very, very high.
1389360	1390700	Very, very, very high.
1390760	1394840	And I believe this does work, but yes, that's all I'll say.
1406150	1412590	It's very uncommon that a software update will change the CAN bus specification as those messages are processed by so many ECUs.
1412730	1415330	And that's possible that they could do some prevention.
1415330	1415570	Yes?
1415590	1416770	So that's true, but
1421600	1429820	you can't tell at the database level the same, but there are other factors and other communications they make that may change.
1430060	1432840	So especially in like the industry.
1433920	1436240	So I guess that would be my question.
1436500	1440760	It sounds like you think that it would be viable to look to your function.
1440760	1443060	Well, yeah, I think it depends how much they change.
1443060	1446260	I think it's possible somebody could make an update that makes these stop working.
1446260	1447080	Absolutely.
1447160	1450420	But I don't think that's, you know, something they commonly do.
1450800	1451300	Yeah.
1460880	1463600	So I can, there's no security involved.
1463600	1465060	This is just a normal message.
1465060	1466140	It's not UDS or anything.
1466140	1467720	It's just normal CAN protocol.
1467860	1471780	So the, in the slides, I do show the message arbitration ID and definition.
1471780	1476320	So you can look at the whole definition in Kama AI's OpenDBC as well.
1479400	1483080	And that's one of the ideas that, you know, maybe that is a solution here, right?
1483080	1485380	Maybe that this is a great use case of SECOC.
1485380	1488440	It's kind of crazy that this is so unprotected, in my opinion.
1489500	1490260	Yes, sir.
1496690	1500770	I mean, honestly, I dumped the firmware and reverse engineered most of it in a day.
1500770	1502290	I did this last fall.
1502290	1505550	It took a while to get the actual device once I ordered it online.
1505570	1509630	But yeah, I just reverse engineered it statically.
1509630	1510730	So it was pretty quick.
1514920	1515660	Yes.
1520580	1526980	So I haven't seen any, but that certainly could be an option that someone could use to defend against this.
1526980	1528300	I just haven't seen it yet.
1531110	1532030	Yes.
1549060	1550840	That is a great question.
1551100	1559380	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.
1559380	1560520	I haven't tested.
1562700	1563960	Dangerous one to test.
1565340	1565800	Cool.
1565800	1566620	Anything else?
1570190	1571610	Well, thank you all for sticking with me.
1571610	1573290	Sorry that the slides weren't there.
