<p>Fuzzing a JavaScript engine draws a lot of attention as the number of browser users is about 4 Billion. Several works have been done to find bugs in JS engines, including popular large engines, e.g, v8, webkit, chakracore, gecko, or some small embedded engines, like jerryscript, QuickJS, jsish, mjs, mujs.</p>
<p>It is really difficult to find bugs using AFL as the mutation mechanisms provided by AFL is not practical for JS files, e.g, bitflip can hardly be a valid mutation. Since JS is a structured language, several works using ECMAScript grammar to mutate/generate JS files(seeds):</p>
<p><a href="https://www.usenix.org/system/files/conference/usenixsecurity12/sec12-final73.pdf" rel="nofollow noreferrer">LangFuzz</a> parses sample JS files and splits them into code fragments. It then recombines the fragments to produce test cases.</p>
<p><a href="https://github.com/MozillaSecurity/funfuzz" rel="nofollow noreferrer">jsfunfuzz</a> randomly generates syntactically valid JS statements from JS grammar manually written for fuzzing.</p>
<p><a href="https://github.com/MozillaSecurity/dharma" rel="nofollow noreferrer">Dharma</a> is a generation-based, context-free grammar fuzzer, generating files based on given grammar.</p>
<p><a href="https://arxiv.org/pdf/1812.01197.pdf" rel="nofollow noreferrer">Superion</a> extends AFL using tree-based mutation guided by JS grammar.</p>
<p>The above works can easily pass the syntax checks but fail at semantic checks. A lot of generated JS seeds are semantically invalid.</p>
<p><a href="https://github.com/SoftSec-KAIST/CodeAlchemist" rel="nofollow noreferrer">CodeAlchemist</a> uses a semantics-aware approach to generate code segments based on a static type analysis.</p>
<p>There are two levels of bugs related to JS engines: simple parser/interpreter bugs and deep inside logic bugs. Recently, there is a trend that the number of simple bugs decreases while more and more deep bugs come out.</p>
<p><a href="https://github.com/sslab-gatech/DIE" rel="nofollow noreferrer">DIE</a> uses aspect-preserving mutation to preserves the desirable properties of CVEs. It also using type analysis to generate semantic-valid bugs.</p>
<p>Some works focus on mutating intermediate representations.</p>
<p><a href="https://github.com/googleprojectzero/fuzzilli" rel="nofollow noreferrer">Fuzzilli</a> is a coverage-guided fuzzer based on mutation on the IR level. The mutations on IR can guarantee semantic validity and can be transferred to JS.</p>
<p>Fuzzing JS is an interesting and hot topic according to the top conference of security/SE in recent years. Hope this information is helpful.</p>
Coverage-based fuzzing of JavaScript applications
<p>The <a href="https://lcamtuf.coredump.cx/afl/" rel="nofollow noreferrer">American Fuzzy Lop</a>, and the conceptually related LLVM <a href="https://llvm.org/docs/LibFuzzer.html" rel="nofollow noreferrer">libfuzzer</a> not only generate random fuzzy strings, but they also watch branch coverage of the code under test and use genetic algorithms to try to cover as many branches as possible. This increases the hit frequency of the more interesting code further downstream as otherwise most of the generated inputs will be stopped early in some deserialization or validation.</p>
<p>But those tools work at native code level, which is not useful for JavaScript applications as it would be trying to cover the interpreter, but not really the interpreted code.</p>
<p>So is there a way to fuzz JavaScript (preferably in browser, but tests running in node.js would help too) with coverage guidance?</p>
<p>I looked at the tools mentioned in <a href="https://stackoverflow.com/questions/16521143/">this old question</a>, but those that do javascript don't seem to mention anything about coverage profiling. And while <a href="https://gitlab.com/akihe/radamsa" rel="nofollow noreferrer">radamsa</a> mentions optionally pairing it with coverage analsysis, I haven't found any documentation on how to actually do it.</p>
<p>How can one fuzz-test java-script (in browser) application with coverage guidance?</p>