Going Native: Using a Large-Scale Analysis of Android Apps to Create - - PowerPoint PPT Presentation

going native using a large scale analysis of android apps
SMART_READER_LITE
LIVE PREVIEW

Going Native: Using a Large-Scale Analysis of Android Apps to Create - - PowerPoint PPT Presentation

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations Going Native: Using a Large-Scale Analysis of Android Apps to Create a Practical Native-Code Sandboxing Policy Vitor Monte Afonso 1 , Antonio Bianchi 2


slide-1
SLIDE 1

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Going Native: Using a Large-Scale Analysis

  • f Android Apps to Create a Practical

Native-Code Sandboxing Policy

Vitor Monte Afonso 1, Antonio Bianchi 2, Yanick Fratantonio 2, Adam Doup´ e 3, Mario Polino 4, Paulo L´ ıcio de Geus 1, Christopher Kruegel 2, and Giovanni Vigna 2

1 University of Campinas 2 UC Santa Barbara 3 Arizona State University 4 Politecnico di Milano

NDSS 2016

1/32

slide-2
SLIDE 2

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

2/32

slide-3
SLIDE 3

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

3/32

slide-4
SLIDE 4

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

4/32

slide-5
SLIDE 5

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

5/32

slide-6
SLIDE 6

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

6/32

slide-7
SLIDE 7

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

Most analysis tools miss these attacks

7/32

slide-8
SLIDE 8

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction - Sandboxing

8/32

slide-9
SLIDE 9

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

Motivation

Lack of data regarding native code usage No research on how to generate a general, practical and useful policy to enforce

9/32

slide-10
SLIDE 10

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Introduction

Motivation

Lack of data regarding native code usage No research on how to generate a general, practical and useful policy to enforce

Large-scale analysis

How many apps actually use native code? What is the behavior of native code? What permissions do native code use? How does native code interact with the app and the framework? Which shared libraries are used in native code?

9/32

slide-11
SLIDE 11

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Background

Native code

Executable file

Exec methods (Runtime.exec or ProcessBuilder.start)

Shared library (.so)

Load methods (e.g., System.loadLibrary) Native methods Native activity

10/32

slide-12
SLIDE 12

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Applications Used

Dataset

1,208,476 distinct free apps Crawled from Google Play - May 2012 and August 2014

Static prefiltering

Filtered apps that have the potential to use native code

Native method: Java method with “native” modifier Native activity: declared in manifest or class that extends NativeActivity Call to Exec or Load methods ELF file inside APK

37.0% (446,562) have the potential to use native code

11/32

slide-13
SLIDE 13

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Dynamic Analysis

Information to track

System calls of native code Interactions of native code with other components

12/32

slide-14
SLIDE 14

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Dynamic Analysis

Our system

App’s system calls traced with strace Instrumented libraries

Flag third-party libraries (based on file path) Record all transitions between Java and app’s native code

Post-processing - separate behavior of app’s native code

13/32

slide-15
SLIDE 15

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Research Question

How many apps actually use native code?

14/32

slide-16
SLIDE 16

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Dynamic Analysis

33.6% (149,949) of dynamically analyzed apps executed native code 12.4% of all apps in our dataset - other work identified around 5% It’s only a lower bound: it could be more Apps Type 72,768 Native method 19,164 Native activity 132,843 Load library 27,701 Call executable file (27,599 standard, 148 custom and 46 both) 149,949 At least one of the above

15/32

slide-17
SLIDE 17

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Native Code Not Reached

Small experiment

Manual analysis 20 random apps Static analysis

40% (8) deadcode - native code unreachable from Java code

Other apps were very complex

Dynamically analyzed those and interacted manually Still did not reach native code

Why deadcode

Third-party libraries - include a lot of code but only part of it is used

16/32

slide-18
SLIDE 18

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Research Question

What is the behavior of native code?

17/32

slide-19
SLIDE 19

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Native Code Behavior - Overview

Common actions in shared libraries

94.2% (125,192) of apps that used custom shared libs only performed subset of common actions Such as memory management system calls, calling JNI functions, writing log messages and creating directories

Other actions in shared libs and custom executable files

Most common are: ioctl calls, writing file in app’s directory, operations on sockets

Standard executable files

Most common are: read system information, write file in app’s dir or sdcard, read logcat

18/32

slide-20
SLIDE 20

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Research Question

What permissions do native code use?

19/32

slide-21
SLIDE 21

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Top 5 Permissions Used in Native Code

Apps Permission Description 1,818 INTERNET Open network socket or call method java.net.URL.openConnection 1,211 WRITE EXTERNAL STORAGE Write files to the sdcard 1,211 READ EXTERNAL STORAGE Read files from the sdcard 132 READ PHONE STATE Call methods getSubscriberId, getDeviceSoftwareVersion, getSimSerialNumber or getDeviceId from class android.telephony.TelephonyManager

  • r Binder transaction to call

com.android.internal.telephony .IPhoneSubInfo.getDeviceId 79 ACCESS NETWORK STATE Call method android.net. ConnectivityManager.getNetworkInfo

20/32

slide-22
SLIDE 22

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Research Question

How does native code interact with the app and the framework?

21/32

slide-23
SLIDE 23

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

JNI Calls

How native code interact with the app and the framework

Most common groups of JNI calls used

Apps Description 94,543 Get class or method identifier and class reference 71,470 Get or destroy JavaVM, and Get JNIEnv 53,219 Manipulation of String objects ... ... 35,231 Call Java method (in app or framework)

Most common groups of methods from the Android framework called

Apps Description 7,423 Get path to the Android package associated with the context of the caller 6,896 Get class name 5,499 Manipulate data structures 4,082 Methods related to cryptography

22/32

slide-24
SLIDE 24

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Research Question

Which shared libraries are used in native code?

23/32

slide-25
SLIDE 25

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Most Used Shared Libraries

Most used standard libraries

Apps Name Description 24,942 libjnigraphics.so Manipulate Java bitmap objects 2,646 libOpenSLES.so Audio input and output 2,645 libwilhelm.so Multimedia output and audio input 349 libpixelflinger.so Graphics rendering 347 libGLES android.so Graphics rendering

Most used custom libraries

Apps Name Description 19,158 libopenal.so Rendering audio 17,343 libCore.so Used by Adobe AIR 16,450 libmain.so Common name 13,556 libstlport shared.so C++ standard libraries 11,486 libcorona.so Part of the Corona SDK, a development platform for mobile apps

24/32

slide-26
SLIDE 26

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Sandboxing

Now we can create the rules

25/32

slide-27
SLIDE 27

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Security Policy

Goal

Reduce attack surface available for native code Generate security policy from data obtained

Trade-off

Why not allowing everything? Overlap between benign and malicious behavior Tunable threshold: we selected 99%

26/32

slide-28
SLIDE 28

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Security Policy

Modes of operation

Reporting or enforcing Not implemented

Process - system call policy

Normalize arguments of system calls (e.g., file paths are replaced by “USER-PATH” or “SYS-PATH”) Iterate over syscalls Select the one used by most apps Repeat until allow certain percentage of apps to run

27/32

slide-29
SLIDE 29

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Root Exploits

Effects of policy with 99% threshold on root exploits

Name / CVE Description Blocked Exploid (CVE-2009-1185) Needs a NETLINK socket with NETLINK KOBJECT UEVENT protocol Yes GingerBreak (CVE-2011-1823) Needs a NETLINK socket with NETLINK KOBJECT UEVENT protocol Yes CVE-2013-2094 Uses perf event open system call Yes Vold/ASEC Creates symbolic link to a system directory Yes CVE-2013-6124 Creates symbolic links to system files Yes CVE-2011-1350 ioctl call used violates our rules Yes CVE-2011-1352 ioctl call used violates our rules Yes CVE-2012-4220 ioctl call used violates our rules Yes CVE-2012-4221 ioctl call used violates our rules Yes CVE-2012-4222 ioctl call used violates our rules Yes RATC (CVE-2010-EASY) Relies on invoking many times the fork syscall No Zimperlinch Relies on invoking many times the fork syscall No CVE-2011-1149 It relies on the mprotect syscall No

28/32

slide-30
SLIDE 30

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Root Exploits

Effects of policy with 99% threshold on root exploits

Name / CVE Description Blocked Exploid (CVE-2009-1185) Needs a NETLINK socket with NETLINK KOBJECT UEVENT protocol Yes GingerBreak (CVE-2011-1823) Needs a NETLINK socket with NETLINK KOBJECT UEVENT protocol Yes CVE-2013-2094 Uses perf event open system call Yes Vold/ASEC Creates symbolic link to a system directory Yes CVE-2013-6124 Creates symbolic links to system files Yes CVE-2011-1350 ioctl call used violates our rules Yes CVE-2011-1352 ioctl call used violates our rules Yes CVE-2012-4220 ioctl call used violates our rules Yes CVE-2012-4221 ioctl call used violates our rules Yes CVE-2012-4222 ioctl call used violates our rules Yes RATC (CVE-2010-EASY) Relies on invoking many times the fork syscall No Zimperlinch Relies on invoking many times the fork syscall No CVE-2011-1149 It relies on the mprotect syscall No

Collateral damage: 1,483 apps would be blocked

28/32

slide-31
SLIDE 31

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Java Method Security Policy

Java methods policy

Performed same process to generate policy 99% threshold: 1,414 apps would be blocked Example of dangerous method that would be blocked if called from native code: android.telephony.SmsManager.sendTextMessage

29/32

slide-32
SLIDE 32

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Limitations

Dynamic analysis limitations

Not all native code is executed In the real world apps might execute more than we

  • bserved in our experiments

If our policy is adopted, it might block more apps

Possible improvements

Use a more sophisticated tool to interact with the apps Track behavior in real devices

30/32

slide-33
SLIDE 33

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

Summary

Advantage of large-scale experiments

Since we analyzed a great amount of apps, we believe we

  • bserved most relevant behaviors

Security policies

Based on behavior of many apps - first step to create usable policies

31/32

slide-34
SLIDE 34

Introduction Background Analysis infrastructure Evaluation Policy generation Limitations

End

Questions ?

Vitor Monte Afonso - vitor@lasca.ic.unicamp.br

32/32