Algorithmadvanced
Hybrid fuzzing
Also called Driller, fuzzing with concolic assistance.
Runs a greybox fuzzer and calls concolic execution only when the fuzzer is stuck, to solve the branch conditions it cannot pass.
- Time
- O(N (L + T) + q m (m^2 + L + T)) worst
- Space
- O(q L + m) extra
- Where
- L = the length of an input; N = the number of fuzzing iterations; T = the cost of one run of the target; m = the largest number of branches on a path; q = the number of queue inputs
- Model
- Word RAM
- Properties
- randomizedofflinerandomizediterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Rupak Majumdar, Koushik Sen, 2007
Hybrid fuzzing combines a coverage-guided fuzzer with concolic testing. The fuzzer is cheap and explores the parts of a program that random changes reach. It is poor at comparisons with specific values, such as a 4-byte magic number, which a random change passes with probability . A concolic engine can solve such a comparison, but it is slow and its number of paths grows exponentially. A hybrid fuzzer runs the fuzzer by default and calls the concolic engine only when the fuzzer stops finding new coverage. The engine then traces the inputs that the fuzzer has kept, solves the branch conditions whose other side is not yet covered, and gives the new inputs back to the fuzzer. Majumdar and Sen (ICSE 2007) proposed the interleaving, and Driller (Stephens et al., NDSS 2016) made it the standard design for greybox fuzzers. The costs on this page are in the word-RAM model.
In plain words
A fuzzer changes inputs at random and keeps the ones that make the program do something new. It is fast, but it gets stuck at checks that need one exact value. For example, if the program wants the first four bytes to be "TOY2", random changes almost never get there.
A concolic engine runs the program and writes down each check as a small equation over the input bytes. A solver can then answer the question "which input passes this check?" exactly. But this is slow, and a large program has too many paths to try them all.
A hybrid fuzzer uses both. The fuzzer works until it finds nothing new for a while. Then the engine solves the checks that block it. The fuzzer goes on from the new inputs.
The problem
The input is a deterministic program and a set of seed inputs. The goal is to cover as many branches of as possible, and to find inputs that make fail, within a budget of runs. Coverage is counted here as the set of (site, outcome) pairs of the branches that some kept input executes. No method covers every reachable branch of every program, by Rice's theorem, so the measure of a fuzzer is what it covers and finds within the budget, and that is a measurement on given targets.
Driller describes the difficulty with two kinds of input. General input can take many values, such as a user name, and a fuzzer explores it well. Specific input has few valid values, such as a command name or a hash, and checks on it split the program into compartments. The fuzzer explores inside a compartment; the concolic engine finds the specific values that lead into the next one.
The algorithm
The main block below is the loop of the implementation. MUTATE applies a few random byte changes. A path condition is the list of the branch conditions of one run, each with the outcome it had. SOLVE returns an input that satisfies a conjunction of conditions and keeps the bytes of the given input elsewhere, or reports that none exists.
HYBRID-FUZZ(P, seeds, N, S) ▷ S: the number of runs without progress that means stuck- 1
Q ← the seeds, cov ← the (site, outcome) pairs of their runs, stall ← 0, traced ← ∅ - 2
for r ← 1 to N do - 3
x ← MUTATE(an input of Q chosen at random) - 4
if the run of P on x covers a pair not in cov then add x to Q and its pairs to cov, stall ← 0 - 5
else stall ← stall + 1 - 6
if stall ≥ S then ▷ the fuzzer is stuck: call the concolic engine - 7
for each y in Q that is not in traced do - 8
add y to traced, φ_1 ... φ_m ← the path condition of the run of P on y - 9
for j ← 1 to m such that the other outcome of φ_j is not in cov do - 10
z ← SOLVE(φ_1 ∧ ... ∧ φ_(j-1) ∧ ¬φ_j), keeping the other bytes of y - 11
if z exists and covers a pair not in cov then add z to Q and its pairs to cov - 12
stall ← 0 - 13
return Q, cov and the inputs on which P failed
Line L9 is what makes the concolic step selective. It skips the branches whose other side some input has already covered, and line L7 traces each input once. So the engine does not explore all paths, only the ones that lead to new coverage. Real engines run on the binary and call an SMT solver; the implementation of this page reads its input through comparisons of fields with constants, and SOLVE is an exact interval solver for them.
Example
The target reads six bytes. It compares the first four bytes, as a little-endian integer, with the value of the bytes "TOY2". If that holds, it checks that byte 4 is less than 16. If that holds, it checks that byte 5 is , and then it fails. The seed is six zero bytes.
Greybox fuzzing alone. The implementation with larger than the budget, 20,000 iterations and generator seed 0, covers only one pair, (site 1, false). It never passes the first check.
Hybrid fuzzing. With and the same generator seed:
| step | what happens | new pairs |
|---|---|---|
| seed | the run fails the first check | (1, false) |
| 200 runs | nothing new, so the first concolic phase starts | |
| phase 1 | trace the seed; flip ; SOLVE writes "TOY2" into bytes 0 to 3, giving "TOY2" followed by two zero bytes | (1, true), (2, true), (3, false) |
| fuzzing | a mutation sets byte 4 to , which is 16 or more | (2, false) |
| 200 runs | nothing new, so the second concolic phase starts | |
| phase 2 | trace "TOY2" with two zero bytes; pairs of sites 1 and 2 are covered, so skip them; flip ; SOLVE sets byte 5 to | (3, true), and the target fails |
The failing input "TOY2", , appears after 476 runs in total. The fuzzer passed the easy check of byte 4 by itself, and the engine solved the two exact checks. The tests of the implementation check these numbers.
Correctness
The method is a search, so its guarantees are about what it reports and about one class of programs. Every reported failure is real, and every input in the queue covered a new pair when it was added. The solver is exact for the conditions of the toy language: it fails only when no input satisfies the conjunction. An input from line L10 follows the path of up to branch and then takes the other side, because the program reads its input only through its branch conditions and it sees the same outcomes up to . For programs whose decision tree reaches each site by one sequence of outcomes, once every queue input is traced, every pair that some input covers is covered. In programs with loops or joins, the skip rule of line L9 can lose a path, so the method is not complete in general. The full proof is in the proof file, and the tests compare the coverage of the implementation with the reachable pairs on 500 random decision trees.
Proof: Correctness of hybrid fuzzingfull
We prove the claims of the Correctness section for HYBRID-FUZZ (lines L1 to L13) and its solver. The target reads its input only through branch conditions , each the comparison of the field , read as an unsigned little-endian integer, with a constant . Two fields that reads are equal or disjoint. is deterministic, so the next condition it evaluates, or the decision to stop or to fail, is a function of the outcomes it has seen so far. The path of an input is the list of the conditions it evaluates with their outcomes, and its pairs are the (site, outcome) pairs on the path.
Claim 1 (the solver is exact). For a conjunction of conditions "(", SOLVE returns None if and only if no input satisfies the conjunction. Otherwise it returns an input that satisfies it and that equals in every byte outside the constrained fields.
Proof. For one field of width , the set of values that satisfy one condition is an interval of or the union of two intervals (for ). RESTRICT intersects a finite union of disjoint intervals with such a set, interval by interval, so after all the conditions on the field its result is exactly the set of the values of the field that satisfy them. The fields are disjoint, so the conjunction is satisfiable if and only if every field has a nonempty set, and a choice of one value per field satisfies it. SOLVE writes such a value into each constrained field and copies every other byte of .
The cost of SOLVE is for conditions and inputs of bytes, since a condition on a field can add at most one interval to its list.
Claim 2 (a flip follows the prefix). Let have path with outcomes , and let be the result of line L10 for index . Then the path of starts with with outcomes , followed by with outcome .
Proof. By induction on . The first condition that evaluates does not depend on the input, so it is for both runs. Suppose the run on has evaluated with outcomes . Then has seen the same outcomes as on , so it evaluates the same next condition . By Claim 1, satisfies the conjunction of line L10, so the outcome of on is if and if .
Claim 3 (no false reports). Every input in the list of crashes makes fail, and every input in the queue covered, when it was added, a pair that no earlier input covered.
Proof. An input goes to the crash list only after a run of on it failed, and is deterministic. Lines L1, L4 and L11 add an input to the queue only if its pairs are not all in the covered set, and then add those pairs to the set. So the covered set is always the union of the pairs of the queue inputs.
Claim 4 (completeness on decision trees). Suppose every site of occurs at one node of its decision tree: the outcomes that lead to a site are the same in every run that reaches it. Suppose a concolic phase (lines L7 to L11) ends in which every queue input was already traced and no input was added. Then every pair that some input covers is in the covered set.
Proof. Let be any input, with path and outcomes . Among the queue inputs, let be one whose outcomes agree with those of on the longest prefix, of length . If , the pairs of are pairs of , which are covered by Claim 3. Otherwise has seen the same outcomes as for conditions, so it evaluates next, and its outcome is , since is the longest. Consider the pair . If it is covered, some queue input covers it by Claim 3. Its run reaches the node of that site, so by the hypothesis on sites it has the outcomes and then , which contradicts the choice of . If it is not covered now, it was not covered when was traced, since the covered set only grows. So line L9 did not skip index , and line L10 asked for an input with the outcomes and then . The input satisfies this conjunction, so by Claim 1 SOLVE returned some , and by Claim 2 the run of covers the pair. Line L11 then put the pair into the covered set, which contradicts the assumption that it is not covered.
The hypothesis of Claim 4 matters. In a program with loops or with paths that join, a site can be reached by different prefixes, and the rule of line L9, which skips a branch whose other outcome some input already covered, can skip the only prefix that leads further. Driller and other hybrid fuzzers make the same choice for speed, so they are not complete in general; neither is any fuzzer, by Rice's theorem.
Claim 5 (cost). With iterations, a queue of inputs, paths of at most conditions, inputs of bytes and runs of cost , the time is .
Proof. An iteration copies and mutates an input in and runs it once. Each queue input is traced at most once, because line L7 skips traced inputs, and it gives at most calls of SOLVE, each followed by at most one run.
Complexity
An iteration of the fuzzer costs : a copy, a few changes and a run. Each of the queue inputs is traced at most once, with at most solver calls of cost for the interval solver, and one run each. The time is , and the space is . With a real SMT solver, a call can take exponential time in the worst case, since the problem includes SAT; in practice the solver time and the trace time dominate, which is why the concolic step runs only when the fuzzer is stuck.
Properties
- Randomized. The fuzzing part draws its mutations from a generator; the concolic part is deterministic.
- Selective. The engine solves only branches whose other side is uncovered, and traces each input once.
- Sound reports. Every failure is checked by a real run; a wrong solver answer only wastes a run.
- Incomplete. It misses branches whose conditions the solver cannot handle in time, and paths that the skip rule drops.
Variants and improvements
- Interleaving by schedule. Majumdar and Sen switch from random testing to concolic execution when random testing saturates, and back, as here. Other designs run the two at the same time on separate cores and share the queue.
- A faster engine. QSYM (Yun et al., USENIX Security 2018) emulates only the instructions that touch symbolic data, drops the soundness of plain concolic execution, and lets the fuzzer check its answers. Its abstract reports that it outperformed Driller on 104 of the 126 Cyber Grand Challenge binaries, and found 13 unknown bugs in eight real programs.
- Choosing what to solve. Later systems rank the branches and inputs by a cost or probability model and send only the most promising ones to the solver, instead of all uncovered branches.
- No solver. Input-to-state correspondence solves many magic value and checksum comparisons by searching the input for the logged operands, at the cost of one extra run per input. A hybrid fuzzer still helps when the program transforms the bytes before the comparison.
- Whitebox fuzzing. Generational search in SAGE flips every branch of a path in one run of the engine, without a greybox fuzzer.
When to use it
Use a hybrid fuzzer on programs with checks on specific values that guard large parts of the code: file format parsers with magic numbers and command interpreters with fixed keywords. Use it when a concolic engine for the target exists and scales to its runs. For programs where most branches depend on general input, a plain greybox fuzzer covers almost as much at lower cost. When the hard checks compare copies of input bytes, try input-to-state correspondence first.
Pitfalls
- Calling the engine too often. A small stall threshold makes the slow engine run all the time. A large one wastes fuzzing time on a fuzzer that is stuck. The threshold is a design choice; Driller makes it proportional to the length of the input.
- Path explosion in the engine. Tracing an input through a parser with loops can give long path conditions and hard queries. Set a time limit per query.
- Unsound engines. An engine that misses some data flows produces inputs that do not take the expected branch. The fuzzer must run every new input and keep it only if it covers something new.
- Comparing fuzzers. Claims that one hybrid fuzzer finds more bugs than another are measurements on given targets, seeds and time budgets. Klees et al. (CCS 2018) list what a fair comparison needs: repeated runs, statistical tests and long enough runs.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hybrid-fuzzing/. The authors are listed in prov/0RJWH1.jsonl.
"""Hybrid fuzzing: a greybox fuzzer that calls concolic execution when it is stuck.
The fuzzer mutates inputs of a queue at random and keeps an input when it
covers a (site, outcome) pair of a branch that no earlier input covered.
When S runs in a row bring nothing new, the fuzzer is stuck. Then each queue
input that was not traced before is run once with its path condition
recorded, and for each branch on the path whose other outcome is not yet
covered, a solver looks for an input that follows the same path up to that
branch and then takes the other side. This is the plan of Driller (Stephens
et al., NDSS 2016), on a toy scale.
The target is a Python callable target(t) that reads its input only through
the tracer: t.branch(site, i, w, op, k) compares the field x[i : i + w], read
as a little-endian unsigned integer, with the constant k by op, one of
"==", "!=", "<", "<=", ">", ">=", and returns the outcome. The target may
raise an exception, which counts as a crash. Two fields that a target reads
are either the same (same i and w) or disjoint, so the path condition is a
conjunction of conditions on separate fields, and the solver below is exact
for it. Real hybrid fuzzers call an SMT solver on conditions of any shape.
The inputs have a fixed length. The mutation operators, the stall threshold
S and the order of the queue are design choices, not theorems. The tests use
small targets written for the purpose; nothing here runs a real program.
"""
import random
from dataclasses import dataclass, field
from typing import Callable, Optional, Sequence
OPS = ("==", "!=", "<", "<=", ">", ">=")
def holds(v: int, op: str, k: int) -> bool:
"""The outcome of the comparison v op k."""
if op == "==":
return v == k
if op == "!=":
return v != k
if op == "<":
return v < k
if op == "<=":
return v <= k
if op == ">":
return v > k
if op == ">=":
return v >= k
raise ValueError(op)
NEGATE = {"==": "!=", "!=": "==", "<": ">=", ">=": "<", "<=": ">", ">": "<="}
class Tracer:
"""Gives the target its input field by field and records the path condition."""
def __init__(self, x: bytes) -> None:
self.x = x
self.path: list[tuple] = [] # (site, i, w, op, k, outcome)
def branch(self, site: int, i: int, w: int, op: str, k: int) -> bool:
if i < 0 or w < 1 or i + w > len(self.x):
raise IndexError("field outside the input")
v = int.from_bytes(self.x[i:i + w], "little")
out = holds(v, op, k)
self.path.append((site, i, w, op, k, out))
return out
Target = Callable[[Tracer], None]
@dataclass
class Run:
path: list
crashed: bool
def pairs(self) -> set:
return {(c[0], c[5]) for c in self.path}
def run(target: Target, x: bytes) -> Run:
"""Run the target once on x."""
t = Tracer(x)
crashed = False
try:
target(t)
except IndexError:
raise
except Exception:
crashed = True
return Run(t.path, crashed)
def restrict(dom: list[tuple[int, int]], op: str, k: int, top: int) -> list[tuple[int, int]]:
"""Intersect a sorted list of disjoint closed intervals with {v : v op k}."""
if op == "==":
allowed = [(k, k)]
elif op == "!=":
allowed = [(0, k - 1), (k + 1, top)]
elif op == "<":
allowed = [(0, k - 1)]
elif op == "<=":
allowed = [(0, k)]
elif op == ">":
allowed = [(k + 1, top)]
else:
allowed = [(k, top)]
out = []
for lo, hi in dom:
for a, b in allowed:
l, h = max(lo, a), min(hi, b)
if l <= h:
out.append((l, h))
out.sort()
return out
def solve(conds: Sequence[tuple], x: bytes) -> Optional[bytes]:
"""An input that satisfies every condition, equal to x outside the constrained fields.
Each condition is (i, w, op, k, want), meaning that (field op k) == want.
Fields are the same or disjoint. In a field, the value of x is kept if it
satisfies the conditions, and otherwise the smallest value that does is
used. Returns None if no input satisfies the conditions. Cost O(m^2 + L)
for m conditions and inputs of L bytes.
"""
doms: dict[tuple[int, int], list[tuple[int, int]]] = {}
for i, w, op, k, want in conds:
top = 256 ** w - 1
d = doms.setdefault((i, w), [(0, top)])
doms[(i, w)] = restrict(d, op if want else NEGATE[op], k, top)
y = bytearray(x)
for (i, w), d in doms.items():
if not d:
return None
cur = int.from_bytes(x[i:i + w], "little")
if not any(lo <= cur <= hi for lo, hi in d):
cur = d[0][0]
y[i:i + w] = cur.to_bytes(w, "little")
return bytes(y)
def mutate(x: bytes, rng: random.Random) -> bytes:
"""Apply 1 to 4 random byte sets or bit flips; the length stays the same."""
b = bytearray(x)
for _ in range(rng.randint(1, 4)):
i = rng.randrange(len(b))
if rng.random() < 0.5:
b[i] = rng.randrange(256)
else:
b[i] ^= 1 << rng.randrange(8)
return bytes(b)
@dataclass
class HybridResult:
queue: list[bytes] = field(default_factory=list)
crashes: list[bytes] = field(default_factory=list)
covered: set = field(default_factory=set)
runs: int = 0
concolic_phases: int = 0
def hybrid_fuzz(target: Target, seeds: Sequence[bytes], rng: random.Random, iterations: int, stall: int, stop_on_crash: bool = True) -> HybridResult:
"""Run HYBRID-FUZZ for the given number of fuzzing iterations.
stall is the threshold S of runs without new coverage that calls the
concolic phase; a value larger than iterations gives plain greybox
fuzzing. Precondition: the seeds are nonempty, of one length L >= 1, and
the target is deterministic. Cost O(N (L + T) + q m (m^2 + L + T)) for N
iterations, q queue inputs, paths of at most m branches and runs of cost T.
"""
res = HybridResult()
traced: set[bytes] = set()
def consider(x: bytes) -> bool:
r = run(target, x)
res.runs += 1
if r.crashed:
res.crashes.append(x)
new = r.pairs() - res.covered
if new:
res.covered |= new
res.queue.append(x)
return bool(new)
for s in seeds: # @line L1
consider(s)
if not res.queue:
res.queue.append(seeds[0])
since = 0
for _ in range(iterations): # @line L2
if stop_on_crash and res.crashes:
break
x = mutate(res.queue[rng.randrange(len(res.queue))], rng) # @line L3
if consider(x): # @line L4
since = 0
else:
since += 1 # @line L5
if since >= stall: # @line L6
res.concolic_phases += 1
for y in list(res.queue): # @line L7
if y in traced:
continue
traced.add(y)
path = run(target, y).path # @line L8
res.runs += 1
for j, (site, i, w, op, k, out) in enumerate(path): # @line L9
if (site, not out) in res.covered:
continue
conds = [(c[1], c[2], c[3], c[4], c[5]) for c in path[:j]]
conds.append((i, w, op, k, not out))
z = solve(conds, y) # @line L10
if z is not None:
consider(z) # @line L11
since = 0 # @line L12
return res # @line L13
test_hybrid_fuzzing.py 177 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hybrid-fuzzing/. The authors are listed in prov/0RJWH1.jsonl.
import itertools
import random
import pytest
from hybrid_fuzzing import OPS, holds, hybrid_fuzz, run, solve
MAGIC = int.from_bytes(b"TOY2", "little")
class Found(Exception):
pass
def page_target(t):
"""The target of the page: a 4-byte magic value, then two one-byte checks."""
if t.branch(1, 0, 4, "==", MAGIC):
if t.branch(2, 4, 1, "<", 16):
if t.branch(3, 5, 1, "==", 0x2A):
raise Found()
def test_page_example():
seed = bytes(6)
grey = hybrid_fuzz(page_target, [seed], random.Random(0), 20000, 10 ** 9)
assert grey.covered == {(1, False)} and grey.crashes == []
assert grey.runs == 20001
hyb = hybrid_fuzz(page_target, [seed], random.Random(0), 20000, 200)
assert hyb.crashes == [b"TOY2\x00\x2a"]
assert hyb.concolic_phases == 2 and hyb.runs == 476
assert hyb.queue[1] == b"TOY2\x00\x00"
assert len(hyb.covered) == 6
def test_solver_edge_cases():
x = bytes(4)
assert solve([], x) == x
assert solve([(0, 1, "==", 5, True), (0, 1, "==", 6, True)], x) is None
assert solve([(0, 1, "<", 0, True)], x) is None
assert solve([(0, 1, ">", 255, True)], x) is None
assert solve([(0, 2, "==", 258, True)], x) == bytes([2, 1, 0, 0])
# The bytes of x are kept where they already satisfy the condition.
assert solve([(1, 1, ">", 3, True)], bytes([9, 7, 9, 9])) == bytes([9, 7, 9, 9])
with pytest.raises(IndexError):
run(lambda t: t.branch(1, 3, 2, "==", 0), bytes(4))
LAYOUTS = [
[(0, 1), (1, 1), (2, 1), (3, 1)],
[(0, 2), (2, 1), (3, 1)],
[(0, 2), (2, 2)],
[(0, 4)],
[(0, 1), (1, 3)],
]
def random_constant(rng, w):
top = 256 ** w - 1
return rng.choice([0, top, rng.randrange(top + 1), rng.randrange(16)])
def representatives(fields_consts):
"""For each field, values that meet every satisfiable conjunction of its conditions."""
reps = {}
for (i, w), ks in fields_consts.items():
top = 256 ** w - 1
vals = {0, top}
for k in ks:
vals |= {k - 1, k, k + 1}
reps[(i, w)] = sorted(v for v in vals if 0 <= v <= top)
return reps
def test_random_solver_against_representatives():
rng = random.Random(31)
for _ in range(800):
layout = rng.choice(LAYOUTS)
conds = []
for _ in range(rng.randint(0, 5)):
i, w = rng.choice(layout)
conds.append((i, w, rng.choice(OPS), random_constant(rng, w), rng.random() < 0.5))
x = bytes(rng.randrange(256) for _ in range(4))
z = solve(conds, x)
consts = {}
for i, w, _, k, _ in conds:
consts.setdefault((i, w), set()).add(k)
reps = representatives(consts)
sat = all(
any(all(holds(v, op, k) == want for (i2, w2, op, k, want) in conds if (i2, w2) == f) for v in vals)
for f, vals in reps.items()
)
if z is None:
assert not sat
else:
assert sat
for i, w, op, k, want in conds:
assert holds(int.from_bytes(z[i:i + w], "little"), op, k) == want
touched = {j for (i, w) in consts for j in range(i, i + w)}
assert all(z[j] == x[j] for j in range(4) if j not in touched)
def random_tree(rng, layout, depth, counter):
if depth == 0 or rng.random() < 0.25:
return ("leaf", rng.random() < 0.3)
i, w = rng.choice(layout)
counter[0] += 1
site = counter[0]
return ("branch", site, i, w, rng.choice(OPS), random_constant(rng, w),
random_tree(rng, layout, depth - 1, counter), random_tree(rng, layout, depth - 1, counter))
def make_target(tree):
def target(t):
node = tree
while node[0] == "branch":
_, site, i, w, op, k, yes, no = node
node = yes if t.branch(site, i, w, op, k) else no
if node[1]:
raise Found()
return target
def tree_constants(tree, out):
if tree[0] == "branch":
out.setdefault((tree[2], tree[3]), set()).add(tree[5])
tree_constants(tree[6], out)
tree_constants(tree[7], out)
return out
def reachable(tree, layout):
"""Every (site, outcome) pair and whether a crash is reachable, by running all representative inputs."""
consts = tree_constants(tree, {})
reps = representatives({f: consts.get(f, set()) for f in layout})
target = make_target(tree)
pairs, crash = set(), False
for vals in itertools.product(*(reps[f] for f in layout)):
x = bytearray(4)
for (i, w), v in zip(layout, vals):
x[i:i + w] = v.to_bytes(w, "little")
r = run(target, bytes(x))
pairs |= r.pairs()
crash = crash or r.crashed
return pairs, crash
def test_random_flip_follows_the_prefix():
rng = random.Random(32)
checked = 0
for _ in range(500):
layout = rng.choice(LAYOUTS)
target = make_target(random_tree(rng, layout, 3, [0]))
y = bytes(rng.randrange(256) for _ in range(4))
path = run(target, y).path
for j, (site, i, w, op, k, out) in enumerate(path):
conds = [(c[1], c[2], c[3], c[4], c[5]) for c in path[:j]] + [(i, w, op, k, not out)]
z = solve(conds, y)
if z is None:
continue
zp = run(target, z).path
assert [(c[0], c[5]) for c in zp[:j]] == [(c[0], c[5]) for c in path[:j]]
assert zp[j][0] == site and zp[j][5] == (not out)
checked += 1
assert checked > 300
def test_random_hybrid_covers_every_reachable_branch():
rng = random.Random(33)
for _ in range(500):
layout = rng.choice(LAYOUTS)
tree = random_tree(rng, layout, 3, [0])
pairs, crash = reachable(tree, layout)
res = hybrid_fuzz(make_target(tree), [bytes(4)], rng, 100, 10, stop_on_crash=False)
assert res.covered == pairs
assert bool(res.crashes) == crash
History
Godefroid, Klarlund and Sen (DART, PLDI 2005) and Sen, Marinov and Agha (CUTE, 2005) introduced concolic testing. Majumdar and Sen (ICSE 2007) observed that random testing reaches deep states fast but covers them narrowly, and that concolic execution covers broadly but slowly, and interleaved the two. Coverage-guided fuzzers such as AFL then became the strongest random testers. Driller (Stephens et al., NDSS 2016), built for the DARPA Cyber Grand Challenge, ran AFL and called the angr concolic engine when AFL stopped finding new paths. On the 126 binaries of the qualifying event it found the same number of vulnerabilities, in the same time, as the top-scoring team. QSYM (2018) made the concolic engine fast enough to keep up with the fuzzer.
References
- Rupak Majumdar and Koushik Sen, Hybrid concolic testing, 29th International Conference on Software Engineering (ICSE 2007), the interleaving of random testing and concolic execution and the argument for it
- Nick Stephens, John Grosen, Christopher Salls, Andrew Dutcher, Ruoyu Wang, Jacopo Corbetta, Yan Shoshitaishvili, Christopher Kruegel and Giovanni Vigna, Driller, augmenting fuzzing through selective symbolic execution, NDSS 2016, the abstract, the introduction (general and specific input, compartments), Section IV.C (when the fuzzer is stuck) and Section V (selective concolic execution with angr)
- Insu Yun, Sangho Lee, Meng Xu, Yeongjin Jang and Taesoo Kim, QSYM, a practical concolic execution engine tailored for hybrid fuzzing, USENIX Security 2018, pp. 745 to 761, the abstract (a fast concolic executor that relaxes soundness and lets the fuzzer validate its results)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 0RJWH1 Edit this page History Report an error Markdown