Mobile Security Srdjan Matic < srdjan@security.di.unimi.it > - - PowerPoint PPT Presentation

mobile security
SMART_READER_LITE
LIVE PREVIEW

Mobile Security Srdjan Matic < srdjan@security.di.unimi.it > - - PowerPoint PPT Presentation

Universit` a degli Studi di Milano Facolt` a di Scienze e Tecnologie Dipartimento di Informatica Mobile Security Srdjan Matic < srdjan@security.di.unimi.it > Aristide Fattori < aristide@security.di.unimi.it > A.A. 20132014


slide-1
SLIDE 1

Universit` a degli Studi di Milano Facolt` a di Scienze e Tecnologie Dipartimento di Informatica

Mobile Security

Srdjan Matic <srdjan@security.di.unimi.it> Aristide Fattori <aristide@security.di.unimi.it>

A.A. 2013–2014

slide-2
SLIDE 2

McAfee Q2 2013

Threat Report for Mobile Malware Threats

Source: McAfee Threats Report: Second Quarter 2013

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 2 / 36

slide-3
SLIDE 3

McAfee Q2 2013

Threat Report for Mobile Malware Threats

Source: McAfee Threats Report: Second Quarter 2013

1 Banking malware 2 (Fake) adult entertainment and dating apps 3 Weaponized legitimate apps that steal user data 4 Fake app installers that actually install spyware Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 2 / 36

slide-4
SLIDE 4

Android Malware: the Rise

Why?

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 3 / 36

slide-5
SLIDE 5

Android Malware: the Rise

The rise of Android malware is due to many factors

Widely adopted on heterogeneous devices Producers push patches/updates slowly Operators’ and Producers’ customizations (often closed-source) Rooted devices, jailbreaks Several custom ROMS: CyanogenMod, MIUI, Custom kernels, modems A number of interesting information on a phone Few (or none) barriers in official markets Unofficial markets without control

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 3 / 36

slide-6
SLIDE 6

Android Malware: the Rise

Version Codename Dist. 1.6 Donut 0.2% 2.1 Eclair 1.9% 2.2 Froyo 7.5% 2.3 - 2.3.7 Gingerbread 44.1% 3.1 - 3.2 Honeycomb 1.2% 4.0.3 - 4.0.4 ICS 28.6% 4.1 Jelly Bean 16.5% Source: Android Developers (Mar. ’13)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 3 / 36

slide-7
SLIDE 7

Android Malware: the Rise

Version Codename Dist. 2.2 Froyo 1.6% 2.3 - 2.3.7 Gingerbread 24.1% 3.2 Honeycomb 0.1% 4.0.3 - 4.0.4 ICS 18.6% 4.1 - 4.3 Jelly Bean 54.5% 4.4 KitKat 1.1% Source: Android Developers (Dec. ’13)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 3 / 36

slide-8
SLIDE 8

Information and Resources on a Phone

Personal information: SMS, contacts, mails, . . . Espionage: intercepting calls, SMSs, location, . . . Access to enterprise networks Money: sending SMS to premium-rate numbers Money: many phones have direct access to CC SPAM: phone ⇒ perfect spambot

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 4 / 36

slide-9
SLIDE 9

Background

slide-10
SLIDE 10

Dalvik and Zygote

Dalvik

Android Applications are coded in Java and interpreted by a custom VM, the DVM

Zygote

Every App has its own DVM instance, spawned by a Zygote process from where it inherits resources

Native Code

Native (ARM) code may be executed by an App through JNI or natively (NDK)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 6 / 36

slide-11
SLIDE 11

Dalvik and Zygote

Dalvik

Android Applications are coded in Java and interpreted by a custom VM, the DVM

Zygote

Every App has its own DVM instance, spawned by a Zygote process from where it inherits resources

Native Code

Native (ARM) code may be executed by an App through JNI or natively (NDK)

All running on top of a Linux OS

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 6 / 36

slide-12
SLIDE 12

Security Model

No application, by default, has permission to perform any

  • perations that would adversely impact other applications, the
  • perating system, or the user

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 7 / 36

slide-13
SLIDE 13

Security Model

No application, by default, has permission to perform any

  • perations that would adversely impact other applications, the
  • perating system, or the user

Sandboxing

Every App has its own UID/GID, used to enforce system-wide DAC

Permissions

To be granted a permission, App must explicitly request it (e.g., send an SMS, place a call)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 7 / 36

slide-14
SLIDE 14

Security Model

No application, by default, has permission to perform any

  • perations that would adversely impact other applications, the
  • perating system, or the user

Sandboxing

Every App has its own UID/GID, used to enforce system-wide DAC

Permissions

To be granted a permission, App must explicitly request it (e.g., send an SMS, place a call) All types of applications—Java, native, and hybrid—are sandboxed in the same way and have the same degree of security from each

  • ther.

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 7 / 36

slide-15
SLIDE 15

Android Apps Internals

Components

Activity

  • Provides a screen with

which users can interact;

  • e.g., write a text, view

a map, send an email. Service

  • Runs in the background

like Unix Dæmons;

  • e.g., async network
  • perations, receiving data;

Receiver

  • Listen (and respond)

to broadcast events from the system;

  • e.g., receive a SMS,

incoming calls; Content Provider

  • define a storage-agnostic

abstraction to transparently access data;

  • enforce access control;

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 8 / 36

slide-16
SLIDE 16

Intents

“An abstract representation of an operation to be performed” Three main components are activated by intents. Intents have different meaning/purpose depending on the recipient.

Intent Meaning per Recipient

Activity: an action that must be performed (e.g., to send an e-mail, an App will broadcast the corresponding intent; the email activity will therefore be executed) Service: similar to activity Receiver: a container for received data.

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 9 / 36

slide-17
SLIDE 17

Manifest File

<?xml version ="1.0" encoding ="utf -8"?> <manifest xmlns:android="http :// schemas.android.com /[...]" package="test. AndroidSMS" android: versionCode ="1" android: versionName ="1.0"> <uses - permission android:name="[...]. RECEIVE_SMS " /> <uses - permission android:name="[...]. SEND_SMS" /> <uses - permission android:name="[...]. INTERNET" /> <application android:label="@string/app_name" > <receiver android:name=". SMSReceiver "> <intent -filter > <action android:name="[...]. Telephony. SMS_RECEIVED " /> </intent -filter > </receiver > </ application >

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 10 / 36

slide-18
SLIDE 18

Manifest File

<?xml version ="1.0" encoding ="utf -8"?> <manifest xmlns:android="http :// schemas.android.com /[...]" package="test. AndroidSMS" android: versionCode ="1" android: versionName ="1.0"> <uses - permission android:name="[...]. RECEIVE_SMS " /> <uses - permission android:name="[...]. SEND_SMS" /> <uses - permission android:name="[...]. INTERNET" /> <application android:label="@string/app_name" > <receiver android:name=". SMSReceiver "> <intent -filter > <action android:name="[...]. Telephony. SMS_RECEIVED " /> </intent -filter > </receiver > </ application >

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 10 / 36

slide-19
SLIDE 19

Manifest File

<?xml version ="1.0" encoding ="utf -8"?> <manifest xmlns:android="http :// schemas.android.com /[...]" package="test. AndroidSMS" android: versionCode ="1" android: versionName ="1.0"> <uses - permission android:name="[...]. RECEIVE_SMS " /> <uses - permission android:name="[...]. SEND_SMS" /> <uses - permission android:name="[...]. INTERNET" /> <application android:label="@string/app_name" > <receiver android:name=". SMSReceiver "> <intent -filter > <action android:name="[...]. Telephony. SMS_RECEIVED " /> </intent -filter > </receiver > </ application >

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 10 / 36

slide-20
SLIDE 20

Binder

IPC/RPC

The Binder protocol allows fast inter-process communication between Apps or between Apps and the system. It also allows Apps to invoke other components’ functions (e.g., to place a call

  • r to send a SMS).

AIDL

The Android Interface Definition Language is used to define which methods of a service can be invoked remotely, among with their

  • parameters. AIDL specifications for Android’s core services are

available online.

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 11 / 36

slide-21
SLIDE 21

Binder

Low-level perspective

Binder Driver

The Binder core is implemented as a device driver. User-space processes (Apps) can interact with the driver through the /dev/binder virtual device.

ioctl

ioctls are used to by Apps to interact with the Binder. Each ioctl takes as argument a command and a data buffer.

BINDER WRITE READ

Allows data to be sent/received among Apps.

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 12 / 36

slide-22
SLIDE 22

Android Malware

Dissecting Android Malware: Characterization and Evolution

http://www.csc.ncsu.edu/faculty/jiang/pubs/OAKLAND12.pdf

slide-23
SLIDE 23

Infection vectors

Repackaged apps

Most used infection vector so far locate and download popular apps disassemble and embed malicious payload reassemble and resubmit Often mixed with update attacks

Other means

Drive by Spyware Trojans . . .

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 14 / 36

slide-24
SLIDE 24

Activation

Android apps have many different entry points that can be leveraged by malware to start their malicious activities

Most used events

BOOT COMPLETED SMS RECEIVED PACKAGE * (Actions on apps) ACTION MAIN (repackaged apps that replace main activity of original app) ...

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 15 / 36

slide-25
SLIDE 25

Payloads

Common payloads

Privilege escalation: exploid, RATC, Zimperlich Remote control: mainly through HTTP C&C Financial charges: SMS to premium numbers, automatically subscribing to premium services Information stealing

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 16 / 36

slide-26
SLIDE 26

Android Malware by Sample

DroidKungFu - 2011

One of the first really sophisticated malware found in the wild

Main Features

Root exploits (encrypted payload) Remote control through C&C channels (encrypted) Stealthy installation of embedded apps Obfuscation: strings, servers, payloads (also through JNI) Latest version use update attacks

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 17 / 36

slide-27
SLIDE 27

Android Malware by Sample

AnserverBot - 2011

Distributed through third-party Android Markets in China

Main Features

Anti-analysis: repackaging, integrity checks, obfuscation Anti-analysis(2): update attacks, dynamic code loading Anti-analysis(3): detection of anti-virus software 2 C&C channels: one classic and one based on blogs on baidu (encrypted)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 18 / 36

slide-28
SLIDE 28

Hands on!

https://code.google.com/p/androguard/ https://code.google.com/p/android-apktool/ http://security.di.unimi.it/sicurezza1314/demo.tar.gz Completare demo decompiler.py Usarlo per reversare demo/Demosicurezza/bin/Demosicurezza-debug.apk Repackare Demosicurezza nolog.apk in modo che stampi su logcat il contenuto del SMS ricevuto. Avete i sorgenti in Demosicurezza/ per comodit` a, ma il repackaging va fatto con apktool.

slide-29
SLIDE 29

Android Malware Analysis

slide-30
SLIDE 30

Malware Analysis Static Instrum. VMM

ADAM DroidRanger RiskRanker DroidMOSS

Static Instrum. VMM

DroidScope TraceDroid Bouncer ParanoidAndroid ActEVE Aurasium TaintDroid Andrubis DroidBox

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 21 / 36

slide-31
SLIDE 31

Malware Analysis: Static Static Instrum. VMM

ADAM DroidRanger RiskRanker DroidMOSS

Pros

  • Many information in the Manifest
  • Java is relatively easy to decompile
  • Potentially “sees” the whole behavior

Cons

  • Obfuscation & Optimization
  • Reflection
  • Dynamic code, Native code

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 21 / 36

slide-32
SLIDE 32

Malware Analysis: Dynamic Static Instrum. VMM

DroidScope TraceDroid Bouncer ParanoidAndroid ActEVE Aurasium TaintDroid Andrubis DroidBox

Pros

  • Resilient to obfuscation
  • Potentially transparent (VMM)
  • Less comples than static

Cons

  • Code coverage
  • VMI can be cumbersome (VMM)
  • Instrumentation can be detected

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 21 / 36

slide-33
SLIDE 33

System-Call Centric Analysis of Android Malware

Traditional Roots

A well-established technique to characterize behaviour of a proccess through system calls

(e.g. Anubis—http://anubis.iseclab.org/)

Can it be applied to Android?

Android architecture is different than traditional devices Are all the interesting behaviours achieved through system calls?

Dalvik VM (Android behaviour such as sending an SMS or receiving a call) OS interactions (i.e. reading/writing a file)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 22 / 36

slide-34
SLIDE 34

CopperDroid

A System Call-Centric Analysis and Stimulation Technique to Automatically Reconstruct Android Malware Behaviors

http://www.artificialstudios.org/alessandro.reina/pubs/eurosec13.pdf

slide-35
SLIDE 35

CopperDroid

Analysis Framework

Automatically reconstructs the behaviors of Android malware Unified analysis that avoid 2-level VMIs

All the behaviors are eventually achieved via system interactions Dalvik VMI optionally enabled to gather further insights

Dynamically stimulates Apps to disclose additional behaviors Extensive evaluation on 2,900 Android malware

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 24 / 36

slide-36
SLIDE 36

Architecture

CopperDroid Emulator

Android OS Dalvik Android/Linux Kernel

CopperDroid Framework

System Call Tracking Binder Analysis

RSP

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 25 / 36

slide-37
SLIDE 37

System calls on Linux ARM

Invoking Syscalls

Like on Intel, on ARM architecture invoking a system call induces a user-to-kernel transiction. (current CPL is stored in the cpsr register)

System calls on Linux ARM

On ARM invoked through the swi instruction (SoftWare Interrupt) r7 contains the number of the invoked syscall r0-r5 contain parameters lr contains the return address

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 26 / 36

slide-38
SLIDE 38

Tracking System calls

System call Analysis

Intercept when a syscall is invoked We need to intercept return to user-space too! There is no SYSEXIT/SYSRET to intercept Not every syscall actually returns to lr (e.g., exit, execve)

CopperDroid’s Approach

instruments QEMU’s emulation of the swi instruction instruments QEMU to intercept every cpsr write (Kernel → User)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 27 / 36

slide-39
SLIDE 39

Bridging the Gap

Processes and Threads

When dealing with out-of-the-box analyses it is essential to retrieve information about the analyzed system

CopperDroid VMI

CopperDroid inspects the Android Kernel to retrieve the following: Process Names PIDs & TIDs Process resources . . .

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 28 / 36

slide-40
SLIDE 40

Binder

The Binder protocol is the core of Android IPC/RPC. Intents are carried through binder Interactions with the system (SMS/Calls) go through binder Binder driver enforces (some) permission policies For example, applications cannot send SMSs on their own, but must invoke (RPC) the proper system service to do that.

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-41
SLIDE 41

Binder

Application

SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(”7855551234”, null, ”Hi There”, null, null);

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-42
SLIDE 42

Binder

Application android.telephony.SmsManager

public void sendTextMessage(...) { ... ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService(”isms”)); if (iccISms != null) iccISms.sendText(destinationAddress, scAddress, text, sentIntent, deliveryIntent); ...

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-43
SLIDE 43

Binder

Application android.telephony.SmsManager com.android.internal.telephony.ISms

public void sendText(...) { android.os.Parcel data = android.os.Parcel.obtain(); try { data.writeInterfaceToken(DESCRIPTOR); data.writeString(destAddr); ... mRemote.transact(Stub.TRANSACTION sendText, data, reply, 0); }

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-44
SLIDE 44

Binder

Application android.telephony.SmsManager com.android.internal.telephony.ISms Kernel (drivers/staging/android/binder.c) ioctl

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-45
SLIDE 45

Binder

Application android.telephony.SmsManager com.android.internal.telephony.ISms Kernel (drivers/staging/android/binder.c) ioctl CopperDroid

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-46
SLIDE 46

Binder

Application android.telephony.SmsManager com.android.internal.telephony.ISms Kernel (drivers/staging/android/binder.c) ioctl

ioctl(/dev/binder, BINDER WRITE READ, ... \x4b\x00\x00\x00\x49\x00\x20\x00\x74\x00\x61\x00 \x6b\x00\x65\x00\x20\x00\x70\x00\x6c\x00\x65\x00 \x61\x00\x73\x00\x75\x00\x72\x00\x65\x00\x20\x00 \x69\x00\x6e\x00\x20\x00\x68\x00\x75\x00\x72\x00 \x74\x00\x69\x00\x6e\x00\x67\x00\x20\x00\x73\x00 ...)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-47
SLIDE 47

Binder

Application android.telephony.SmsManager com.android.internal.telephony.ISms Kernel (drivers/staging/android/binder.c) ioctl

ioctl(/dev/binder, BINDER WRITE READ, ... InterfaceToken = com.android.internal.telephony.ISms, method: sendText, destAddr = 7855551234, scAddr = , text = Hi There ...)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 29 / 36

slide-48
SLIDE 48

Binder

CopperDroid Analysis

CopperDroid deeply inspects the Binder protocol intercepting a subset of the ioctls issued by userspace Apps.

write size write consumed write buffer read size ... BC * Params BC TR Params BC * Params ioctl(binder fd, BINDER WRITE READ, &binder write read);

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 30 / 36

slide-49
SLIDE 49

Binder

write buffer operations

CopperDroid analyzes BC TRANSACTIONs and BC REPLYs

BC * Params BC TR Params BC * Params target code uid ... data size buffer InterfaceToken Param 1 Param 2 ... struct binder transaction data

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 31 / 36

slide-50
SLIDE 50

Binder

write buffer operations

CopperDroid analyzes BC TRANSACTIONs and BC REPLYs

BC * Params BC TR Params BC * Params target code uid ... data size buffer InterfaceToken Param 1 Param 2 ... struct binder transaction data

ISms.sendText(78555.., ‘‘Hi there’’)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 31 / 36

slide-51
SLIDE 51

Binder

Some examples of interesting binder transactions

Interface Method IPhoneSubInfo getDeviceId getDeviceSvn getSubscriberId getIccSerialNumber getLine1Number getLine1AlphaTag getVoiceMailNumber ISms getAllMessagesFromIccEf updateMessageOnIccEf copyMessageToIccEf sendData sendText sendMultipartText

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 32 / 36

slide-52
SLIDE 52

Stimulation

Android malware needs to be properly stimulated to trigger more malicious behaviors and increase coverage of dynamic analysis. CopperDroid Ad-Hoc Stimuli

1 Identifies events the target reacts to

(mostly contained in the Manifest file)

2 During the analysis, injects custom events

(of those identified as useful)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 33 / 36

slide-53
SLIDE 53

Stimulation

CopperDroid Emulator

Android OS Dalvik Android/Linux Kernel

CopperDroid Framework

System Call Tracking Binder Analysis

RSP To inject events CopperDroid leverages MonkeyRunner

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 34 / 36

slide-54
SLIDE 54

Evaluation

CopperDroid analyzed 1,226, 395, and 1,365 malware respectively from: Android Malware Genome Project, Contagio repository, and McAfee UK.

28% additional behaviors on 60% of Genome samples! 22% additional behaviors on 73% of Contagio samples! 28% additional behaviors on 61% of McAfee samples!

# Malware Stim. Samples w/ Behavior

  • Incr. Behavior

Family

  • Add. Behav.

w/o Stim. w/ Stimuli 1 ADRD 3.9 17/21 7.24 4.5 (63%) 2 AnserverBot 3.9 186/187 31.52 8.2 (27%) 3 BaseBridge 2.9 70/122 16.44 5.2 (32%) 4 BeanBot 3.1 4/8 0.12 3.8 (3000%) 5 CruseWin 4.0 2/2 1.00 2.0 (200%) 6 GamblerSMS 4.0 1/1 1.00 3.0 (300%) 7 SMSReplicator 4.0 1/1 0.00 6.0 (⊥) 8 Zsone 5.0 12/12 16.67 3.8 (23%)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 35 / 36

slide-55
SLIDE 55

Future and ongoing research directions

Stimulation

So far, low hanging fruit approach: Need to find more complex, yet time-efficient solutions (Tainting/concolic exec run in the order of hours) Human-driven stimulation (scalable?) Application similarity

Detection

Leverage CopperDroid base of knowledge to create new detection approaches: lightweight non-root (?) detection of repackaged apps (?)

Srdjan Matic, Aristide Fattori Mobile Security A.A. 2013–2014 36 / 36