Hacker Zhi Xu has found that seemingly legitimate apps can unleash a hidden dark side to compromise almost half of all Android devices.

The Palo Alto Networks senior engineer says legitimate Google Play apps can establish a kind of beachhead on devices that can be invaded by a second app installed from legitimate third party stores like Amazon. The second app provides the first with the required access to compromise devices and steal all manner of data.

Xu says the attack dubbed Android Installer Hijacking allows crims to replace apps without a user's knowledge.

"The malicious application can gain full access to a compromised device, including usernames, passwords, and sensitive data," XU says in an advisory.

"This hijacking technique can … substitute one application with another, for instance if a user tries to install a legitimate version of Angry Birds and ends up with a flashlight app that’s running malware."

Google, Samsung, and Amazon are some of the organisations working to fix the flaws.

Users should upgrade to at least Android 4.4 to avoid being exposed.

The problem exists in part because the PackageInstaller used to install Android apps contains a time-of-Check to Time-of-Use vulnerability that allows malicious apps to replace legitimate ones.

This replacement attack could only take place when apps are downloaded to unprotected file system spaces, a feat which occurs only outside of Google Play.

"... PackageInstaller on affected versions does not verify the APK (Android app) file at the Time of Use [meaning] the PackageInstaller can actually install a different app with an entirely different set of permissions," Xu says.

The hacker says attackers must first have their seemingly benign app installed from Google Play. From there it could watch for any apps installed from stores like Amazon; if it detects any, it could quietly replace the app with a malicious version during the installation process as users reviewed permissions such as the ability to access the camera.

This attack will work only on devices running Android 4.1 and below, or those which have been modified to enable root access.

In an alternative attack, bad guys could publish seemingly legitimate Google Play apps that promote their malicious apps located on Amazon. If the user took the bait, the exploitation process would remain the same.

No real world attacks have been detected, vendors say.

Some newer Android 4.3 handsets are vulnerable exceptions including Samsung Galaxy S4 phones and Amazon Fire fondleslabs running build version JSS15J.I337UCUEMK2, and version 13.3.2.5 respectively. Updates for those devices are available.

Xu called on all vendors to verify if a hash check fix which squashed the flaw is applied to their operating systems. ®