Welcome. Thank you for spending your time and skipping the loss of testimony to come see me. It makes me feel great. So I'm here to talk about automotive bootloaders. So I guess, first of all, a little bit about who I am. I'm Phil Lepchinsky, so it's lap with all the consonants and then ski. I'm a software engineer, a senior staff engineer at Renesas, and we make chips and all kinds of things. So what am I here to talk about? Embedded bootloaders in automotive. So what does a bootloader do? Essentially, it owns the reset vector in the microcontroller, and on reset, the bootloader is going to determine if your application is valid or not. If it's valid, it allows you to load the application. On a big system, on a chip, it might say, copy that over into RAM and execute it. For embedded devices, though, it typically will just jump to the start vector of your application. Also, in deeply embedded devices, the bootloader usually allows you to reprogram the memory, the flash and the micro. So, so here you have the root letter vector. Jump into the bootloader. It's going to do some stuff, determine if you have a valid application or not, and then jump to the bootloader. And then it's going to do some stuff, determine if your application is valid or not. And then it's going to do some stuff, determine if you have a valid application or not. So, we've got these in the car. We know that they're in there. How do we talk to them? Well, it makes it, we make it easy in automotive. We have a proprietary connector for OBD, and you have to get special dongles, like the car hacking village dongle. So everybody go buy one of those, they're 80 bucks. But that allows us to connect to the CAN bus. So that's defined by ISO protocol, released in 86. But it's 2008, become mandatory. So we know that any vehicle after 2008, it's in there, we can talk to it. And so that's the physical layer connected through the OBD2 dongle. To start talking to these things, so CAN, only 8-byte payloads. That doesn't give us a lot of information. We can send small commands, but we can't send, like, large amounts of data. So I know. So we got the transport layer, 15765. That's the underlying transport layer that sits on top of CAN and between CAN and the diagnostic layer. So this basically allows us to send payloads up to 4K by segmenting the messages. So on top of that, we're just going to make layers and layers and layers of protocols to make it confusing. We've got ISO 14229, and that's Unified Diagnostic Services. So. This is a ISO spec that basically defines a whole bunch of common services, essentially creating the API. It's client-server. So you send it a request with your client, and the server running on the ECU will send the response. Essentially, this spec defines all of the different standard services. There can be also OEM or supplier-specific services. There can be OEM or supplier-specific services as well. And there's also security levels. So there's different sessions to get elevated privileges. For bootloaders, we're typically talking about the programming session. ISO defines session two as the programming session. So if you send a session control change request to go into the programming session, now you go into the bootloader. So this is where things get interesting. Thank you. And I guess before I jump to that, let me explain. On an embedded device in automotive, the bootloader is typically a whole separate executable program that's separately compiled from the application. So there's some kind of inter-process communication that happens between, like, your normal application and the bootloader when you're sending, passing the information through. So that's usually done through, like, a reset. So you might get a programming, like, a session control request. And it'll set some flags and then cause a reset. And then the bootloader says, oh, hey, I'm in programming session. Let's go do something interesting. So what does this look like, the typical programming sequence? It's broken up into three distinct kind of groups. There's this pre-programming sequence, which happens before you program. There's the programming sequence, which is when you're doing the programming. These are really easily named. And then the post-programming sequence, which I bet you guys can guess, it's after you program. All right, so pre-programming, what happens here? This is, like, usually OEM-specific, really what you're doing. But in the ISO spec, there's common things that typically happen. Oftentimes, you'll do a session control and jump into this, the extended session. So that's session three. And the extended diagnostic session gives you, like, elevated services than your normal diagnostic default session that would be, like, you're driving around in the car. So what you do is you go into this extended session, and you start doing things that are going to prepare the vehicle for programming. So one of the common things is to turn off DTCs. So I'm going to, like, change my application software on the car, and all these other ECUs are still talking to each other or they're looking for messages. And if there's an ECU that's down, not, you know, sending its messages, everybody else that relies on my messages is going to say, what the hell is going on? It'll start setting DTCs. It'll, you know, it doesn't know what's going on. So typically, when the diagnostic tester is going to initiate a programming session, it turns off all the DTCs. It might turn off, disable the non-diagnostic communication. And so say, okay, everybody be quiet on the bus because I want to start reprogramming ECUs. This may or may not require security access to get into this session. Again, this is all OEM-specific, and the OEM specs are all secretly guarded and under NDA. And there's a bunch of OEM people here that they weren't. They don't let me tell the secrets. So then there's the programming step. And this is when you basically activate the bootloader and unlock it. UDS defines a security seed key exchange, so service 27. And you basically, the tester will say, hey, go give me a seed, sends the seed back, and then the tester will send the response. It's a challenge response protocol. But again, the way this is programmed, the actual algorithm is not defined by ISO. That's defined specifically by the OEM. One thing to note, you know, again, the industry is continually trying to strive for better security. But historically, OEMs didn't always do a great job with their security algorithms. It might be a secret algorithm that's, you know, some engineer made up one day. And the secrecy of it is because it's hidden in a desk somewhere. But lots of smart reverse engineers out there that can figure things like that out. So historically, that's been a problem. The industry is working towards better types of security there and also other things like better entropy on the seeds. That's another problem. Anyway, so you unlock this thing, service 27. There may be some write data by identifier service where you write, like, a fingerprint or some specific information. So this is typically, like, the tester might do, like, write the programming date. And then it's like, hey, this was flashed into the ECU, like, the last time it did it. Or write its, like, serial number. So, like, the tester's serial number into it and say, hey, this was flashed by, you know, Ben's serial number. One, two, three, four. Very professional. So then what it'll do is, again, this is, a lot of this stuff is, it's defined by ISO. But exactly how it's done is OEM specific. So some OEMs will have a secondary bootloader that you download. And typically what's in that is, like, the actual flash routines. So residing in the ECU normally, they're not in there. So you can't, like, just, you know, gain, do, like, some buffer overflow and get into there and rewrite the ECU. Because the code for that's not even in there. The flash drivers are actually downloaded by the tester. And they're set up specifically for that ECU. So you download that and then you activate that. And so that enables now the programming routines. So the next thing that happens then is we're going to get into this. So once we've activated the bootloader, we're going to get into this download step. And the way that looks is you have a request download. So service 34, which says you send basically your address and the length. And there's different types of addressing, like some OEMs. So we'll have, like, actual address-based addressing. Some have what's called, like, logical blocks, where you give it the logical block identifier. Again, it's, all of this stuff is proprietary. Then you have the service 36, which is the transfer data. So you're sending this, and you can send basically, you know, 4K at a time until you have all of your data there. Once that's happened, you do a transfer. And then you do a transfer data exit. And so this is typically where you do something like a checksum or do an integrity check of all of this data before activating it. So there may be, like, a routine control after that that says, hey, do this check routine and, you know, check the checksum on it. That's the basic, least secure way is just doing the checksum. You know, it varies wildly. It's all OEM-specific. It's all OEM-specific and proprietary. So a lot of times this could be also where you do, like, the code signing check verification. But really that could be done in the transfer data exit, or it could be done with a special routine. It's all up to an OEM to decide how to do that in their specifications. So, okay, all the data's got there. We sent it to the ECU. We've verified that the data's good. It's good to go. It looks authentic-ish. Now what happens? The tester will say, okay, go back into the diagnostics or the extended session. We start getting it ready for the post-programming. So you turn the DTCs back on because now your application is all working great. And you can turn the normal diagnostic communication, non-diagnostic communications on. And then you usually do, like, a session control to the default session. And so this usually happens through, like, a reset. So the bootloader says, okay, we're done. We reset. And you jump back into the application. So, okay, now that you have, like, the most basic understanding of how ECU bootloaders or automotive bootloaders work, how are these used potentially as an attack factor? Well, there's lots of things that it can do. It's a very powerful. It's its own application. And so just by... What it does, its normal operation, it necessity, like, by necessity, has to do things like, well, it prevents the application from running because it's its own application. So if you can say, hey, go into the bootloader, well, now the application is not working. And why would you want to turn the application off? Well, what if you're trying to, like, spoof messages? If you're spoofing messages on the bus and the ECU is also sending out its valid messages, well, now you're... You have this contention or confliction, if you like to make up words. So if you have this, you know, now you can turn the ECU off and you can send its messages and spoof the messages. Most automotives right now are not using, like, CAN is not, by the protocol itself, is not sending authenticated messages. It's a bus protocol. So if I send messages with this ID, with this... With this signal, I can now, you know, the ECUs that are listening to this can now have to listen to it if you're on the same bus and all those other things. So turn the ECU off and send your own messages and spoof those. It's also... It is auto-reset the decision maker, right? It's deciding, is this application valid or not? And meaning you could also say, if you can make it so that it thinks the application is not valid, it's not going to run that application and you're permanently disabled. Or if you can somehow subvert the validity checks, now you can execute non-signed code or you can execute whatever you want, right? It also, by nature, has ways to input data or export data, you know, exfiltrate data. So some OEMs implement request upload. Part of the ISO spec. It's available. The general practice is not to do that because then you could just send requests to pull all the code out of there, your firmware. But some OEMs do it. Or the supplier implements it for whatever reason. By the nature of the ruler, you can write data to it, request download. That's, you know, if you can write something into RAM, then maybe you can execute. Like a couple slides back, we've got this programming step where you're downloading a flash driver. So that's basically downloaded and run out of RAM. You can read interesting data, right? There's the service 22, read data by ID. So if you have IDs, you can read certain things out of there. That might be interesting in getting things out of it. Again, it might have, because it's its own separate application, it's a different session. There may be different DIDs available than what are in the application. So there's more or at least different information sometimes out of the bootloader. You may be able to read a specific spot in memory. There's a service 23, read memory by address. And again, these are all like, these are just the ISO services that are defined, right? That's, you know, you can look them up online. Write specific parameter data. So write data by ID. That's available. Write memory by address. That's, you know, that's a service. Usually there's range checking and stuff in there if it's done, implemented correctly. But again, there's, you know, there's a lot of powerful things available if you can get around, you know, security there. Another attack factor is man in the middle of the programming sequence. So if you have a valid tester, even without knowledge of, you know, the security or anything like that, you may be able to record the programming sequence. You may be able to replace certain parts of it. You could potentially intercept firmware over the wire because lots of OEMs don't, like, encrypt the data once it gets to the CAN bus. It might be encrypted at rest. It might be encrypted in the cloud when they pull it down. But the ECU doesn't have, like, the symmetric keys in it to, like, decrypt the firmware. So it's usually just transmitted over. You know, unencrypted. Again, this, you know, it's all OEM specific and people are moving towards encrypted firmware, of course. But, you know, that could be with a valid tester. That could be easier than, you know, trying to get JTAG on a device and pulling the firmware, right, if you can just snoop it off the bus. Again, I mentioned this before, replay attacks on certain sequences. So if the tester is validly doing something. Interesting. Maybe you can record that in CAN and then replay it. And how would you do something like that? Well, I'll get to that in a second. Also, by nature of what the tools have to do, right, the programming tool is going to have the images, right? You have to flash these images to the ECU. So if the tool itself is not well programmed. Protected. That may be, like, an easier attack vector than trying to, like, you know, get a buffer overflow in a bootloader or trying to get JTAG or somehow, like, taking this, you know, pulling the firmware off the ECU. Because the programming tool itself needs to have the firmware because it's sending it to the ECU. You can also get information about the proprietary programming sequences and things like that because, you know, unless you have specs from an OEM or, you know, have access to this stuff. It's all highly secretly guarded, right? Also, anytime, you know, it's using any kind of, like, symmetric keys, like if it's the CT algorithm is not authenticated all the way to, like, a back end, the tool itself, you know, may have the symmetric keys for CT. So instead of trying to reverse engineer this firmware or, you know, hack into an HSM on an ECU, the programming tool might just have all the algorithms in it. Another thing that's awesome about UDS is that so that the way a seed key is designed is basically it's like a, you know, it's like a blind butler. Like, you do the secret knock and he opens the door and then anybody can go in. So once you've, you know, once you've unlocked the ECU or gotten into that session, then you can just kind of keep that session alive from a valid tester and then send whatever messages you want. So kind of snooping. So a valid session, you could hijack that and send kind of other things. So having access to these testers or if you're on the bus at the same time, it's kind of, you have lots of access there. Other attack vectors. A bootloader trojan. So, you know, there's ways to even gain persistence on an ECU by downloading a bootloader that overwrites the bootloader, right? There's products that do this for updating bootloaders. And essentially you program an application into the, as the new application has to look like a valid application and then it just overwrites your bootloader with its own bootloader. You might lose your keys. You might, you know, now you gain permanent persistence on the ECU. So what makes this even more scary? So before, for all of this, you had to have a bootloader. You have physical access to the vehicle, right? So it doesn't scale well. I can't physically walk to a thousand or a million different vehicles and start changing the firmware on them. But don't worry. Everyone solved this problem because now everyone wants to add over-the-air programming. So many OEMs are incorporating this. Implementing it just like a diagnostic tester that's connected to the Internet, right? Right. So depending. So depending on how secure that is, that can put in a lot of challenges, right? OTA is awesome. It's great for fixing bugs. We can add features. We can do security updates. It helps facilitate, you know, rolling out recalls, like fixing recalls and stuff because you can push these things out quickly. But OTA basically is remote code execution. And generally that's bad. In terms of a security model. So it's like, it's the savior, but it's also the thing that can really hurt us. It's kind of a two-edged sword. And it opens up some interesting challenges that we might not have had before. So attacks on, like, repositories itself. There's, you know, DEF CON's huge, right? There's all kinds of fun talks going on. And I'm sure somebody, maybe this year. Or certainly in previous years, we've talked about, like, repository attacks on updaters, like for Ubuntu and, you know, Windows Update and all that. Same thing with automotive, right? If we're doing OTA updates, it's opening up attack vectors for, you know, exfiltrating code, signing keys, you know, repository poisoning, things like that. Also, there's some challenges. There's some challenges in keeping OTA going because the car has intermittent connectivity. You know, if it's parked in a garage, it doesn't, you might not have access for who knows, right? Or somebody might park this car in a garage for 20 years and then turn it on. And now you have, you know, 6 million software updates. You can't drive your car for three weeks because it's downloading. And then, like, man in the middle. Type of thing. Type of tax to the vehicle. You know, it's literally a moving network, computer network. So, it's a really challenging IT problem to maintain this kind of infrastructure and securing all of that. So, there's a lot of new challenges that could prevent updates or pass bad information to the cloud or to the vehicle. And so, it kind of, it's pushing, you know, OEMs to have to really think about the full end-to-end lifecycle for updates. Oh, yeah. Yeah, and cars move. So, if you brick your phone, usually that's, you know, that's a bummer. But if you brick somebody's car and they're in the middle of, I don't know, the desert, they're not going to be particularly happy. There's also all kinds of, like, OTA attacks. So, there's a project called Optane that's doing, like, a security model framework for OTA attacks. And they've kind of enumerated. Okay. So, there's a whole bunch of different things, like malicious software attacks, you know, updating, trying to poison the cache with bad updates. Freeze attacks where you're stopping the, basically stopping the updates from happening by slowing it down. Or maybe you have, like, bad vulnerable software trying to get the ECU to roll it back to a bad version. There's a lot of challenges and lots of ways to, like, DOS the system. So, it's quite a big challenge. So, now that I've bummed everybody out, or maybe made them excited because maybe they're trying to hack cars. This is the car hacking village, right? So, what's the industry trying to do to make it more secure? And for people that don't care about that, that also means what might not be implemented right now. Things like code signing, right? Where I take a message digest. You're signing it with private key. Penning that to the data. And then verifying it on the ECU side. So, this is one of the, like, I mentioned that Optane project. This is one of the things that that project is really trying to, like, set up delegations for how you make a signature scheme for automotive really fault tolerant against different types of attacks. So, a lot of work being done there. Secure boot. Push and secure boot. You know, so this is like building a chain of trust to ensure the authenticity and integrity of code at startup. Small ECUs that have just like a, like a She module, which is like a small HSM. You know, these might have like a really simple secure boot. But if you get into like the systems on a chip, there's the main line talk, I think, yesterday about the Qualcomm firmware. And he showed like the Qualcomm firmware secure boot chain. Right. like, it was like 45 different things. So each one of these might have like, could have a vulnerability, right? And you have to try to protect that whole thing. So these can get really complicated and really, really tricky. And also who owns the keys for a secure chain as it becomes really complicated. Because it could be in automotive, we have this big, huge supply chain and different stakeholders might need to own different parts of it. So like an OEM might want to own some things, but the original equipment, like tier one supplier might also, you know, need a stake in it. So it's like, these things can get really complicated and they're hard to, they're tricky to really secure. But we're working on it. Another big thing, like this is, you know, what I work on all the time. Hardware security modules. So this is like hardware acceleration. So this is like hardware acceleration to help facilitate some of these things. So like I mentioned before, you know, you've got the seed key. So often one of the big problems with that is like really, really poor entropy on your seeds. So somebody might just implement, because we don't have like, there's no like real time clock. There's no, you know, good timers. You don't have a good source of entropy on these ECUs. So, you know, people would implement this like super awesome proprietary random drummer generator and, you know, it throws out four different random numbers or something. So it's really easy to replay these seeds. So hardware facilitated true random number generation, that really helps with certain things like that. Protected key storage. AES hardware acceleration for symmetric crypto or other symmetric crypto accelerators. Having public key crypto accelerators in there. Again, you know, the idea is to protect all the keys and also try to help accelerate some of these things. So, you know, we can do, enable things like real time authentication and encryption and message authentication and things like that. There's also things to like enable secure boot in hardware. One of the challenging things with this, though, is that there's not like a one spec to rule them all in automotive. So a lot of stuff is using like TPMs for, you know, like IOT or AT and, you know, traditional AT. In automotive there's this like baseline specification from the, this is like the hilarious German pun here. They called it the HISS she. So HISS is like the Hersteller Initiative software. It's like a consortia of like a bunch of German suppliers and OEMs. And they created this she spec which is a secure hardware extension. And it just defined a little bit of, like, certain things in hardware that they would, that they specified for security. And it's, it's kind of like a standalone peripheral. And so a lot of silicon vendors have implemented that. And have, have support for that. But OEMs are, you know, moving even beyond that. A lot of people need more keys or they need, you know, more specific stuff like a secure execution environment. There's a, there's another, there's another few years in the range of some of years later, a group in Europe called Aveda, it was like a government, EU sponsored consortia. And they came up with like another spec that kind of divided it up into like three different levels. So this low, medium, full Aveda spec. And so this is like the highest one, you know, has a secure code execution, a coprocessor and everything like that. So again, SOC inventors are like implementing stuff like that. Like we have one called ICUM for that. But other SOC inventors like NXP has the CSC, which is the cryptographic services engine and Finneon's got their own stuff. Arm has the Trust Zone. And, you know, there's been a bunch of talks on Trust Zone hacking stuff. So if you're interested in that, there's lots of information on Trust Zone stuff. So it's kind of a big challenge because there are so many different varieties. And I don't know if you've heard of it, but there's a lot of information on Trust Zone hacking stuff. There's no like just common, you know, API for, okay, here's the automotive API and spec for building this secure hardware as a chip vendor. So every OEM kind of just has their own flavor of how it works. So again, this is a challenge. But there's also committees that are working on kind of creating more common specs. There's an SAE group for that. And there's also an ISO group that's working on kind of like common security practices. Some more stuff. So ECU hardening. This is just like general security, good hygiene stuff. But, you know, you'd be surprised how often this doesn't happen. And most of the OEMs have specs now that say like, yeah, you have to lock the JTAG. But, you know, you have to lock the JTAG. Or, you know, tamper protection. Things like if the tamper protection is detected, it erases your keys out of the HSM. So even if somebody gains access, they can't get the keys out. Or can't use the, you know, can't use the thing. Again, good crypto hygiene. Don't use the same key across all of your cars like some OEMs have done. But, you know, this hardware stuff basically helps. Enable some of the higher level, like protocol level kind of security. Like doing authenticated CAN. So there's a thing called AUTOSAR, which is like a software and it's open standard software initiative or something. I've had it and I'm forgetting what it stands for. I should know that. Yeah. But anyway. It defines like a protocol for doing secure authentication. So it's like a protocol for doing, you know, something to confirm a security. You know, for a security that's not gonna be as well known or as well known for a car. So, you know, thing to do. So, you know, we've got the default OEMs. And then we have a little bit of authentication. So, if you have, you know, an OEM is a very common problem that people have. So, you know, there's a lot of options. And then there's also authentication. So if you have, you know, know, some signed piece of information that you can verify with a public key. So I'm going to do it on time. So on summary here, bootloaders give you powerful access to automotive ECUs. We started adding OTA to these things and it's making everyone's lives really difficult. But it's keeping us all employed, so that's good. It really opens up the attack service for remote exploitation. It's the enabler to be able to do updates and to push security patches and things like that, but it makes stuff extremely difficult. I think automotive vehicles is one of the most difficult things to do OTA on because it's this big thing that's moving that could smash into something. And then, of course, we're working on this. We're working on securing the ECUs, but are we doing it fast enough? Are we there yet? Of course, the answer is no. We're still working on that. It's improving incrementally, of course. So thank you. I really appreciate you guys taking your time to lose your happy hour drink prices and sit here and watch and listen to me. Thank you. Thank you.