Class Jazzer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA 32-bit random number that hooks can use to make pseudo-random choices between multiple possible mutations they could guide the fuzzer towards. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexploreState(byte state, int id) Instructs the fuzzer to attain as many possible values for the absolute value ofstateas possible.static voidguideTowardsContainment(String haystack, String needle, int id) Instructs the fuzzer to guide its mutations towards makinghaystackcontainneedleas a substring.static voidguideTowardsEquality(byte[] current, byte[] target, int id) Instructs the fuzzer to guide its mutations towards makingcurrentequal totarget.static voidguideTowardsEquality(String current, String target, int id) Instructs the fuzzer to guide its mutations towards makingcurrentequal totarget.static voidonFuzzTargetReady(Runnable callback) Register a callback to be executed right before the fuzz target is executed for the first time.static voidreportFindingFromHook(Throwable finding) Make Jazzer report the providedThrowableas a finding.
-
Field Details
-
SEED
public static final int SEEDA 32-bit random number that hooks can use to make pseudo-random choices between multiple possible mutations they could guide the fuzzer towards. Hooks must not base the decision whether or not to report a finding on this number as this will make findings non-reproducible.This is the same number that libFuzzer uses as a seed internally, which makes it possible to deterministically reproduce a previous fuzzing run by supplying the seed value printed by libFuzzer as the value of the
-seed.
-
-
Method Details
-
guideTowardsEquality
Instructs the fuzzer to guide its mutations towards makingcurrentequal totarget.If the relation between the raw fuzzer input and the value of
currentis relatively complex, running the fuzzer with the argument-use_value_profile=1may be necessary to achieve equality.- Parameters:
current- a non-constant string observed during fuzz target executiontarget- a string thatcurrentshould become equal to, but currently isn'tid- a (probabilistically) unique identifier for this particular compare hint
-
guideTowardsEquality
public static void guideTowardsEquality(byte[] current, byte[] target, int id) Instructs the fuzzer to guide its mutations towards makingcurrentequal totarget.If the relation between the raw fuzzer input and the value of
currentis relatively complex, running the fuzzer with the argument-use_value_profile=1may be necessary to achieve equality.- Parameters:
current- a non-constant byte array observed during fuzz target executiontarget- a byte array thatcurrentshould become equal to, but currently isn'tid- a (probabilistically) unique identifier for this particular compare hint
-
guideTowardsContainment
Instructs the fuzzer to guide its mutations towards makinghaystackcontainneedleas a substring.If the relation between the raw fuzzer input and the value of
haystackis relatively complex, running the fuzzer with the argument-use_value_profile=1may be necessary to satisfy the substring check.- Parameters:
haystack- a non-constant string observed during fuzz target executionneedle- a string that should be contained inhaystackas a substring, but currently isn'tid- a (probabilistically) unique identifier for this particular compare hint
-
exploreState
public static void exploreState(byte state, int id) Instructs the fuzzer to attain as many possible values for the absolute value ofstateas possible.Call this function from a fuzz target or a hook to help the fuzzer track partial progress (e.g. by passing the length of a common prefix of two lists that should become equal) or explore different values of state that is not directly related to code coverage (see the MazeFuzzer example).
Note: This hint only takes effect if the fuzzer is run with the argument
-use_value_profile=1.- Parameters:
state- a numeric encoding of a state that should be varied by the fuzzerid- a (probabilistically) unique identifier for this particular state hint
-
reportFindingFromHook
Make Jazzer report the providedThrowableas a finding.Note: This method must only be called from a method hook. In a fuzz target, simply throw an exception to trigger a finding.
- Parameters:
finding- the finding that Jazzer should report
-
onFuzzTargetReady
Register a callback to be executed right before the fuzz target is executed for the first time.This can be used to disable hooks until after Jazzer has been fully initializing, e.g. to prevent Jazzer internals from triggering hooks on Java standard library classes.
- Parameters:
callback- the callback to execute
-