Favocado: Fuzzing the Binding Code of Javascript Engines Using Semantically Correct Test Cases

Favocado: Fuzzing the Binding Code of Javascript Engines Using Semantically Correct Test Cases

Favocado: Fuzzing the Binding Code of JavaScript Engines Using Semantically Correct Test Cases Sung Ta Dinh∗, Haehyun Cho∗, Kyle Martiny, Adam Oestz, Kyle Zeng∗, Alexandros Kapravelosy, Gail-Joon Ahn∗x, Tiffany Bao∗, Ruoyu Wang∗, Adam Doupe´∗, and Yan Shoshitaishvili∗ ∗Arizona State University, yNorth Carolina State University, zPayPal, Inc., xSamsung Research ∗ftdsung, haehyun, zengyhkyle, gahn, tbao, fishw, doupe, [email protected] yfkdmarti2, [email protected], [email protected] Abstract—JavaScript runtime systems include some special- by the introduction of multiple JavaScript fuzzers over the past ized programming interfaces, called binding layers. Binding few years, none of which could be used to fuzz binding code layers translate data representations between JavaScript and in non-browser environments [24, 27, 29, 34, 37, 40, 41, 55, 56]. unsafe low-level languages, such as C and C++, by converting data However, due to the complexity in the implementation of between different types. Due to the wide adoption of JavaScript binding layers in JavaScript engines, vulnerabilities in these (and JavaScript engines) in the entire computing ecosystem, layers are not rare [11]. Therefore, there is a pressing need discovering bugs in JavaScript binding layers is critical. Nonethe- less, existing JavaScript fuzzers cannot adequately fuzz binding to design JavaScript fuzzers to efficiently fuzz JavaScript code layers due to two major challenges: Generating syntactically and and effectively find bugs in these binding layers. semantically correct test cases and reducing the size of the input Even without considering the binding layers, it is difficult space for fuzzing. to effectively fuzz JavaScript engines in the first place. Re- In this paper, we propose Favocado, a novel fuzzing approach searchers found that for fuzzing JavaScript engines, the quality that focuses on fuzzing binding layers of JavaScript runtime of the initial fuzzing input (i.e., seeds) greatly impacts the systems. Favocado can generate syntactically and semantically fuzzing performance [44]. This is because JavaScript engines correct JavaScript test cases through the use of extracted semantic do not directly consume the user-provided JavaScript code. information and careful maintaining of execution states. This These engines will parse user input into an abstract syntax tree way, test cases that Favocado generates do not raise unintended (AST) and then process the tree. User inputs that cannot be runtime exceptions, which substantially increases the chance of triggering binding code. Additionally, exploiting a unique fea- transformed into an AST are easily rejected. Hence, JavaScript ture (relative isolation) of binding layers, Favocado significantly test cases generated by fuzzers that are unaware of JavaScript reduces the size of the fuzzing input space by splitting DOM specifications are likely to be malformed and rejected before objects into equivalence classes and focusing fuzzing within each being processed. equivalence class. We demonstrate the effectiveness of Favocado in our experiments and show that Favocado outperforms a state- To generate syntactically correct JavaScript code as test of-the-art DOM fuzzer. Finally, during the evaluation, we find 61 cases, modern JavaScript engine fuzzers use context-free gram- previously unknown bugs in four JavaScript runtime systems mars [8, 24, 29, 37, 57] or existing semantically correct test (Adobe Acrobat Reader, Foxit PDF Reader, Chromium, and cases [27, 40, 55, 56]. However, only being syntactically correct WebKit). 33 of these bugs are security vulnerabilities. is not enough for JavaScript engines to process a test case, as many JavaScript statements have interdependent relationships. Failing to capture such relationships will lead to generating I. INTRODUCTION semantically incorrect code that raises runtime exceptions The use of JavaScript has expanded beyond web browsers when being processed. While no JavaScript fuzzers generate into the entire computing ecosystem as a general-purpose pro- fully semantically correct code as test cases, some fuzzers can gramming language. As a result, JavaScript engines are embed- generate test cases in a semantic-aware manner [27, 40, 56]. ded in a variety of commercial software (e.g., Adobe Acrobat However, the percentage of rejected test cases that are gen- and Node.js). JavaScript engines often provide important func- erated by these semantic-aware fuzzers is still a significant tionality through a binding layer, which is usually implemented problem. in unsafe languages such as C and C++. While the JavaScript Unfortunately, existing fuzzers are likely to have a difficult engines are being heavily studied, fuzzed, and hardened, their time generating test cases that can adequately fuzz JavaScript binding layers are frequently overlooked. This is exemplified binding layers. As shown in Listing 1, a typical JavaScript test case that triggers the execution of binding code once involves at least two steps: (1) Creating the object and (2) setting a Network and Distributed Systems Security (NDSS) Symposium 2021 property of the object or calling a function of the object. 21-24 February 2021 ISBN 1-891562-66-5 Due to the excessive number of JavaScript exceptions that https://dx.doi.org/10.14722/ndss.2021.23xxx randomly generated test cases raise, it is practically impossible www.ndss-symposium.org for existing fuzzers to generate legitimate JavaScript code that 1 var cb= this.getField("CheckBox"); (e.g., Favocado is able to generate JavaScript statements 2 cb.checkThisBox(0,true); that do not access previously deallocated objects). Listing 1: An example JavaScript test case that triggers the Reducing the size of the input space. Favocado excavates execution of binding code to check a checkbox. relations between binding objects from the collected se- mantic information. Then it separates all binding objects into multiple equivalence classes based on their relations. Finally, Favocado focuses on fuzzing JavaScript binding covers both steps. Not to mention, generating a sequence of layer by each equivalence class. such snippets to execute binding code multiple times. To demonstrate the generality and effectiveness of Favocado, Another challenge for effectively fuzzing the binding layer we thoroughly evaluate our prototype with different types of is the enormous input space. There are many object types that binding objects (PDF, Mojo, and DOM). These binding objects are accessible with JavaScript through the binding layer as a are implemented in four different JavaScript runtime systems Document Object Model (DOM) (e.g., in Chromium, there are (Adobe Acrobat Reader, Foxit PDF Reader, Chromium, and more than 1,000 DOM binding objects). Each DOM object WebKit). During our evaluation, Favocado finds 61 previously may have a multitude of methods and properties, some of unknown bugs, which includes 33 severe security vulnerabili- which may require hard-to-satisfy arguments such as other ties. Our evaluation results show the effectiveness of Favocado, DOM objects. Creating all objects to enumerate all properties which outperforms the state-of-the-art DOM fuzzer, Domato. and manipulate all methods is simply infeasible. An effective fuzzer that adequately fuzzes JavaScript binding code should Contributions. This paper makes the following contributions: be aware of the unique features of this layer when generating test cases. With this embedded awareness built in, a fuzzer can • We propose Favocado, a novel approach for fuzzing optimize test case generation by reducing the size of the input binding layers of JavaScript engines. Favocado generates space. semantically correct JavaScript test cases based on ex- tracted semantic information and tracking states mutation. One unique feature of the JavaScript binding layer is the Favocado also reduces the input space by being aware of relative isolation of different DOM objects. Intuitively, differ- relations between DOM objects. ent DOM objects (e.g., for Adobe Acrobat, spell.check() • We implement a prototype of Favocado and thoroughly in its spell module and Net.HTTP.request() in its evaluate it against real-world binding code in four differ- Net.HTTP module) in the binding layer are implemented ent JavaScript runtime systems (Adobe Acrobat Reader, as separate native modules, unless an object defined in Foxit PDF Reader, Chromium, and WebKit) to demon- one module can be used by code in another module. A strate the effectiveness of Favocado. We also compare JavaScript test case that calls spell.check() before Favocado against Domato and show that Favocado out- Net.HTTP.request() is essentially equivalent to another performs Domato. test case that calls the two methods in reverse order. We may • We responsibly analyzed and disclosed all bugs found by define a DOM objects relation where an object can use another Favocado that include 33 security vulnerabilities. By the object as a value to its properties or a parameter to its methods. time of writing, 13 bugs have been assigned CVE entries Based on the relations between DOM objects, we may divide during the responsible disclosure process. the entire input space into equivalence classes. In our ex- ample, spell.check() and Net.HTTP.request() will To foster further research, we open source the prototype of fall into different equivalence classes. Object-relation-aware Favocado that we developed as part of our research. The fuzzers may only mutate DOM objects within each equivalence repository is at https://github:com/favocado/Favocado.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    15 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