Among the four dozen vulnerabilities Google patched this week was a fix for a bug that allowed attackers to inject malicious code into Android apps without affecting an app’s signature verification certificate.
The technique allows an attacker to circumvent device anti-malware protection and escalate privileges on targeted device with a signed app that appears to be from a trusted publisher, according to researchers.
The vulnerability, dubbed Janus, was discovered earlier this summer by Eric Lafortune, CTO of GuardSquare. He reported the bug (CVE-2017-13156) to Google in July. Google patched the vulnerability as part of its December Android Security Bulletin. Public disclosure of the bug was Thursday. As part of his research, Lafortune created a proof-of-concept tool, also called Janus, which allows an attacker to inject an APK file with a malicious DEX (Dalvik Executable) file. DEX files make up the code inside Android programs that are zipped into single APKs.
“An attacker could inject malicious code into a reputable app. Any user that downloaded and installed the app would become infected,” Lafortune said. One attack scenario includes Android APKs downloaded from third-party app stores that appear to be legitimate banking, social media or system utility apps.
“Any Android app – from a banking app, game to Google Maps – could be a Janus target. Once the infected app is installed the attacker would have the same system privileges as the app. That means an attacker could steal banking credentials, read messages or further infect a targeted device,” Lafortune said.
Impacted are Android devices running a version of the Android OS older than Nougat (7.0) and any Android devices that support the APK signature scheme v1. Android devices updated to support APK signature scheme v2, introduced in July 2016, are not impacted.
Google describes APK signatures as a “whole-file signature scheme that increases verification speed and strengthens integrity guarantees by detecting any changes to the protected parts of the APK.” Lafortune told Threatpost the Janus tool works by allowing an attacker to create an APK that ignores any extra bytes when computing or verifying the application’s signature.
“On the one hand, an APK file is a zip archive, which can contain arbitrary bytes at the start, before its zip entries…,” said the researcher. “On the other hand, a DEX file can contain arbitrary bytes at the end, after the regular sections of strings, classes, method definitions, etc. A file can, therefore, be a valid APK file and a valid DEX file at the same time.”
He said Janus is able to accomplish this because a preceding and separate JAR signature scheme only takes into account the zip entries. “It ignores any extra bytes when computing or verifying the application’s signature,” he said.
Since applications that have been signed with APK signature scheme v2 are not impacted, Lafortune recommends developers should always apply signature scheme v2 to ensure apps cannot be tampered with.
Download SafeUM — communicate privately, without advertising and spam.