Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

0-Click RCE on Tesla Infoainment Through Cellular Network - 2236

SyacktivPosted 18 Days Ago
  • Tesla was a target for Pwn2Own in 2024. From reverse engineering the system (free root shell via test pads), they found multiple issues that allowed them to get RCE. Tesla does harden their system well but, once inside, many assumptions just break down.
  • The ql_atfwd AT command handler contains a straight forward command injection vulnerability. This listens on 192.168.90.60:50950 but there's an Iptables rule that prevents connectivity from a cellular network. By happenstance, they noticed that the firewall wasn't turned on sometimes. But why?
  • While booting systemd, it starts two processes: firewall with default rules, and QCMAP_Connectionmanager for adding the dynamic iptable rules. If firewall can't lock, the default rules are simply not loaded, and it exits. Since this only worked 25% of the time, they had to find a way to trigger this themselves.
  • A connectivity card reboot is implemented on the infotainment system. When LTE connectivity is established, it checks for Internet access. If this fails three times, the card is rebooted. A cellular network can make this test fail but there is a limit of 4 reboots every 30 minutes via NTP. Since NTP can also be spoofed, this gives us effectively infinite retries to trigger this race condition that takes down the firewall.
  • So, the first part of the chain is as follows:
    1. Attacker runs a base station (fake cellular modem) that affects the local IP of the client.
    2. If Firewall is active, reboot the board via the connectivity check issue described above. If it's not enabled, then proceed
    3. Send the AT command with the command injection. They use this to permanently disable the firewall, add SSH keys, and deliver the next stage of the payload.
  • Once on the mode, we need to be able to spread to other parts of the car. On the network, we can connect to the infotainment, and to another modem. The infotainment contains two plugins for the Ofono AT handler with a simple text-based protocol that is terminated with \r\n. In one of the plugins, they found a heap-based buffer overflow via an unchcked strdup call. This was a controlled size, controlled allocation size, but couldn't use null bytes, and had no shaping capabilities on the rest of the heap.
  • They perform a heap overflow that leads to overwriting the heap metadata on glibc chunks. By targeting the tcache, they are able to corrupt the size, that leads to incorrect sized chunks to be returned. They use this primitive to overwrite the structure Ofono that can be requested by the user with arbitrary data. They used the same tcache overwrite to overwrite a function pointer to call libc to get arbitrary code execution.
  • Tesla has some extra protections in place that they have to bypass called XPIN that hooks memory management syscalls, hooks mprotect calls, and such, similar to SELinux. To bypass this, they used a fallback on a Linux kernel Copy-On-Write (COW) with a modified mapping to write to the .data section of a library to execute code. SELinux detects when a mapping is modified by XPIN did not.
  • Ofonod was also heavily sandboxed with SecComp filters, Apparmor, iptable restrictions, and namespace restrictions but DID have CAP_NET_ADMIN. Even though it was heavily sandboxed, an attacker can A) rename the network interfaces, B) change the IP configuration, and C) forward packets to the security gateway. I don't fully understand WHAT this gets you but all of this doesn't sound great.
  • As a few takeaways, they got lucky on the amount of time this took. The race condition was lucky, and the command injection was found on another device already. According to them, the Infotainment exploit will become hard because the sandbox is hard to escape, and simple bugs like the XPIN heap overflow will be killed.
  • Overall, an awesome presentation! Very little fluff, and a lot of bugs to get to their end goal. It's cool to see Tesla freeze the version one month before the event, and give the teams so much support to get this working.