Hiding a malicious Android APK in images as evasion method

Pierluigi Paganini October 21, 2014

Two researchers at Fortinet have demonstrated during the last Black Hat Europe conference how to hide a malicious Android APK in images.

Mobile devices are continuously under attacks, cyber criminals are improving their technique to attack mobile users and increase the profits.  A new technique recently disclosed, allows attackers to hide encrypted malicious Android applications inside images, the method allows threat actors to evade detection by antivirus products and according the experts potentially also the checks run by Google Play’.

The new attack technique was developed by Axelle Apvrille, a security researcher at Fortinet, in collaboration with reverse engineer Ange Albertini. The researchers presented their proof-of-concept last week during the last Black Hat Europe security conference.

The methods exploit a technique designed by Albertini dubbed AngeCryption, which allow to encrypt anything into whatever we want (apart a few restrictions on input and output formats) using a Python script written by the researcher. The script receives in input the content user wishes to encrypt , the output user wishes to receive and it will calculate a specified key using AES in cipher-block chaining (CBC) mode that produces the expected output file..

The script elaborates the input, “without altering the information it contains, so that the input encrypted with the provided key and a generated initialization vector (IV) turns into the output.”

The two researchers at Fortinet applied the concept to Android application packages (APKs) files, they created a proof-of-concept wrapping application that displays a PNG image of Anakin Skywalker, one of the characters of Star Wars saga. The app they developed is able to decrypt the image with a particular key in order to obtain a second Android APK file that it will install.

During their presentation at the BlackHat, the researcher used an encrypted APK that once extracted by the principal app displays a picture of Darth Vader, in a real attack scenario the hackers could run a malicious application to control the Smartphone or to steal user’s, including SMS messages, photos and contacts.

Malicious APK attack uses angecrypt_anakin

During the presentation the Android device displayed a permission request when the wrapper application tried to install the decrypted APK file, but as explained by Apvrille this behavior is easy to avoid invoking a method called DexClassLoader.

Another interesting thing is that the malicious APK could be also downloaded from a remote server without triggering any alert due the to the encryption applied.

As explained the researchers there is anyway a condition to satisfy in order to successfully run the attack, some data needs to be appended at the end of the original application, but the APK format does not allow to append any data after a marker called the End of Central Directory (EOCD), which is a sort of end of the file.

The researcher bypassed the limitation, adding a second EOCD after the appended data, this procedure tricks Android into accepting the file as valid. It’s clear that APK parser fails to correctly parse the code provided on input.

The researchers have already reported the security issue to the Android security team that is currently working on a fix. The attack works on the latest version of Android, Android 4.4.2.

Because of fragmentation in the Android ecosystem, especially when it comes to firmware updates, many devices will likely remain vulnerable to this attack for a long time, giving Android malware authors ample time to take advantage of it.

The researchers speculated that the vulnerability will probably remain active for a long time on many devices because the fragmentation in the Android ecosystem and different patch management of various vendors.

The proof-of-concept code used during the presentation is available on Github.

Pierluigi Paganini

(Security Affairs – APK, Android)



you might also like

leave a comment