Dynamic Detection of Inter-Application Communication Vulnerabilities in Android
Total Page:16
File Type:pdf, Size:1020Kb
Dynamic Detection of Inter-application Communication Vulnerabilities in Android Roee Hay Omer Tripp Marco Pistoia IBM Security, Israel IBM T. J. Watson Research Center, USA [email protected] fotripp,[email protected] ABSTRACT Keywords A main aspect of the Android platform is Inter-Application inter-application communication, Android, security, mobile Communication (IAC), which enables reuse of functional- ity across apps and app components via message passing. 1. INTRODUCTION While a powerful feature, IAC also constitutes a serious at- Android is the most popular mobile operating system, tack surface. A malicious app can embed a payload into with 78% of the worldwide smartphone sales to end users an IAC message, thereby driving the recipient app into a in Q1 2015 [6]. A key aspect of the Android architecture potentially vulnerable behavior if the message is processed is IAC, aka Inter-Process Communication (IPC), which en- without its fields first being sanitized or validated. ables modular design and reuse of functionality across apps We present what to our knowledge is the first compre- and app components. hensive testing algorithm for Android IAC vulnerabilities. The Android IAC model is implemented as a message- Toward this end, we first describe a catalog, stemming from passing system, where messages are encapsulated as Intent our field experience, of 8 concrete vulnerability types that objects. Through Intents, an app (or app component) can can potentially arise due to unsafe handling of incoming IAC utilize functionality exposed by another app (or app com- messages. We then explain the main challenges that auto- ponent), e.g. by passing a message to the browser to render mated discovery of Android IAC vulnerabilities entails, in- content or to a navigation app to display a location and cluding in particular path coverage and custom data fields, provide directions to it. and present simple yet surprisingly effective solutions to The Android IAC interface is a significant attack sur- these challenges. face [?, 10, 4]. Familiar examples of IAC vulnerabilities are We have realized our testing approach as the Intent- Cross-Application Scripting (XAS), whereby an app is ma- Droid system, which is available as a commercial cloud nipulated into running untrusted JavaScript code when ren- service. IntentDroid utilizes lightweight platform-level in- dering IAC content inside an HTML-based view; client-side strumentation, implemented via debug breakpoints (to run SQL injection (SQLi), whereby an app backed by an SQLite atop any Android device without any setup or customiza- database (supported natively by the Android platform) in- tion), to recover IAC-relevant app-level behaviors. Evalu- tegrates unvalidated or unsanitized IAC data into an SQL ation of IntentDroid over a set of 80 top-popular apps query; and injection or manipulation of UI elements, which has revealed a total 150 IAC vulnerabilities | some already occur if reflective APIs, such as Fragment.instantiate(:::), fixed by the developers following our report | with a recall are used without proper input validation. We describe these rate of 92% w.r.t. a ground truth established via manual as well as other attack vectors in detail in Section 2.3. auditing by a security expert. Past Research. The Android IAC interface has been in- vestigated from different angles. These include static detec- Categories and Subject Descriptors tion algorithms for confidentiality threats due to outbound IAC [4]; fuzzing tools to test the robustness of message han- D.2.5 [Software/Testing and Debugging]: Testing tools dling [10], or otherwise detect specific security weaknesses like capability leakage [21]; as well as proposals to revise ar- chitectural aspects of the Android system for more secure General Terms IAC [7]). Algorithms, Experimentation, Security While these studies are all useful, a main concern that re- mains unaddressed is IAC integrity threats. In recent years, several critical IAC vulnerabilities have been disclosed. A notable example is CVE-2011-2357 [5], which reports a Cross- Permission to make digital or hard copies of all or part of this work for Application Scripting (XAS) vulnerability in the Android personal or classroom use is granted without fee provided that copies are Browser manually discovered by one of the authors of this not made or distributed for profit or commercial advantage and that copies paper. (See Section 2.3.) Yet another example is the ability bear this notice and the full citation on the first page. To copy otherwise, to to exploit the IAC interface using drive-by techniques, e.g. republish, to post on servers or to redistribute to lists, requires prior specific by pointing the browser at a malicious website [19]. These permission and/or a fee. ISSTA’15 , July 12–17, 2015, Baltimore, MD, USA and similar discoveries expose IAC as a potentially serious Copyright 2015 ACM 978-1-4503-3620-8/15/07 ...$15.00. security hole. To our knowledge, none of the existing research provides a 2. THE IAC ATTACK SURFACE solution for comprehensive integrity testing of IAC channels. In this section, we provide technical background on An- The main challenge for the testing tool is that all fields of an droid IAC, and then describe a catalog of security vulnera- IAC message but uri are custom (i.e., not specified in the bilities that are all exploitable via the IAC surface. These IAC interface declaration). This complicates the construc- are based on publicly available vulnerability reports [5] as tion of meaningful test inputs. Another challenge is how to well as on one of the authors' field experience in performing obtain effective path coverage with low overhead. manual security audits. Our Approach. We address the problem of testing for IAC integrity vulnerabilities. In stating this problem, we 2.1 Background: The Android Architecture place special emphasis on practicality. Our goal is to de- An Android app consists of components of the following sign a testing algorithm featuring high recall (or coverage) types: Activity, Fragment, Service, BroadcastReceiver alongside low overhead. This twofold requirement implies, and ContentProvider. All the components comprising an in specific, that the testing tool can only (i) rely on sparse app (except dynamically registered BroadcastReceivers) are app/platform instrumentation (as opposed to gleaning ar- declared in the app's manifest file (AndroidManifest.xml). bitrary run-time information), and (ii) apply a small and An Activity defines a single UI screen, e.g. a browsing focused set of tests. window or preferences dialog. A Fragment is a finer-grained While high coverage is a natural requirement, the motiva- UI container that is reusable within the same app. Services tion for low overhead is to enable efficient large-scale testing perform background tasks. Finally, the role of BroadcastRe- by third parties, such as app stores or organizations with a ceivers is to intercept incoming messages from other appli- Bring Your Own Device (BYOD) policy, that currently have cation components and ContentProviders. Another (poten- limited vetting power. Indeed, the testing system we have tial) component in an Android app is native code. Such code, created, dubbed , is packaged as a cloud-based IntentDroid typically written in C or C++, interfaces with the Java code service to support these use cases.1 via the Java Native Interface (JNI). The idea underlying is to monitor only a IntentDroid Android apps are executed in a sandboxed environment select set of platform APIs | those responsible for security- to protect both the system and the hosted applications from relevant functionality as well as access to IAC data | and malware [4]. The Android sandbox relies on, and augments, utilize the resulting run-time information to guide testing. the Linux kernel's isolation facilities. While sandboxing is We describe how, based on this information alone, Intent- a central security feature, it comes at the expense of inter- is able to prune redundant tests, recover custom IAC Droid operability. In many common situations, apps require the fields, and vary inputs to increase path coverage. ability to interact. For example, the browser app should be We report on extensive evaluation of across IntentDroid capable of launching the Google Play app if the user points a set of 80 top-popular Android apps from the wild, wherein toward the Google Play website. a security expert detected a total of 163 IAC vulnerabili- To recover interoperability, Android provides high-level ties. Using an average of 40 tests per app, IntentDroid IAC mechanisms via the Binder class, implemented as a was able to detect 150 of those vulnerabilities, which consti- driver in the Linux kernel. IAC is achieved via Messages (for tutes a recall rate of 92%. Some of the vulnerabilities have Services) and Intents (for Services as well as other com- already been fixed by the developers. Beyond validating the ponents). Intents are messaging objects that contain both overall efficacy of , we also validate each of the IntentDroid the payload and the target application component. Content design choices it features, and demonstrate its significance is placed into the uri (or data) attribute. and can addition- experimentally. Last, we provide qualitative insight into the ally be stored within an associated Bundle in the form of usefulness of via detailed analysis of several IntentDroid extra parameters. of the detected vulnerabilities. Intents can either be implicit, which means that the tar- Contributions. This paper makes the following principal get is not specified, or explicit, which means that a specific contributions: target is provided. Intents can be broadcast to Broadcas- 1. Comprehensive IAC Security Testing: We have created tReceivers, invoke Activitys, or launch a Service. An the first comprehensive dynamic testing system for An- application component can only be invoked by external par- droid IAC integrity vulnerabilities (Sections 4-5). ties, via an Intent, if the manifest file permits that.