Business Google shoehorned Rust into Pixel 10 modem to make legacy code safer - Cellular modems are complex black boxes of legacy code, but Google is making them safer with Rust.

  • 🏰 The Fediverse is up. If you know, you know.
  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
Link | Archive

1776116096349.png
The Pixel 10 series ships with Google's safer modem code. Credit: Ryan Whitwam

By Ryan Whitwam

Modern smartphone operating systems have myriad systems in place to improve security, but none of that helps when attackers target the modem. Google’s Project Zero team has shown it’s possible to get remote code execution on Pixel phone modems over the Internet, which prompted Google to reevaluate how it secures this vital, low-level system. The solution wasn’t to rewrite modem software but rather to shoehorn a safer Rust-based component into the Pixel 10 modem.

Cellular modems are something of a black box. Your phone’s baseband is its own operating system running legacy C and C++ code, which makes it an increasingly appealing attack surface. The core issue is that memory management in these systems is difficult and often leads to memory-unsafe firmware code on production devices. That can allow attackers to leverage serious vulnerabilities like buffer overflows and memory leaks to compromise devices.

So that’s not great—why are we still using this stuff? Part of the issue is just the inertia of embedded systems. Companies have been developing modem firmware based on 3GPP specifications for decades, so there’s a lot of technical debt at this point. Modems also have to operate in real time to send and receive data effectively, and C/C++ code is fast.

Google’s demonstrative hack of the Pixel’s Exynos-based modem is not the only one by a long shot. Project Zero researchers have identified more than two dozen Exynos modem vulnerabilities in recent years, 18 of which were classified as “severe.” Naturally, the issues were patched after discovery, but the complexity of modem code virtually guarantees there are more vulnerabilities lurking inside, ready to be exploited by a bad actor.

Getting Rusty​

Making modems safer means addressing these memory loopholes, and Rust is a great candidate for that. Of course, Rust is not the first memory-safe language to exist. Python, C#, and others also have safer memory management systems, but they rely on garbage collection to do it. Garbage collection can scan active memory while programs run to find and free up unused memory. This is safer, but it’s also slow, and that’s a nonstarter for real-time modem firmware.

Rust doesn’t have a slow garbage collector. Instead, it uses a mechanism called the borrow checker that ensures memory safety at compile time. This strict set of rules ensures that you can’t “forget” to free up memory—code simply won’t compile if the memory rules are breached. This is what makes Rust a memory-safe language.

However, not even Google can wave its proverbial hand and change how modem firmware is written—we’re talking about tens of megabytes of executable machine code, which is a lot. Not only would it be a herculean task to update decades of work, but many of the companies involved also consider the inner workings of modems to be trade secrets.

To protect the Pixel modem from zero-day attacks, Google focused on the DNS parser. As cellular features have migrated to data networks, DNS has become a core part of how phones work. Google explains that DNS requires parsing of untrusted data, and that makes it a major security concern, but it’s one you can solve with Rust.

Google chose the hickory-proto open source Rust DNS library, which is not particularly optimized but has broad adoption and support. The modem in Pixel phones is not a memory-constrained environment, which allowed the team to tack on a Rust component to make DNS in the existing code safer. The team stripped out the standard library dependencies, allowing it to compile to machine code for faster operation, which was then grafted onto the existing C/C++ modem code. In total, the Rust components added 371KB, which is workable in the Pixel modem.

Under this system, any attempt to trigger a vulnerability by manipulating memory runs into the Rust wall—it can’t be affected by malicious DNS packets. The Pixel 10 phones are the first to ship with this safer modem implementation. Google hopes this work will allow other platforms to make similar improvements, but the company notes the size of its chosen Rust library could be a problem for simpler embedded systems. It may be possible to address that by making the library more modular in the future. Google also sees this work as a foundation for integrating more memory-safe components into the cellular baseband in time.
 
The team stripped out the standard library dependencies, allowing it to compile to machine code for faster operation, which was then grafted onto the existing C/C++ modem code. In total, the Rust components added 371KB, which is workable in the Pixel modem.
So they didn't touch all the proprietary closed source modem code, they left it as a blob, they just replaced the standard C library (which was probably the ONLY thing open source) with Rust. WOW, THE MODEM IS FINALLY FREE GUYS, HALLELUYAH
 
So they didn't touch all the proprietary closed source modem code, they left it as a blob, they just replaced the standard C library (which was probably the ONLY thing open source) with Rust. WOW, THE MODEM IS FINALLY FREE GUYS, HALLELUYAH
Wouldn't the connection between the phone OS and the modem prevent the modem from being overtaken from malware because of Rust?
 
Wouldn't the connection between the phone OS and the modem prevent the modem from being overtaken from malware because of Rust?
No, in the FOSS world, many have tried to make a FOSS phone, from just taking an existing Android phone, putting AOSP on it and degoogling it, to making their entire hardware from scratch, except the modem which is too complex and nobody was able to do it yet. The issue isn't the modem being taken over from the OS, the issue is that the modem isn't a separate chip, it's so closely coupled to the main CPU, and it's a completely closed proprietary binary blob that nobody knows everything that's inside of. The most realistic scenario that privacy focused people are trying to prevent is the modem being able to access their private data in the OS, as it may have backdoor channels to the CPU's memory, it could theoretically directly read the OS's memory, including all the keys and decrypted data the user is accessing in the OS, thus nullifying all the security that a secure FOSS OS might give you. The modem might have a backdoor (or multiple) into the OS that is impossible to mitigate in the OS, and gives anyone that knows how to use the backdoor, 24/7 access to it. As the modem is always powered when the CPU is powered, it can always connect to radio networks, like the internet, and present the backdoor to the entire world, or it might be a passive listener of packets that will trigger the backdoor, even if not connected to any networks at all. It can simply listen to all packets in the air (like Bluetooth or WiFI packets not specifically destined to it but that contain the magic words that trigger the backdoor) that will then allow the attacker to activate the backdoor.
The problem isn't solvable until there is a completely FOSS modem firmware that can be built and flashed by anyone and that can replace all the functionality of the original modem.
Even if you look at phones like the Librem 5, which uses a completely separate modem on a miniPCIe card, only connected to the CPU with USB, this mitigates the potential backdoor to the CPU as it can't do that via USB unless there is also a vulnerable driver in the OS side, but the code of the modem is still a binary blob, so it might do bad stuff regardless (even if it can't access the OS's memory, it can intercept all cell traffic and calls and relay them to a 3rd party, for example). And it might be buggy and work like shit, and nobody can fix it, because it's closed source and the OEM doesn't give a shit. Like in the Librem 5 case.
 
The most realistic scenario that privacy focused people are trying to prevent is the modem being able to access their private data in the OS, as it may have backdoor channels to the CPU's memory, it could theoretically directly read the OS's memory, including all the keys and decrypted data the user is accessing in the OS, thus nullifying all the security that a secure FOSS OS might give you.
So would it be fair to say your concern is more of the propriety nature of the binary and the coupling of the hardware's Modem and CPU together? From the malware perspective would it be fair to say that you believe the modem would be infected via an already ready made backdoor in the binary of the modem, as opposed to perhaps someone opening a file they shouldn't have on their phone via the OS and having the modem infected that way?
 
So would it be fair to say your concern is more of the propriety nature of the binary and the coupling of the hardware's Modem and CPU together? From the malware perspective would it be fair to say that you believe the modem would be infected via an already ready made backdoor in the binary of the modem, as opposed to perhaps someone opening a file they shouldn't have on their phone via the OS and having the modem infected that way?
exactly

If the OS is open source, it could theoretically be made completely secure so that no malicious file could trigger any unwanted behavior. I say theoretically, practically there are always 0-days possible, but theoretically it could, with enough independent eyes on the source code that aren't bribed by malicious actors to look away.
 
Wouldn't the connection between the phone OS and the modem prevent the modem from being overtaken from malware because of Rust?
Rusts memory safety only extends so far, generally when it interacts with hardware, it has to run unsafe code because hardware does shit that cannot be guaranteed safe by compile-time safety checks. That only covers memory corruption though, there are many other bug classes that Rust does not protect against (e.g. logic vulns or race conditions like TOCTOU)
 
So would it be fair to say your concern is more of the propriety nature of the binary and the coupling of the hardware's Modem and CPU together? From the malware perspective would it be fair to say that you believe the modem would be infected via an already ready made backdoor in the binary of the modem, as opposed to perhaps someone opening a file they shouldn't have on their phone via the OS and having the modem infected that way?
The concern is the feds can roll up to your house (Edit: completely remotely if your phone carrier is cooperating) and take complete control of your phone without you knowing. Mic, camera, location, files (including placing files onto your device in order to frame you), everything. No need to try and tart it up to sound smart.
 
Rusts memory safety only extends so far, generally when it interacts with hardware, it has to run unsafe code because hardware does shit that cannot be guaranteed safe by compile-time safety checks. That only covers memory corruption though, there are many other bug classes that Rust does not protect against (e.g. logic vulns or race conditions like TOCTOU)
Or intentional bugs, 0-days, backdoors, remote shells, RCE's ... that are intentionally put into the binary blob that you have no idea what it does (but Rust(tm) will make sure the backdoor runs with 100% memory safety!)
 
Dumb Google. Rust should be banned and the people who write it & those who promote it exiled to the Amazon jungle. If for no other reason than it has a fucking horrible name. Rust = bad, retards.

Even if it’s the greatest thing since the wheel come up with a better name. Don’t associate your language with a substance universally connected with decay and poor maintenance.
 
Back
Top Bottom