MMS • RSS
The upcoming Android P, which was recently released in beta, will use more compiler-based security mitigations, writes Google engineer Ivan Lozano, including control flow integrity and integer overflow sanitization.
The basic idea behind compiler-based mitigations, a set of features provided by the LLVM/Clang compiler, is instrumenting runtime operations at compile-time to catch operations that trigger undefined behavior and make them fail safely. LLVM/Clang supports a number of sanitizers, including divide by zero, nullability violations, negative array bounds, and control flow integrity.
Google started to use LLVM/Clang sanitizations back in the days of Android Nougat (which was then released as Android 7), and has been later adding control flow integrity checks in Android O (Oreo, Android 8.0). With Android P, writes Lozano, Google has significantly extended support of both sanitizers and control flow integrity across a number of components of the OS, including the media frameworks and other security-critical components such as Bluetooth, NFC, and the kernel.
Control flow integrity addresses code-reuse attacks, where an attacker leverages existing code, for example by finding short code sequences ending in a
ret instruction and executing them in arbitrary order. This allows the attacker to take control of the stack without the need to inject any code, which greatly increases the complexity of detecting such attacks. To counter such kind of attacks, control flow integrity aims to confine a program’s control flow to a reduced call graph determined at compile time. If the program tries to branch to an unexpected call target, then it is aborted in a safe way. Control flow integrity has a cost, both at compile and run time, but Google testing on Android showed it is negligible, says Lozano.
As to sanitizers, Google has extended the use of the integer overflow sanitizers to a number of libraries, including
libnl, and others. Integer overflow is a common means for attackers to take control of a program and was at the heart of the Stagefright vulnerability that affected previous versions of Android. Google’s contribution here has been improving LLVM integer overflow sanitizers to reduce their overhead by over 75% in a number of cases.