Privacy Implications of Android Applications in the Presence of Third-Party Libraries
Total Page:16
File Type:pdf, Size:1020Kb
Privacy Implications of Android Applications in the Presence of Third-Party Libraries Roger Bernat Ribas Manero Thesis submitted for the degree of Master of Science in Electrical Engineering, option Electronics and Integrated Circuits Thesis supervisor: Prof.dr.ir. Bart Preneel Prof.dr.ir. Marian Verhelst Assessor: Prof.dr.ir. Claudia Diaz Mentor: Michael Herrmann Academic year 2013 – 2014 c Copyright KU Leuven Without written permission of the thesis supervisor and the author it is forbidden to reproduce or adapt in any form or by any means any part of this publication. Requests for obtaining the right to reproduce or utilize parts of this publication should be addressed to Departement Elektrotechniek, Kasteelpark Arenberg 10 postbus 2440, B-3001 Heverlee, +32-16-321130 or by email [email protected]. A written permission of the thesis supervisor is also required to use the methods, products, schematics and programs described in this work for industrial or commercial use, and for submitting this publication in scientific contests. Preface "Hoy es siempre todavía" - Antonio Machado "Fent i desfent, aprèn l’aprenent." - Ferran Boixadós Escalé After an academic year of hard work, my master thesis is finally finished. With it, I conclude my Master Degree and, therefore, a stage of my live. This time has been an amazing trip of auto-discovery. There were moments were I had to face several difficulties that completely overtook me but I always came up with a solution. I will always remember that sweet moment in which your written code works as expected. I would like to thank the KU Leuven for offering me the opportunity of doing my Master Thesis with them. Specially, I would like to thank Prof. Claudia Diaz who accepted my application from the very beginning. Also, my advisor Michael Hermann from whom I have learned a lot and without whom I could never have reached this point. Furhter, my advisor in Spain Prof. Jordi Forné for helping and guiding me from the distance. I would like to thank my colleges from the COSIC department Marc Juárez and Günes Acar for their help and interest. Furthermore, I would like to thank all the people from the COSIC. I would like to thank my family and my girlfriend Veronica for all their support during this year, backing me up every time I could not find a way to continue. Finally, I would like to thank all the incredible people I have met during this year. Specially, my room-mates Xavi Garcia, Laura Forriol and Josu Saetero and my good friend Esra Tiger. Thank you all! Moltes gràcies a tots! Dank u allen! Roger Bernat Ribas Manero i Contents Preface i Abstract iv List of Figures and Tables v List of Abbreviations and Symbols viii 1 Introduction 1 1.1 Motivation ................................ 1 1.2 Objectives, Scope and Main Conclusions ................ 3 2 Related Work 5 2.1 Privacy Implications of Android Applications ............. 5 2.2 Location Privacy ............................. 6 3 Background 9 3.1 Internals of the Android Operating System .............. 9 3.2 Android Mobile Applications Fundamentals .............. 11 4 3Ov: Identifying Over-privileges in Android Applications 17 4.1 The Google Play Market ......................... 17 4.2 Crawling the Google Play Market .................... 19 4.3 Downloading the Applications ...................... 20 4.4 Parsing the AOSP’s Permissions .................... 21 4.5 Reverse-engineering the Applications .................. 22 4.6 Parsing and Analyzing the Applications ................ 23 4.7 Generating Android Manifest Type Files ................ 28 4.8 Limitations of 3Ov ............................ 29 4.9ProofofWork............................... 30 4.10 Discussion ................................. 37 5 LPDroid: Application Transparent Protection of Location Data 39 5.1 Protecting Users’ Location at the User Level ............. 39 5.2 Protecting Users’ Location at the Framework Level .......... 46 5.3LowerLevelsoftheAOSP........................ 56 6 Future Work 57 6.1Improving3Ov.............................. 57 6.2 Improving LPDroid ............................ 58 ii Contents 7 Conclusion 59 A Source Code of 3Ov 63 A.1 Crawling the applications ........................ 63 A.2 Downloading the applications ...................... 67 A.3 Parsing AOSP’s permissions ....................... 69 A.4 Reverse-engineering the applications .................. 71 A.5 Find third-party libraries ........................ 72 A.6 Parsing and analyzing the applications ................. 76 A.7 Generating the Android Manifest files ................. 80 A.8 Discussion ................................. 83 B Source Code of LPDroid 99 B.1Userlevelsourcecode.......................... 99 B.2 Framework level source code ....................... 104 Bibliography 111 iii Abstract Mobile devices, such as smart phones and tablet computer, become increasingly popular. One reason that makes these devices so popular, is the availability of mobile applications that allow to add a wide range of functionality to the operating system of a mobile device. Recently, concerns have been raised with respect to the private information that these mobile applications are able to access. Usually, privileges can be granted to a mobile application in order to limit the data they have access to. However, since mobile applications generally do not run if not all privileges are granted, users tend to grant all necessary privileges. From a privacy perspective, this is particularly an issue, because a mobile application usually consists of several parts: One part written by its developers and several external libraries written by third parties. In this work, we present 3Ov, a tool that analyses the source code of mobile applications in order to identify the privileges necessary for the mobile application itself and the privileges that are necessary for the third party libraries. The ultimate goal of 3Ov is to find permissions that needs to be granted to a mobile application solely because the third party library requires it. We provide the evaluation of 89 applications of a proof of concept. Our results show that external libraries increase the privileges that need to be granted to the application. Since this means that users allow potentially many parties to access their private data, we discuss protecting possibilities on the example of location data. We propose LPDroid, a tool that enables to embed location privacy protecting mechanisms in the operating system itself. In particular, LPDroid allows the user to choose the level of protection and the operating system obfuscates the user’s location data automatically to all mobile applications accessing location data. iv List of Figures and Tables List of Figures 3.1 Complete Android Software Stack diagram as proposed by Yaghmour Karim. ..................................... 10 3.2 Activity’s life-cycle from Android developers website. ........... 13 3.3 Permission section of the Android Manifest file from an application that requires access to the Internet. ....................... 15 3.4 Building process of an Android application as shown in the Android developerswebsite............................... 16 4.1 Flow chart of 3Ov. .............................. 18 4.2 This function automatically initiates the download process. ....... 21 4.3 Once the application’s website is loaded, we call the autoDownloadApk() function. .................................... 21 4.4 General structure of a smali file. ...................... 24 4.5 Most popular third-party libraries found in the 1126 analyzed applications. Graph (a) shows the most popular Advertising, graph (b) the most popular Development tools libraries and graph (c) the most popular Social SDKs. ............................ 27 4.6 Presence rate of Development tools (a) and Advertising libraries (b). 28 4.7 Graph (a) shows the permissions required to use the top five Development tools libraries. Graph (b) shows the permissions required to use the top five Advertising libraries. ............... 32 4.8 Over-privileges found according to the first four heuristics. Graph (a) considers the lower bound while graph (b) the upper. ........... 34 4.9 Over-privileges found according to the fifth heuristic. ........... 35 4.10 Most popular over-privileges due to the usage of the different categories of third party libraries. Graph (a) shows the most popular over-privileges due to Development libraries. Graph (b) shows the most popular over-privileges due to Advertising libraries. ............ 35 4.11 Over-privileges found according to the fourth heuristic. ......... 36 4.12 Image (a) shows the number of applications that have declared one or more unnecessary permissions. Image (b) shows which are the most popular permissions unnecessarily granted to the applications. ..... 37 v List of Figures and Tables 5.1 Show MyLocation application running in a real device. Image (a) shows the information about the providers while image (b) shows the information embedded with the received coordinates. ........... 43 5.2 Listpermissions application running in a real device. ........ 44 5.3 Image (a) shows how the Action bar of the emulator notifies a message from TaintDroid. Image (b) shows the information of the message. 49 5.4 Image (a) shows the procedure followed every time new location coordinates are received. Image (b) shows how AppFence interrupts the work flow by calling the fakeLocation() method. ............. 50 5.5 Image (a) shows how the telnet session is established and how the (25.00, 25.00) coordinates are established with