FANS: Fuzzing Android Native System Services Via Automated Interface Analysis

FANS: Fuzzing Android Native System Services Via Automated Interface Analysis

FANS: Fuzzing Android Native System Services via Automated Interface Analysis Baozheng Liu1;2,∗ Chao Zhang1;2 , Guang Gong3, Yishun Zeng1;2, Haifeng Ruan4, Jianwei Zhuge1;2 1Institute of Network Science and Cyberspace, Tsinghua University [email protected] 2Beijing National Research Center for Information Science and Technology [email protected] 3Alpha Lab, 360 Internet Security Center 4Department of Computer Science and Technology, Tsinghua University Abstract 1 Introduction Android has become the most popular mobile operating sys- Android native system services provide essential supports and tem, taking over 85% markets according to International Data fundamental functionalities for user apps. Finding vulnerabil- Corporation1. The most fundamental functions of Android ities in them is crucial for Android security. Fuzzing is one of are provided by Android system services, e.g., the camera the most popular vulnerability discovery solutions, yet faces service. Until October 2019, hundreds of vulnerabilities re- several challenges when applied to Android native system lated to Android system services had been reported to Google, services. First, such services are invoked via a special inter- revealing that Android system services are still vulnerable and process communication (IPC) mechanism, namely binder, attractive for attackers. A large portion of these vulnerabilities via service-specific interfaces. Thus, the fuzzer has to recog- reside in native system services, i.e., those mainly written in nize all interfaces and generate interface-specific test cases C++. Vulnerabilities in Android native system services could automatically. Second, effective test cases should satisfy the allow remote attackers to compromise the Android system, interface model of each interface. Third, the test cases should e.g., performing privilege escalation, by means of launching also satisfy the semantic requirements, including variable IPC requests with crafted inputs from third-party applications. dependencies and interface dependencies. Finding vulnerabilities in Android native system services is thus crucial for Android security. In this paper, we propose an automated generation-based However, to the best of our knowledge, existing researches fuzzing solution FANS to find vulnerabilities in Android na- paid little attention to Android native system services. Apart tive system services. It first collects all interfaces in target from a non-scalable manual approach [7], two automated services and uncovers deep nested multi-level interfaces to fuzzing solutions have been proposed to discover vulnera- test. Then, it automatically extracts interface models, includ- bilities in Android system services. The first one is Binder- ing feasible transaction code, variable names and types in the Cracker [6], which captures input models of target services transaction data, from the abstract syntax tree (AST) of target by recording requests made by 30 popular applications. An interfaces. Further, it infers variable dependencies in transac- inherent disadvantage of this approach is that it cannot re- tions via the variable name and type knowledge, and infers cover precise input semantics, e.g., variable names and types. interface dependencies via the generation and use relation- Also, it will miss rarely-used or deeply-nested interfaces, due ship. Finally, it employs the interface models and dependency to the incomplete testing. The other one is Chizpurfle [10], knowledge to generate sequences of transactions, which have which utilizes Java reflection to acquire parameter types of valid formats and semantics, to test interfaces of target ser- interfaces to test vendor-implemented Java services. However, vices. We implemented a prototype of FANS from scratch and such a method cannot be used to retrieve the input model of evaluated it on six smartphones equipped with a recent ver- Android native system services. sion of Android, i.e., android-9.0.0_r46 , and found 30 unique In Android, system services are registered to the Service vulnerabilities deduplicated from thousands of crashes, of Manager. User apps query the manager to get the target which 20 have been confirmed by Google. Surprisingly, we service’s interface (encapsulated in a proxy Binder object), also discovered 138 unique Java exceptions during fuzzing. then invoke different transactions provided by this interface via a unified remote procedure call (RPC) interface named IBinder::transact(code,data,reply,flags), where, ∗Part of this work was done during Baozheng Liu’s research internship at Alpha Lab of 360. 1https://www.idc.com/promo/smartphone-market-share/os (1) code determines the target transaction to invoke, and (2) ated by invoking the special method writeStrongBinder to inputs of the transaction are marshalled into the serialized identify multi-level interfaces. For C2, we notice that, Android parcel object data. Thus, we could utilize this unified system services always use a set of specific deserialization IPC method to test all system services. To thoroughly methods (e.g., readInt32) to parse input data. By recogniz- test target services, we could first find all interfaces and ing the invocation sequence of such methods, we could infer available transactions, and then invoke them with input data the grammar of a valid input. To preserve the knowledge of satisfying service-specific formats and semantic requirements. variables’ names and types, we choose to extract the deserial- Specifically, there are three challenges to address: ization sequence (i.e., the input grammar) from abstract syntax C1: Multi-Level Interface Recognition. In addition to the tree (AST). For C3, we will utilize the variable name and type (top-level) interfaces registered in the Service Manager, knowledge extracted from the AST to generate proper inputs there are nested multi-level interfaces, which could be re- and recognize intra-transaction variable dependency. Further, trieved via the top-level interface and invoked by user apps. we rely on the fact that a dependent transaction will deserial- For example, the IMeoryHeap interface is buried at the fifth- ize data serialized by the depended transaction, to recognize level (i.e., invoked via four layers of interfaces). Therefore, inter-transaction variable dependency. Moreover, we rely on we need to recognize all top-level interfaces and nested multi- the generation and use relationship between interfaces to infer layer interfaces, in order to systematically test Android system their dependencies. services. Given that many interfaces are defined in Android We implemented a prototype of FANS from scratch, inter- Interface Definition Language (AIDL) rather than C++ and mittently examined it on six mobile phones equipped with the dynamically generated during compilation, we have to take recent Android version android-9.0.0_r46 for about 30 days. them into consideration as well. FANS has discovered 30 unique vulnerabilities deduplicated C2: Interface Model Extraction. For each interface, we from thousands of crashes. To our surprise, FANS also found need to get the list of supported transactions (i.e., code) to 138 unique Java exceptions, yielded by Java applications that test, and then provide input data to invoke each transaction. might depend on Android native system services. Besides, To improve the fuzzing effectiveness, the input data should we dig into the code and observe that some Android native follow grammatical requirements of target interfaces. Manu- system services would also invoke Java methods. We have ally providing the grammar knowledge is not scalable. Auto- submitted all native bugs to Google, and received 20 con- matically extracting such knowledge from the large volume firmations. As for the Java exceptions, we are working on of Android source code is also challenging. First, the gram- examining them manually and submitting them to Google. mar is specific to an individual transaction, and thus we have To facilitate future research, we open source the prototype of to recognize all available transactions and extract grammars FANS at https://github.com/iromise/fans. for each of them. Second, the grammar requirements co-exist with the path constraints, e.g., branch conditions, loop condi- tions and even nested loops, making it hard to be extracted Contributions. In summary, this paper makes the following and represented. contributions: C3: Semantically-correct Input Generation. Android it- • We systematically investigated the dependency between self performs many sanity checks (e.g., size check) on the interfaces in Android native system services, and un- input data. Therefore, inputs that do not meet semantic re- earthed deeper multi-level interfaces. quirements can hardly explore deep states or trigger vulner- • We proposed a solution to automatically extract input abilities. There are many types of semantic requirements, interface model and semantics from AST. This method including variable names and types, and even dependencies can be applied to other interface-based programs. between variables or interfaces. For instance, a variable named • We proposed a solution to infer inter-transaction depen- packageName indicates an existing package’s name is re- dencies, by utilizing variable name and type knowledge quired; a variable of an enumeration type can only have a in serialization and deserialization pairs in different trans- limited set of candidate values; a variable in current transac- actions. tion may depend on another variable in either the

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us