Extracting SecOC Keys From A 2021 Toyota RAV4 Prime

Extracting SecOC Keys From A 2021 Toyota RAV4 Prime

Source Node: 2508013

With the recently introduced SecOC (Secure Onboard Communication) standard, car manufacturers seek to make the CAN bus networks that form the backbone of modern day cars more secure. This standard adds a MAC (message authentication code) to the CAN messages, which can be used to validate that these messages come from a genuine part of the car, and not from a car thief or some third-party peripheral.

To check that it isn’t possible to circumvent SecOC, [Willem Melching] and [Greg Hogan] got their hands on the power steering (EPS) unit of a Toyota RAV4 Prime, as one of the first cars to implement this new security standard.

<img decoding="async" data-attachment-id="666665" data-permalink="https://hackaday.com/2024/03/08/extracting-secoc-keys-from-a-2021-toyota-rav4-prime/pcb_pinout_thumb/" data-orig-file="https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg" data-orig-size="2787,2787" data-comments-opened="1" data-image-meta="{"aperture":"1.78","credit":"","camera":"iPhone 15 Pro","caption":"","created_timestamp":"1701859308","copyright":"","focal_length":"6.86","iso":"500","shutter_speed":"0.02","title":"","orientation":"1"}" data-image-title="PCB_pinout_thumb" data-image-description data-image-caption="

The 2021 Toyota RAV4 Prime’s power steering unit on the examination bench. (Credit: Willem Melching)

” data-medium-file=”https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime.jpg” data-large-file=”https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg?w=625″ class=”size-medium wp-image-666665″ src=”https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime.jpg” alt=”The 2021 Toyota RAV4 Prime’s power steering unit on the examination bench. (Credit: Willem Melching)” width=”400″ height=”400″ srcset=”https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg 2787w, https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg?resize=250,250 250w, https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg?resize=400,400 400w, https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg?resize=625,625 625w, https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg?resize=1536,1536 1536w, https://platoaistream.net/wp-content/uploads/2024/03/extracting-secoc-keys-from-a-2021-toyota-rav4-prime-1.jpg?resize=2048,2048 2048w” sizes=”(max-width: 400px) 100vw, 400px”>

The 2021 Toyota RAV4 Prime’s power steering unit on the examination bench. (Credit: Willem Melching)

As noted by [Willem], the ultimate goal is to be able to run the open source driver assistance system openpilot on these SecOC-enabled cars, which would require either breaking SecOC, or following the official method of ‘rekeying’ the SecOC gateway.

After dumping the firmware of the EPS Renesas RH850/P1M-E MCU via a voltage fault injection, the AES-based encryption routines were identified, but no easy exploits found in the main application. This left the bootloader as the next target.

Ultimately they managed to reverse-engineer the bootloader to determine how the update procedure works, which enabled them to upload shellcode. This script then enabled them to extract the SecOC keys from RAM and send these over the CAN bus. With these keys the path is thus opened to allow any device to generate CAN messages with valid SecOC MACs, effectively breaking encryption. Naturally, there are many caveats with this discovery.

As noted in the blog post, the specific MCU targeted did the crypto routines in software rather than using a more secure hardware module, while also omitting to validate the payload sent to the bootloader. That said, it might be that this approach works even with much newer SecOC implementations. Some experimentation on a 2023 Corolla Cross demonstrated that its power steering unit could also be coaxed into allowing code execution via the bootloader, but further attempts at defeating SecOC on it haven’t been made yet.

A GitHub repository containing the the software tools to extract keys and such has been made available.

While SecOC promises to make the future of CAN hacking more difficult, there’s still millions of vehicles on the road that are all too happy to let you poke around in their data networks — allowing you to do everything from pulling EV battery info to adding a backup camera so long as you have the proper tools.

Time Stamp:

More from Hack A Day