140
Security of the Android Operating System Yury Zhauniarovich [email protected] http://zhauniarovich.com University of Trento

Security of the Android Operating System - · PDF fileSecurity of the Android Operating System Yury Zhauniarovich [email protected] ... Android Security Internals

  • Upload
    lambao

  • View
    232

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security of the Android

Operating System

Yury [email protected]

http://zhauniarovich.com

University of Trento

Page 2: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

About://

M.Sc. in Computer Security from the Belarusian

State University

Ph.D. in Information and Communication Technology

from the University of Trento

The author of the free book “Android Security

(and Not) Internals” [1]

A reviewer of the book “Android Systems

Development How-to” [2]

A developer of several research prototypes based on

Android OS (YAASE [3], CRePE [4], MOSES [5])

Currently, a Postdoctoral Researcher at the University of Trento

2

Page 3: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Outline

General Bits and Pieces

Android Architecture

Android Security Internals

Security Problems and Solutions

Page 4: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

What is the codename of the

following Android version?

4

Page 5: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

General Bits and Pieces

Android Architecture

Android Security Internals

Security Problems and Solutions

Page 6: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Mobile Operating Systems

6

Page 7: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Why Android?

Open source system

On about 85% of all new mobile devices (according to the last IDC report [6])

A highly customized system (FacebookHome, Kindle Fire, different devices from China, CyanogenMod)

Running on different platforms (TV, Wearable, Auto)

Third-party applications can be easily developed

We can test third-party applications without publishing them in Google Play

1 million+ applications in Google Play

7

Page 8: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

History of Android (2002-2007)

8

• 2002:

– Andy Rubin, CEO of Danger Inc., showed the first phone Sidekick

at Stanford

– Larry Page and Sergey Brin attended this event and became users

of this phone

• 2003:

– Rubin has left the company because the things did not go well

– In October, Andy Rubin, Rich Miner, Nick Sears, and Chris White

founded Android Inc. in Palo Alto

• 2005:

– In August, Android Inc. is acquired by Google

Page 9: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

History of Android (2007-2009)

9

• 2007:

– November 5, Open Handset Alliance was announced

– The first product – Android

• 2008:

– In October, the first phone (HTC Dream) running Android 1.0 was

presented

• 2009:

– In April, Android 1.5 Cupcake was presented

– In September, Android 1.6 Donut appeared

– In October, Android 2.0 Eclair was announced together with a

new phone Motorola Droid (Milestone)

Page 10: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

History of Android (2010-2013)

10

• 2010:– Google launched Nexus series with HTC Nexus One

– Google announced Android 2.3 Gingerbread, which was the most popular version till 2013, together with Samsung Nexus S

– Android popularity first surpassed Apple iPhone’s

• 2011:– Android 3.0 Honeycomb for tabs released with Motorola Xoom

– Android 4.0 Ice Cream Sandwich appeared combining two development branches

• 2012:– Android 4.1 Jelly Bean, 4.2 Jelly Bean

• 2013:– Android 4.3 Jelly Bean, 4.4 Kitkat

Page 11: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Versions

Astro Boy and Bender were code names for pre-1.0 milestones

11http://www.xda-developers.com/android/the-evolution-of-android-part-i/http://www.androidpolice.com/2012/09/17/a-history-of-pre-cupcake-android-codenames/

Page 12: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Version Share

12

Data collected during a 7-day period

ending on August 12, 2014.

https://developer.android.com/about/dashboards/index.html

Page 13: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

What is the codename of

Android version 1.1?

13

Page 14: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

General Bits and Pieces

Android Architecture

Android Security Internals

Security Problems and Solutions

Page 15: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Stack

15

Page 16: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Linux Kernel

Linux Kernel is used:

Memory management

Process management

Security module

Networking

etc

Android Enhancements:

Ashmem

Power management

Binder IPC

Logger

etc

16

Page 17: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Native Userspace

Components

Hardware Abstraction Layer

Init / Toolbox

Native Daemons (rild, adbd, vold, etc)

Native Libraries

Libraries:

2D and 3D graphics

Media codecs

Font rendering

SSL

The core of web browser

Bionic libc

17

Page 18: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Runtime

Dalvik VM:

Virtual machine for Android to run applications

Provides application portability

Supports multiple instances

CPU and memory optimized to run on mobile devices

Core Libraries:

Data structures

Utilities

File access

Network access

Graphics

etc.

18

Page 19: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Application Framework

System Services:

Essential services to the Android platform:– ActivityManager Service

– PackageManager Service

– PowerManager Service

– etc.

Hardware access services:– Telephony Service

– Location Service

– Bluetooth Service

– etc.

Framework Libraries:

Provide API to services:– Activity Manager

– Package Manager

– Power Manager

– Location Manager

– Sensor Manager

– Telephony Manager

– etc.

19

Page 20: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Applications

System apps:

Supplied with the platform– Email application

– SMS application

– Contacts

– Phone

– Browser

– etc.

Third-party apps:

Apps produced by third-party developers– Evernote

– Facebook

– Dropbox

– Feedly

– Chrome

– etc.20

Page 21: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Stack

21

Page 22: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

General Bits and Pieces

Android Architecture

Android Security Internals

Security Problems and Solutions

Page 23: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

General Overview

Linux Kernel:

– Application Sandboxing

Android Middleware:

– IPC Reference Monitor

23

Page 24: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Security Internals

Linux Kernel Level

Native Userspace Level

Application Framework Level

Application Level

Page 25: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Linux DAC

25

Subject

user: user_xgroup: group_g

Object

Owner:owner: user_y

group: group_g

ACL:owner: rwx (7)

group: rw- (6)

others: r-- (4)

Action:write

•Process

•File•Socket

Page 26: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Application Sandboxing

Each app during installation:

– receives a distinct UID

– receives a distinct primary GID

– may receive membership in additional groups

UID and primary GID do not change during app’s life on a device

Each app process runs under its own UID

All app resources are owned by its UID

AID (Android ID) == UID26

Page 27: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

System Defined AIDs

UID range 1000-9999 is reserved

The values used to control access to:

– some system components (radio, camera, etc.)

• through running system processes with specified identities

• through assigning system components (unix-sockets, files, drivers) certain owners and permissions

– networking capabilities (paranoid networking patches)

The values used in Android are hardcoded in android_filesystem_config.h

27

Page 28: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

System Defined AIDs

28

system/core/include/private/android_filesystem_config.h

Page 29: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

System Component Protection

29

Camera

/dev/cam

Owner:owner: root (0)

group: camera (1006)

ACL:owner: rw- (6)

group: rw- (6)

others: --- (0)

Page 30: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Paranoid Networking Patches

Vanilla Linux: by default all processes have access to networking capabilities

Mobile: access to network is considered as dangerous functionality

– may drain your battery

– may send private data

Android: Applications run in sandboxes => Limitations on network functionality must be implemented at the Application Sandbox level => Linux Kernel should be modified

30

Page 31: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Paranoid Networking Patches

kernel/include/linux/android_aid.h

31

Page 32: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Paranoid Networking Patches

kernel/net/ipv4/af_inet.c

32

Page 33: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Can you describe other ways

of application sandboxing?

33

Page 34: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Security Internals

Linux Kernel Level

Native Userspace Level

Application Framework Level

Application Level

Page 35: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Boot Process

35

Page 36: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Filesystem

Does not comply with Filesystem Hierarchy Standard

Has standard Linux files as /dev, /proc, /sys, /etc, /mnt, etc.

Has Android-specific directories as /system, /data and /cache

36

Page 37: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Filesystem

37

Page 38: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security

Security at the Native Userspace Level is provisioned through:

– Setting certain filesystem permissions to files and sockets

– Running certain processes under specified credentials

– Controlling who can send commands through opened sockets and who can run current executables

38

Page 39: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Filesystem Permissions

Files, drivers, unix-sockets ownership and permissions are set:

– during the building of the system ROM {1}

– /init process {2}

– /init.rc file(s) {3}

– /ueventd.rc file(s) {4}

39

Page 40: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

System ROM {1}

System ROM

– system.img

– userdata.img

– cache.img

system.img, userdata.img, cache.img obtained during the building of the Android operating system

– At the compilation time must be defined:

• User and group names

• Filesystem ownership and permissions

system/core/include/private/android_filesystem_config.h

40

Page 41: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android System Usernames {1}

41

system/core/include/private/android_filesystem_config.h

Page 42: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Filesystem Definitions {1}

42

Page 43: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android-Specific Folders {1}

Mounting points for images:

– /system system.img

– /data userdata.img

– /cache cache.img

Core of Android:

– /system – contains Android OS except Linux Kernel (located on /boot)

– /data – stores user data or information that changes over the time

– /cache – is used to store frequently accessed data and OTA updates

43

Page 44: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

/init {2}

44

Run ueventd

daemon

Create filesystem nodes, mount

filesystems, and assign

permissions

Parse and execute init.rc

Page 45: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Configuration init.rc File(s) {3}

Configuration files are parsed and executed by /init program

Written in Android Init Language

Contain Action Lists executed when certain triggers are occurred

Set: system variables, parameters, filesystemowners and permissions, etc.

Run: main system daemons

init.rc >600 configuration lines

system/core/rootdir/init.rc

45

Page 46: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Excerpt of init.rc {3}

system/core/rootdir/init.rc

46

Page 47: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Daemon ueventd {4}

Responsible for system and device events

At the beginning replays the kernel ueventhotplug events specified in uevent.rc files

47

Page 48: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Running Processes with Credentials

service media /system/bin/mediaserver

class main

user media

group audio camera inet net_btnet_bt_admin net_bw_acct drmrpc

ioprio rt 4

48

Page 49: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Sockets

49

Page 50: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Processes

50

Page 51: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Security Internals

Linux Kernel Level

Native Userspace Level

Application Framework Level

Application Level

Page 52: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

System Services

Provide core functionality of the Android platform

Implemented mostly in Java, some using native code

Most of them run as separate threads within system_server process

Define the interfaces (e.g, IPowerManager for PowerManagerService) used from other services and applications

52

Page 53: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Inter Process Communication

53

Page 54: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android IPC

Posix System V IPC (semaphores, shared memory and message queues) are not supported by Android’s libcimplementation (Bionic)

Uses Unix domain sockets for some special cases (e.g., communication with Zygote daemon)

Binder Framework

– relies on special /dev/binder driver

– provides the ether for ICC mechanisms (e.g., Intents)

– link-to-death

– sync/async remote method invocation

– provides ability to send file descriptors across processes

– communication between the processes is organized according to synchronous client-server model

54

Page 56: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

System Service Discovery

How a Client can discover a Service?

Each Service is a Binder object, which is assigned with 32-bit value random, unique over the system token

The token acts as a handle for the Service (having this handle it is possible to interact with the Service)

How can a Client discover the value of this token?

56

Page 57: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Binder Context Manager

Special Binder Service with a known in advance token value = 0

Context Manager may be imagined as a name service:

– CM provides a handle to a Service using the name of the Service

– Each Service before being exposed needs to be registered with CM

Binder Context Manager == Service Manager in Android

57

Page 58: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Binder Security

The Binder driver allows only single Context Manager registration

Does not impose any security by itself, but:

– Binder tokens can act as a security access token (e.g., wakelock example)

– Binder driver to each transaction adds UID and PID of the sender process

Receiver may get UID and PID values:

– android.os.Binder.getCallingUid()

– android.os.Binder.getCallingPid()

58

Page 59: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Application Framework Security

Application1 wants vibration functionality

Vibration can drain phone’s battery

– Only approved applications should have this functionality

– How to protect vibrate() method from being called from any app?

59

android.os.Binder.getCallingUid() in set of allowed uids

checkCallingOrSelfPermission(permission)

Page 60: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Permission Check Example

60

The check is performed in system_serverprocess => client process cannot influenceon the check (e.g., through Java reflection)

Page 61: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Permissions

Special labels that guard access to protected functionality

– Built-in permissions (framework)

– Custom permissions (system and user apps)

Permissions are granted upon installation

Permissions are not equal in security sense!

– criticality(install packages) > criticality (send SMS) > > criticality(vibrate)

PackageManagerService (system service) is responsible for managing permissions assigned to different applications and system components

61

Page 62: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Permission Granting

Developer:

During the development

declares in the

AndroidManifest.xml, which

permissions are required for

his application to operate

properly

Example: android.permission.SEND_SMS

Owner of the phone:

During installation is

acquainted with these

required permissions and

decides either to grant these

permissions to the

application or not to grant

and, thus, prohibit the

installation of the application

62

Page 63: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Permission Protection Level

63

• Normal – automatically granted

– access to (sometimes annoying but) harmless features, like changing the wallpaper

• Dangerous– user granted

– access to SMS sending facility, to phone number, contacts, camera, etc.

• Signature (I case)– developer controlled

– used to enable interactions among the developer apps

• Signature (II case)– Device manufacturer controlled

• System|Signature– Google/device manufacturer controlled

Page 64: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Built-in Permissions

64

Page 65: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Code Signing

All Android applications and framework resources need to be signed

There are 4 keys defined in AOSP:

– platform

– shared

– media

– releasekey (testkey)

AndroidManifest.xml with built-in permissions is within framework-res.apk signed with platform key

65

Page 66: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Package Manager Check

66

Page 67: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Kernel Permission Mapping

frameworks/base/data/etc/platform.xml

67

Page 68: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Security Internals

Linux Kernel Level

Native Userspace Level

Application Framework Level

Application Level

Page 69: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Applications

Types:

– System applications

– Third-party applications

Consist of components, which are declared in AndroidManifest.xml

No central start point (no main() method)

Permissions are enforced on the Android Framework level

69

Page 70: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Application Components

70

Broadcast receiver:

• Message box to receive messages from other

components and to react to them

Content provider:

• Data sharing interface

Activity:

• User Interface element

Service:

• Background

processing

Page 71: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Application Interaction

71

Email

Description

writting

Cover

picking

Email

sendingBook list

Personal Library

Service

Content Provider

Service

Content Provider

Gallery

Service

Content Provider

PersonalLibrary.apk Email.apk Gallery.apk

Page 72: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Intents

Intents are messages between components of the system

Three out of four app component are activated using Intents

72

Developer can explicitly specify the receiver of the message (explicit intent) or can ask the system to choose appropriate component for processing specified action (implicit intent)

iOs8 will introduce similar functionality (Extensibility)

Page 73: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Intent Resolution

Explicit Intents

Explicit intents are used for application-internal messages

Required:

Component name

Optional:

Action

Data

Category

Extras

Flags

Implicit Intents

Implicit intents are often used to activate components in other applications

Required:

Component name = blank

Action

Data

Category

Optional

Extras

Flags

73

Page 74: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Android Manifest

74

Describes

contents of the

package:

•Components

•Required permissions

•The classes that

implement each of the

components

•Some other features

of app and

components

(sharedUid,

processes, etc.)

Page 75: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Custom Permissions

75

Page 76: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Application Build Process

76

Device

Compilation

and

Packaging

SigningDevelopercertificate

Android Project

assets

AndroidManifest.xml

resources

source code

Android Package (.apk)

assets

AndroidManifest.xml

uncompiled resources

.dex

files

resources.

arsc

Page 77: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Literature Overview

1. N. Elenkov. “Android Security Internals”. No Starch Press,

expected October 2014

2. K. Yaghmour. “Embedded Android”. O’Reilly Media (2013)

3. J. Drake et al. “Android Hacker's Handbook”. Wiley (2014)

4. J. Levi. “Android Internals: A Confectioner's Cookbook”.

expected August 2014, http://newandroidbook.com/

5. Y. Zhauniarovich. “Android Security (and Not) Internals”. Web

(2014), http://zhauniarovich.com/files/asani/asani.pdf

6. E. Fernandes. “Instant Android Systems Development How-

to”. Packt Publishing Ltd (2013)

77

Page 78: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

General Bits and Pieces

Android Architecture

Android Security Internals

Security Problems and Solutions

Page 79: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

What the most critical security

problems do you see in Android?

79

Page 80: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Critical Problems: My View

Permission system

– Overprivileged applications

– Users do not understand permissions

– “All-or-nothing approach” with permission granting

Private information collection

Malware

– Repackaging

– Application vetting

80

Page 81: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Permission System

Private Information

Android Malware

Our Solutions

Page 82: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Overprivileged Applications

Is the principle of least privilege respected? Not always.

– Applications reimplement the functionality already available (Facebookwill open links in its internal browser)

– Developers request permissions not required for the app operation

A. Felt et al “Android Permissions Demystified” at CCS’2011

– Stowaway is a tool to check which permissions the actually app requires

– From 940 analyzed apps 32.7% are overprivileged

Most common unnecessary permissions are:

– ACCESS_NETWORK_STATE 16%

– READ_PHONE_STATE 13%

– ACCESS_WIFI_STATE 8%

– WRITE_EXTERNAL_STORAGE 7%

A more recent mapping of permissions to API in the paper “PScout: Analyzing the Android Permission Specification” by Kathy Au et al.

82

Page 83: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Stowaway Example

83

Page 84: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Do Users Understand Permissions?

WAKE_LOCK

USE_CREDENTIALS

MANAGE_ACCOUNTS

AUTHENTICATE_ACCOUNTS

WRITE_SETTINGS

com.android.vending.BILLING

84

Page 85: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Do Users Understand Permissions?

A. Felt et al “Android permissions: User attention, comprehension and behavior” in SOUPS-2012

– Surveyed 300 Android users and interviewed 25 of them

– Key findings:

• 17% of participants paid attention to permissions during installation

• 42% of interviewed participants were unaware of existence of permissions

• Very low rate of permission comprehension: only 3% were able to correctly answer to the questions on permission understanding

85

Page 86: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Solutions

Reconsider “all or nothing” approach

– Add “prompt” permissions

– Provide users with better permission explanation

Provide a possibility to disable permissions at runtime and depending on context

– CRePE*

– CyanogenMod

86

* M. Conti et al. “CRePE: A System for Enforcing Fine-Grained Context-Related

Policies on Android”. In IEEE TIFS, 2012

Page 87: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Permission System

Private Information

Android Malware

Our Solutions

Page 88: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Example: Private Information

IMEI (International Mobile Station Equipment Identity) – is a unique number to identify a phone

In Android to get it use: TelephonyManager.getDeviceId()

Requires permission: android.permission.READ_PHONE_STATE

88

Page 89: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Motivation

Sensitive user information may be gathered by:

Advertising frameworks and other libraries embedded into apps

Third-party app developers– Brightest Flashlight app (50+ million installations, traced

user location in almost real-time)

– 20 out of 30 popular apps potentially misuse private users’ information*

Adversaries**– using repackaging of popular apps

– developing apps that conceal their malicious behavior

89

* W. Enck et al. “TaintDroid: An Information-Flow Tracking System for Realtime

Privacy Monitoring on Smartphones”. In Proc. Of OSDI‟10

** Y. Zhou, X. Jiang. “Dissecting Android malware: Characterization and Evolution”.

In Proc. of S&P ‟12

Page 90: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TaintDroid

W. Enck et al 'TaintDroid: an information flow tracking system for realtime privacy monitoring on smartphones', in OSDI-2010

– TaintDroid is a system for dynamic taint tracking in Android.

– When tainted data is sent over the network, TaintDroid logs this fact

Studied 30 popular apps, some of them indeed misuse sensitive data

– 2 apps send SIM card ID

– 15 apps send location data to ad servers

– None of the apps tells this in the EULA

90

Page 91: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Solutions

Fake information

– MockDroid*

– App Ops (Android 4.3, 4.4, removed in 4.4.2)

Provide a possibility to separate personal and work data; filter our private information

– MOSES**

Trusted Application Stores

– TruStore***

91

* A. Beresford et al. “MockDroid: Trading Privacy for Application Functionality on

Smartphones”. In Proc. of Hotmobile’11, 2011

** Y. Zhauniarovich et al. “MOSES: Supporting and Enforcing Security Profiles on

Smartphones”. In IEEE TDSC, 2014

*** Y. Zhauniarovich et al. “DEMO: Enabling Trusted Stores for Android”. In Proc. of

CCS‟13, 2013.

Page 92: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Permission System

Private Information

Android Malware

Our Solutions

Page 93: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Malware Analysis

Y. Zhou, X. Jiang “Dissecting Android Malware: Characterization and Evolution” in IEEE S&P-2012

– Analyzed 1260 malware samples categorized in 49 families

Malware was analyzed by:

– Installation type

– Activation method

– Type of payload

– Use of permissions

93

Page 94: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Installation Types

Repackaging – piggyback malicious payloads into popular applications

Update attack – malware includes an update component that will fetch or download the malicious payloads at runtime

Drive-by download – malware tries to force users to download “interesting” or “feature-rich” apps.

Others – spyware, fake apps, trojans, apps with root exploit

94

Page 95: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Android Malware

Repackaging

Dynamic Update Attack

Page 96: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Repackaging

96

Android Package (.apk)

assets

AndroidManifest.xml

uncompiled resources

.dex

files

resources.

arsc

Developersignature

Signing

Developer

certificate (same)

Adversary

certificate(different)

Rebranding(good)

Plagiarizing(bad)

Device

Page 97: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Repackaging

App repackaging is very easy on Android:

– Fetch an app Disassemble Change Assemble Sign with own certificate Publish

The code of the application can be easily changed

– smali/backsmali, AndroGuard, dex2jar, etc.

Plagiarizing is used to:

– steal advertising revenues (14% of ad revenues)*

– collect user database (10% of user base)*

– malware distribution (86% of Android malware samples use this distribution channel)**

97

* C.Gibler et al. “Adrob: examining the landscape and impact of Android application

plagiarism”. In Proc. of MobiSys ‟13

** Y. Zhou, X. Jiang. “Dissecting Android malware: Characterization and Evolution”.

In Proc. of S&P ‟12

Page 98: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Solutions

Repackaging:

– Search and delete repackaged applications

• FSquaDRA by Y. Zhauniarovich (DBSec 2014)

– Resource-based comparison

• DNADroid by J. Crussell et al. (ESORICS 2012)

– PDG subgraph isomorphism

• Juxtapp by S. Hanna et al. (DIMVA 2012)

– k-grams of opcodes hashing feature vector Jaccard distance

• AndroGuard

– Similarity score based on NCD = extract opcode sequences for methods compress compare methods based on NCD

– One central store with plagiarism detection service

98

Page 99: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Android Malware

Repackaging

Dynamic Update Attack

Page 100: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Dalvik VM

Dynamic Updates

100

Android Package (.apk)

assets

AndroidManifest.xml

uncompiled resources

.dex

files

resources.

arsc

DexFile.loadDex

Method.invokecode files

(jar, dex,…)

1. Dynamic Class Loading (DCL)

2. Reflection

Page 101: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Motivation

In Android, code loaded dynamically has the same privileges as original

Static analyzers cannot fully inspect an app in the presence of dynamic code features (AndroGuard, Stowaway, PScout etc.)

Heavily used by malware to conceal malicious behavior

Dynamic code update features are used:– In legitimate applications

• Google Play: 19% - DCL, 88% - reflection

• Third-party markets: 6% - DCL, 74% - reflection

– In malicious applications

• Malware dataset: 20% - DCL, 81% - reflection

101

Page 102: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Solutions

White-listing of the code loaded dynamically

– Time lag

– Huge whitelists

– Requires analysis of the loaded code

Application vetting

102

* S. Poeplau et al. “Execute This! Analyzing Unsafe and Malicious Dynamic Code

Loading in Android Applications”. In Proc. of NDSS’14, 2014

Page 103: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Application Vetting

Application vetting is the process of performing background check of apps before proposing them to end-users

Application vetting can be used to:

– ensure only approved apps are loaded on employee’s device (in the enterprise context)

– find repackaged applications

– reveal malicious applications

103

Page 104: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Google Bouncer since Feb. 2012

An app submitted to Google Play is run in a simulated environment

– Checking for known malware behavior patterns

It is a static environment

– J. Oberheide and C. Miller in June 2012 present the data of the simulated environment which can be used by malware to detect when they are scanned

• Same Gmail account, same contact list, same pictures on the phone, same processor emulator, same IP block

• They got this data by obtaining a remote access to their app which was being analyzed by the Bouncer

It is vulnerable to dynamic JavaScript code updates

– In July 2012 N. Percoco and S. Schulte uploaded an SMS app which also harvested user information and was capable of launching a DDoS attack

– It was not detected by the Bouncer, because the malicious code was uploaded after the app was verified

• Developers can remotely add new features to apps already accepted on Google Play and modify how the file looks, all without going through the approval or update process again.

8/27/2014

Page 105: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Permission System

Private Information

Android Malware

Our Solutions

Page 106: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Our Solutions

MOSES

FSquaDRA

TruStore

Page 107: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES: Motivation

Same device multiple virtual environment (e.g., in BYOD scenarios)

Demand to increase the control over the capabilities of third-party apps, e.g., prohibit access to location

Lack for context-based enforcement of security policies on Android

Absence of remote control over virtual environments by the owners

107

Page 108: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES: State Of the Art

Secure containers

– e.g., Aurasium by R.Xu et al. (USENIX Security ’12)

– usually, 2 virtual environment (private and work)

– app rewriting usage

Mobile paravirtualization

– e.g., L4Android by M.Lange et al. (ACM SPSM ’11)

– predefined number of operation modes

– battery-consuming solutions

Linux containers

– e.g., Cells by J.Andrus et al. (ACM SOSP ’11)

– switching requires user interaction

– virtual environments are hard-coded

108

Page 109: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES: Problem

Issue: How to provide several virtual environments

on the same device

– users are not willing to carry several devices

that separate data and apps belonging to different usage contexts

– app developers should not rewrite their apps according to new rules

managed by different owners

– e.g., working environment is controlled by company administrators

avoiding energy demanding (para)virualizationsolutions?

– smartphones require long working time without recharging

109

Page 110: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES: Idea

IDEA: Provide a possibility to create virtual

environments (or Security Profiles (SP))

through policy-based framework so that

applications in one SP cannot access the

data of the same app in another SP. Ensure

the control over Security Profiles to the

owners. Equip SPs with an ability to enforce

fine-grained policies.

110

Page 111: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES: Architecture

111

Page 112: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES Configuration:

Security Profile Creation

112

create_profile “private” in_mode “permissive” with_priority “50”;

allow_apps “*”;

add_sr “browser_deny_receive_from_google” on_position “10”; activate_in_context “home”;

Page 113: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES Configuration:

Context Definition

113

create_context “home”;condition [(latitude=“55”) AND (longitude=“11”) AND (radius=“1000m”)];

Page 114: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES Configuration:

Special Rule Creation

114

create_sr “browser_deny_receive_from_google”;

action “deny”;

package “com.google.android.browser”;

operation “receive internet data”;

target “google*”;perform [];

Page 115: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

MOSES: Contributions

First policy-based solution for virtual environments on Android

Manual and context-based Security Profiles activation

Security Profiles and Contexts are not predefined, users can configure them dynamically

Possibility to confine applications using fine-grained security policies

Compatible with existing applications

115

Y. Zhauniarovich, G. Russello, M. Conti, B. Crispo, E. Fernandes.

“MOSES: Supporting and Enforcing Security Profiles on Smartphones”.

In IEEE TDSC, to appear in 2014.

G. Russello, M. Conti, B. Crispo, E. Fernandes , Y. Zhauniarovich.

“Demonstrating the Effectiveness of MOSES for Separation of Execution

Modes”. In Proc. of CCS‟12, 2012.

Page 116: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Our Solutions

MOSES

FSquaDRA

TruStore

Page 117: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Motivation

App repackaging is very easy on Android:– Fetch an app Disassemble Change Assemble

Sign with own certificate Publish

The code of the application can be easily changed– smali/backsmali, AndroGuard, dex2jar, apktool, etc.

Plagiarizing is used to:– steal advertising revenues (14% of ad revenues)*

– collect user database (10% of user base)*

– malware distribution (86% of Android malware samples use this distribution channel)**

117

* C.Gibler et al. “Adrob: examining the landscape and impact of Android application

plagiarism”. In Proc. of MobiSys ‟13

** Y. Zhou, X. Jiang. “Dissecting Android malware: Characterization and Evolution”.

In Proc. of S&P ‟12

Page 118: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Problem Statement

Issue: How to detect repackaged Android applications

fast

– 1.1+ million apps on Google Play *

– 190+ third-party markets **

– quadratic complexity

in effective way?

– need for a similarity metric to what extent one app is similar to another

118

* N. Viennot et al. “A Measurement Study of Google Play”. In Proc. of SIGMETRICS „14

** T. Vidas, N. Christin. “Sweetening Android Lemon Markets: Measuring and

Combating Malware in Application Marketplaces”. In Proc. of CODASPY „13

Page 119: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

FSquaDRA: Idea

Repackaged apps want to maintain the “look and feel” of the originals

– Opera Mini fake: 230 of 234 files are the same

IDEA: compare apps based on the included resource files (same files same apps)

119

Page 120: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

FSquaDRA: Approach

Compute hashes of all files inside two apps

Calculate Jaccard index for the extracted hashes:

120

Compare the obtained value with a threshold

PROBLEM: How to compute hashes efficiently?

Hi – set of hashes of files in apk i

Page 121: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Speeding Up Hash Calculations

As a part of application signing process SHA1 digest of each file inside apk is calculated

121

Page 122: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

FSquaDRA: Evaluation

Dataset:

– 55779 apk samples

– from 8 markets including Google Play

Pairwise comparison of all apps in the dataset

Objectives:

– plagiarizing rates for apps signed with different certificate

– rebranding rates for apps signed with the same certificate

Evaluate Efficiency and Effectiveness

122

Page 123: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Evaluation: Pairwise Comparison

123

Page 124: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Evaluation: Efficiency

FSquaDRA is implemented as a single-threaded Java program

– not really optimized

We ran experiments on a commodity laptop (2.9 GHz Intel Core i7, 8GB RAM)

– 15,10 hours to load hashes into memory

– 64,41 hours to compute similarity score for all app pairs

On average 6700 app pairs per second

124

Page 125: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Evaluation: Effectiveness

Metrics:

– False Positives? For apps FSquaDRA considers repackaged, are they actually repackaged?

– False Negatives? For apps FSquaDRA considers different, are they really not repackaged?

Approaches:

– analyze FSquaDRA on a dataset of repackaged apps

– compare FSquaDRA metrics with the state-of-the-art tools

Problems:

– no public dataset with repackaged apps

– only one public tool: AndroGuard

125

Page 126: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Effectiveness: Evaluation Setup

AndroGuard – open-source tool by A. Desnos:– computes code-based similarity metric

– slow (65 sec to compare an app pair on average)

– does not produce symmetric values

We use average score of (A,B) and (B,A) as the similarity score for AndroGuard (ags)

For each selected bin: – randomly picked 100 app pairs with different

certificates and 100 app pairs with the same certificate;

– calculated their AndroGuard similarity score (ags)

– compared with FSquaDRA similarity score (fss)

126

Page 127: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Effectiveness: Plagiarizing Results

(different certificates, fss>0)

127

Correlation: 0.7919

Difference (fss-ags):

-mean: -0.0412

-st. dev.: 0.1862

-median: -0.0480

Red: line of best fit

Blue: LOWESS

(locally weighted

scatterplotsmoothing line)

Page 128: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Effectiveness: Rebranding Results

(same certificates, fss>0)

128

Correlation: 0.5807

Difference (fss-ags):

-mean: -0.2761

-st. dev.: 0.2704

-median: -0.2518

Red: line of best fit

Blue: LOWESS

(locally weighted

scatterplotsmoothing line)

Page 129: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

FSquaDRA: Features

The first solution detecting repackaged apps based on resource files

Our resource-based similarity score is highly correlated with the code-based similarity score of AndroGuard (0.79 for plagiarizing, 0.58 for rebranding)

Faster than any known competitor

– DNADroid by J. Crussell et al. (ESORICS 2012) - 0.012 app pair/sec

• PDG subgraph isomorphism

• Hadoop MapReduce framework with a server and 3 desktops

– Juxtapp by S. Hanna et al. (DIMVA 2012) - 49.4 app pair/sec

• k-grams of opcodes hashing feature vector Jaccard distance

• Intel Xeon CPU (8 cores) , 8GB of RAM

– Our approach - 6700 app pair/sec

Open-source *

129* https://github.com/zyrikby/FSquaDRA

Page 130: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

Security Problems and Solutions

Our Solutions

MOSES

FSquaDRA

TruStore

Page 131: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore: Motivation

No possibility to prohibit the installation of uncertified applications in BYOD scenarios

Large number of third-party markets (Google Play, Yandex.Store, F-Droid, etc.)

Users trust more to the markets that perform application vetting

131

Page 132: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore: Problem

Issue: How to support an attestation service on the Android platform maintaining

the openness of the ecosystem,

– all markets should have the same possibility to distribute their apps

– a user decides to which markets she trusts more

backward compatibility with already developed apps?

– app developers should not rewrite their apps according to new rules

132

Page 133: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore: Idea

133

Apple centralized architecture

IDEA: If an application has passed the

vetting process of a market, sign it with the

market certificate. Ensure on the client-side

that only applications signed with the

approved certificates can be installed on the

device.

PROBLEM: Android has open ecosystem

Page 134: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore: Approach

134

Page 135: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore Client: Architecture

135

Page 136: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore Client: Configuration

136

Page 137: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore: Operation

137

Page 138: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

TruStore: Contributions

We proposed an approach to support attestation services for the Android platform:

– supports the open nature of the Android ecosystem

– does not change current development, signing and publishing workflow

– can be applied to already developed applications

– allows to prohibit installation of uncertified apps in BYOD scenarios

138

Y. Zhauniarovich, O. Gadyatskaya, B. Crispo. “DEMO: Enabling Trusted

Stores for Android”. In Proc. of CCS‟13, 2013.

Page 140: Security of the Android Operating System -  · PDF fileSecurity of the Android Operating System Yury Zhauniarovich yury.zhauniarovich@unitn.it   ... Android Security Internals

(Some) References

1. Y. Zhauniarovich. “Android Security (and Not) Internals”. Web (2014),

http://zhauniarovich.com/files/asani/asani.pdf

2. E. Fernandes. “Instant Android Systems Development How-to”. Packt Publishing Ltd

(2013)

3. G. Russello, B. Crispo, E. Fernandes and Y. Zhauniarovich. “YAASE: Yet another

Android security extension”. In Proc. PASSAT/SocialCom, 2011.

4. M. Conti, B. Crispo, E. Fernandes, Y. Zhauniarovich. “CRePE: A System for Enforcing

Fine-Grained Context-Related Policies on Android”. In IEEE TIFS, 2012.

5. Y. Zhauniarovich, G. Russello, M. Conti, B. Crispo, E. Fernandes. “MOSES:

Supporting and Enforcing Security Profiles on Smartphones”. In IEEE TDSC, 2014.

6. http://www.idc.com/prodserv/smartphone-os-market-share.jsp

7. Y. Zhauniarovich, O. Gadyatskaya, B. Crispo, F. La Spina, E. Moser. “FSquaDRA:

Fast Detection of Repackaged Applications”. In Proc. of DBSec’14, 2014.

140