Quick and Dirty Guide to Fuzzing V8 with libFuzzer

What is V8?

V8 (also known as Chrome V8) is an open source JavaScript engine developed by The Chromium Project for the Google Chrome web browser. Other projects that use V8 include Couchbase, MongoDB and Node.js.

With my help, your V8 fuzzers will be up and running before you know it. Google does things a bit different, so it won't be as easy as ./configure && make but it's not really difficult once you figure out the right process. Thanks again to Google for giving me a nudge in the right direction.

Clone the depot_tools repository:

$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

Add depot_tools to the end of your PATH (you will probably want to put this in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools to /path/to/depot_tools:

$ export PATH="$PATH:/path/to/depot_tools"

Now we get the code we're going to fuzz. Create a chromium directory for the checkout and change to it:

$ mkdir ~/chromium && cd ~/chromium

Run the fetch tool from depot_tools to check out the code and its dependencies.

$ fetch --nohooks --no-history chromium

The --no-history option will speed things up as it won't pull down the entire git history, which we don't really need for fuzzing.

The remaining instructions assume you have switch to the src directory:

$ cd src

For this example, I am using Ubuntu 16.04 x64. If you're using Debian, these instructions should also work for you. Otherwise you may need to adjust the build dependencies.

Install additional build dependencies.

$ build/install-build-deps.sh

Run the hooks.

$ gclient runhooks

Now you've got the code base and the tools necessary to start building the fuzzers. For this example, I am using libFuzzer and not AFL. Blasphemy, I know. (;

Build the fuzzers:

First, we're going to run this command which will setup our targets:

$ gn gen out/libfuzzer '--args=use_libfuzzer=true is_asan=true is_ubsan_security=true is_debug=false enable_nacl=false' --check

This will tell the build system to use libFuzzer, ASan and UBSan. When it runs successfully, you'll be greeted by a message similar to Done. Made 6168 targets from 1323 files in 9620ms. Next run gn ls out/libfuzzer | grep fuzzer and you'll be greeted with a list which contains ~519 entries, most of which we won't be concerned with. For this example, I am going to pick a json parser, so let's run gn ls out/libfuzzer | grep json and see what pops up:


I think v8_json_parser_fuzzer looks like a good choice. So in order to build this particular fuzzer, we run this command:

$ ninja -C out/libfuzzer v8_json_parser_fuzzer

You'll see text like [55/1074] CXX obj/third_party/libFuzzer/libfuzzer/FuzzerExtraCounters.o while it is building. It can take a while, so be patient and have a cup of coffee. Once it has completed, cd out/libfuzzer and you'll find the v8_json_parser_fuzzer fuzzer along with a v8_json_parser_fuzzer.dict dictionary file and a v8_json_parser_fuzzer.options libFuzzer options file that you can use to define various things but we aren't going to get into that right now. Feel free to explore that on your own.

Create a directory for your starting corpus, naming it whatever you want:
$ mkdir json_parser_corpus

Fill json_parser_corpus with your json files. I don't use the included V8 fuzzing corpus because everyone and their dog fuzzes that stuff. Here is a sample for you to use if you don't want to find your own. (;


If you have a single core, your command line would be:
$ ./v8_json_parser_fuzzer json_parser_corpus/ -dict=v8_json_parser_fuzzer.dict

If you have multiple cores:
$ ./v8_json_parser_fuzzer json_parser_corpus/ -dict=v8_json_parser_fuzzer.dict -jobs=X -workers=X

Note: -jobs=X where X is the number of times you want the fuzzer to restart after it finds something that triggers that particular job to abort or crash and -workers=X where X is the number of CPU cores you want to libFuzzer to take advantage of.

Congratulations, you're now fuzzing V8. I hope you find a bug or two. Don't forget us little people when you're famous. (=



  • Abhishek Arya at Google.
  • My Twitter followers.
  • My Patreon supporters.

Shameless Plug

As always, you can support me on Patreon, via PayPal, Bitcoin 1HnyFwSJDjWFexD7oRr4HGTFwD8N6NsrfX or Ethereum 0xee9cBCB8DDC4f25832AD7FC02FADB981b1212D04.

Geeknik Labs

Also on this blog

SHARE:  Email · Facebook · Google · Twitter · Tumblr · Kindle
SUBSCRIBE:  Receive an email on new posts from Geeknik Labs


  • Notify me upon new comments

☺ Got it