Skip to content

Latest commit

 

History

History
100 lines (71 loc) · 3.66 KB

cargofuzz.md

File metadata and controls

100 lines (71 loc) · 3.66 KB

cargo-fuzz (libfuzzer)

Command-line wrapper for using libFuzzer. Easy to use, no need to recompile LLVM!

Cargo-fuzz repository: cargo-fuzz.

cargo-fuzz is documented in the Rust Fuzz Book.

Installation

$ cargo install --force cargo-fuzz

cargo-fuzz + wasmer

Copy the fuzz folder inside wasmer repository and copy your input dataset corpus inside corpus/FUZZER_NAME.

compile

Simple fuzzer calling wasmer_runtime::compile.

compile_with_llvm

Fuzzer using wasmer_runtime::compile_with API with:

diff_compile_backend

Fuzzer twice wasmer_runtime::compile_with API with respectively llvm and singlepass backends. Then, results of both compilations are compared to detect differences in compilation.

validate

Simple fuzzer calling wasmer_runtime_core::validate_and_report_errors_with_features with:

validate_all_feat

Simple fuzzer calling wasmer_runtime_core::validate_and_report_errors_with_features with:

simple_instantiate [USELESS/DEPRECATED]

Not really interesting to use this fuzzer because every valid errors through by wasmer will be considered as crash by libfuzzer. In practice, that mean the fuzzer will crash almost immediately.

Tips/options for cargo-fuzz

Help: cargo fuzz run --help

Interesting options:

	[...]
    -O, --release                Build artifacts in release mode, with optimizations
    -a, --debug-assertions       Build artifacts with debug assertions enabled (default if not -O)

OPTIONS:
	--features <features>
		Build artifacts with given Cargo feature enabled
	-s, --sanitizer <sanitizer>
		Use different sanitizer [default: address] [possible values: address, leak, memory,thread]
    -j, --jobs <JOBS>
    	Number of concurrent jobs to run [default: 1]

Some useful options (to be used as `cargo fuzz run fuzz_target -- <options>`) include:
 - `-max_len=<len>`: Will limit the length of the input string to `<len>`
 - `-runs=<number>`: Will limit the number of tries (runs) before it gives up
 - `-max_total_time=<time>`: Will limit the amount of time to fuzz before it gives up
 - `-timeout=<time>`: Will limit the amount of time for a single run before it considers that run a failure
 - `-only_ascii`: Only provide ASCII input
 - `-dict=<file>`: Use a keyword dictionary from specified file. See http://llvm.org/docs/LibFuzzer.html#dictionaries

Corpus & Testcases minimization

Example