Giter VIP home page Giter VIP logo

ast_js_fuzzing's Introduction

* Summary
Language fuzzing is '''hard'''.  To hit the runtime effectively, language fuzzing must create complicated files that are both correct in terms of their syntax and semantics.  Mutation fuzzing doesn't work well for this and, grammar fuzzing takes lots of effort.  This project proposes to build a language fuzzer that works on the AST (abstract syntax trees) in an mutation style.  Example language will be JavaScript.  JavaScript is loosely typed and has lots of interesting uses.  There are 5 board stages envisioned.

Stage 1, parse JS files
Get corpus of input files (mozilla/webkit) and build ASTs of each.
Found a python module called slimit that provides ASTs of JavaScript.  It's not that great, but will totally work for us.

Stage 2, mate files
Swap AST elements between trees that of similar types (i.e. exprs <=> exprs, decls <=> decls, cond <=> cond).

Stage 3, mutate files
Walk new ASTs and replace strings/numbers from bad sets.

Stage 4, semantic fixup
Walk new ASTs and add global vars where missing.  Loop back to stage 1 as necessary.

Stage 5, Emit code from ASTs
Throw and instrument

* To do:
1) The AST representation is not complete.  Some JS files will not parse.
2) The semantic fixups need some work.  Sometimes get an undefined symbol during fuzzed runtime.
3) Sometimes the emit code will run into infinite recursion.

* Example
There is a simple sample program to get you started.  It will lex, parse, walk and print AST and emit code for the simple.js program in samples.  Just run:
  python ./src/printJSast.py ./samples/small.js

* Rhino example, outputs will be in ast_js_fuzzing/src/t
cd astJSFuzz/src
mkdir t
./astJSFuzz.py -s 5 -n 3 -f ../samples/jses/vanilla/ -d 0.05 -o t -m -v

* References
http://packages.python.org/slimit/

ast_js_fuzzing's People

Contributors

bernielampe1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.