Charlie and Chris venture to reach a new level of vehicle compromise by exploiting the V850 microcontroller’s firmware to remotely issue arbitrary commands.Charlie Miller: So far in this story, we could only play with your radio. It’s kind of cool, but not super-cool. Chris Valasek: What we had to do now is figure out how this part worked (see left-hand image). We showed these diagrams last year at Black Hat, and we knew the radio touch but with CAN buses we just needed to figure out how.
Charlie Miller: And this is one of the reasons we chose the Jeep in the first place, because it has this diagram and it’s like, okay, if you own the radio – you own all the CAN buses, game over.Chris Valasek: Yeah, we named it the most hackable car because that’s what we thought we could get into the easiest. The way it actually works is you have this OMAP board that has all your stuff on it, and it was connected to a daughterboard that had a V850 chip through a serial line – they implemented SPI for their communications (see right-hand image).
Charlie Miller: That’s Serial Peripheral Interface. So the V850 is on the CAN network; the V850 can send CAN messages; the V850 can listen to CAN messages. The OMAP chip that we’re on can’t. It can only talk to the other chip.
Chris Valasek: This is the problem: we can’t send CAN messages in to control a car. We just had unique CAN message injection.Charlie Miller: And this is why Chrysler and other companies have correctly said “No, there’s isolation between the infotainment system and the CAN network.” They are kind of right. You know, there were many months that I tried to send CAN messages from the OMAP chip, trying to figure it out.
Chris Valasek: Yeah, going through Lua scripts trying to figure out which ones may be able to send CAN messages. You spent a lot of time trying to figure that out. But as we know, close only counts in horseshoes and hand grenades, so ‘kinda’ isn’t right. We identified the chip as V850ES/FJ3 series chip, and the nice thing is we knew we had a firmware for it because it came in the IoC update that you could download offline (see left-hand image above).
Charlie Miller: Right. So, when you plug the USB stick update into your car, it updates the files on the OMAP chip, but it also can reflash and update the V850 chip with new firmware.
Chris Valasek: Long story short, there is also a script that says “Hey, take this as a parameter and flash the V850 chip over SPI.” There is no code signing and there’s really no check, so all you have to do is come up with a bootleg firmware that you wrote yourself that does stuff, and you can update the chip, no questions asked.So, that’s how you get from being on the head unit to actually being on the V850 chip.
I’m going to fly through the rest of this (see right-hand image), because it’s really boring.We read datasheets a lot. We read a lot of datasheets (see left-hand image).
Charlie Miller: This is three months of reading datasheets.Chris Valasek: Finally, the nice thing is, IDA Pro had a processor module for the V850ES, we found the base addresses (see right-hand image).
Charlie Miller: This is hacking, not ‘Mr. Robot’.
Chris Valasek: Yeah, this is the hacking part. We were just sitting there for three months going through all this crap.
Charlie Miller: Even if Christian Slater really-really wanted to hack a car, it’s still going to take three months.Chris Valasek: Exactly. So, we set up the segments and we found a bunch of cool values (see right-hand image). There’s gp-relative addressing – again, read the paper, there’s a bunch of sections. We found where CAN buffers were and cross-referenced those to other pieces in the code (see left-hand image). According to the datasheet, here are values that set things like the ID and the data and all that good stuff. Our only problem was we couldn’t call this function directly from anywhere (see right-hand image). So we knew we could set up data, we knew we could get this function to send it if we wanted, but we had no way to call it. So, what did we do? We’re like, okay, we’ll find the SPI parser and figure out if we can send SPI messages and then, basically, trampoline that code into some other code, where we write shellcode and do code with code (see right-hand image).
Charlie Miller: Basically, since that made no sense…
Chris Valasek: I was trying to be funny.
Charlie Miller: Yeah, so first we looked in the existing firmware to see if there was some way the OMAP could sort of signal to send an arbitrary CAN message. But no matter how hard we looked, we couldn’t find that way. So we decided we would have to make a method that would do that, and then we would send a SPI (Serial Peripheral Interface) message to the V850, saying “Okay, send this message with this data now please.” That’s the approach we had to adopt.Chris Valasek: The sidebar – there’s a bunch of memcpy’s to fixed-sized buffers that take the size from the SPI message (see right-hand image). Again, I think we gave up looking for these after we found a few.
Charlie Miller: Yeah. So the point is, we are going to reflash the firmware, the V850 chip, because there’s no code signing. But even if they had code signing, we could bypass that by exploiting these memory corruption bugs on the V850 from SPI.Chris Valasek: But luckily, we didn’t. We wrote shellcode by hand, that’s kind of cool, right? Basically, it was, hey, use the SPI code as the trampoline; if it sees this byte it jumps to our shellcode that we put in unused section of the ROM; our shellcode sets up the buffers, blah-blah-blah, sends a message, returns – we’re all good (see right-hand image), boom! That’s how you send messages from being on a wireless chip through SPI to reprogram the V850 chip. The V850 now contains our backdoored firmware. If it receives this command, it’s going to look at these bytes; if it sees that byte it’s going to trampoline to our code; that’s going to take the data out of the SPI messages we just sent and use that as CAN data. And we can send arbitrary messages. That’s how you can physically control a car from wireless to internal.
Charlie Miller: Right. One little hurdle that we had to bypass on the way, though, was that this system, while it is designed for the OMAP chip to update the V850 chip, it’s only designed to do that with a USB stick in and the guy sort of pressing the buttons and that sort of stuff, which we don’t have remotely (see left-hand image above). And so there was just some sort of exercise to go through to do that, and it’s kind of hard because you can only update the V850 if it’s in bootloader mode. And if you put it in bootloader mode it resets the OMAP chip and then you lose control. Anyway, read the paper if you want details. It was slightly difficult.Chris Valasek: What happens when it goes wrong? It was covered on your warranty every time (see right-hand image), which is the best part.
Charlie Miller: Yeah, one thing I got to say for Chrysler is they stand behind their products.
Chris Valasek: They do, that’s for sure.
Charlie Miller: This happened twice. If you mess up flash in the V850, then the head unit just doesn’t work anymore. The first time, what happened was I was flashing it – and there’s no output that it’s going on – so it’s flashing, I didn’t know how it was doing and I was like “Fuck this,” and I just turned it off. It was half-flashed and it never came back on again. Don’t do that. The real upgrade mechanism doesn’t let you do that, it has safety. I had no safety, I was driving with my seat belt off. So, then I took it to the dealer and they’re like “What happened?” I was like “The screen doesn’t come on anymore…” I tried not to use words like “head unit” or “chip”, so I went on to say “The screen is all black, I don’t know.”
Chris Valasek: And Charlie was just texting me “I think they’re buying it, they’re gonna give us a new head unit.” I was like “Alright, sweet!”
Charlie Miller: To be fair, I never lied. The screen did not work. And then the second time, I think I screwed up something different. I told them “There’s something wrong, it doesn’t work again.”