MobDojoStart learning free

Exploits, Tools & Data Recovery · Bug Classes & Mitigations · Lesson 4 of 5

Memory-Safe Languages

How Rust and Swift remove whole bug classes, and why the switch takes years.

12 min70 XPLab in Pro

Rust in Android

Mitigations make bugs harder to use. A memory-safe language goes further: it stops most memory bugs from being written in the first place. The language checks that every write fits in its box and that nobody keeps using a freed locker, either while the code is being built or while it runs.

Android's apps and much of its framework were already written in Java and Kotlin, which are memory-safe. The trouble was the low-level parts, like media, Bluetooth and networking, which need a fast systems language and were written in C and C++. Google's answer was Rust, a systems language that checks memory rules when the code is built, without slowing the program down much.

Here's the timeline from Google's security blog:

Rust isn't magic. It has an escape hatch, marked unsafe, for the few places that must talk directly to hardware or older code. Google says about 4% of its Rust is in such blocks, and that they get extra review. Google also reported a bonus it hadn't expected: Rust changes were rolled back about four times less often than similar C++ changes.

Swift, and why it takes years

Apple took a similar path with Swift, the language it introduced in 2014 for building apps. In its 2025 Memory Integrity Enforcement post, Apple described Swift as an easy-to-use, memory-safe language. Many Apple apps and newer system parts use it, but iOS still contains a great deal of older C, C++ and Objective-C code. That's exactly why Apple also built hardware protections: they guard the code that hasn't moved yet.

Why not rewrite everything right away?

So the change is steady, not sudden. Google is extending Rust into more places, including the Linux kernel, firmware and its own apps. Apple keeps moving more of its code to Swift.

What does this mean for you? Over time, phones should have fewer of the most severe bugs, the kind used in zero-click attacks, and the remaining ones should be more expensive for attackers to use. It doesn't mean phones become bug-free. Logic bugs remain, old code remains, and mitigations still matter. The best thing a user can do is the same as ever: install updates quickly, since every fix, in any language, arrives that way.

Test yourself

Can you answer these?

  1. What was Google's main strategy for cutting memory safety bugs in Android?
  2. Google said bugs in a body of code fade over time as it ages, and it compared this to radioactive decay. Which term did it use? (two words, or hyphenated)

Answer them in the app to earn 70 XP (Pro).

Answer in the app