Automated Test Generation: A Journey from Symbolic Execution to Smart Fuzzing and Beyond
Koushik Sen
EECS Department University of California, Berkeley https://people.eecs.berkeley.edu/~ksen/
1
Automated Test Generation: A Journey from Symbolic Execution to - - PowerPoint PPT Presentation
Automated Test Generation: A Journey from Symbolic Execution to Smart Fuzzing and Beyond Koushik Sen EECS Department University of California, Berkeley https://people.eecs.berkeley.edu/~ksen/ 1 Programs are still written by humans, and will
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
18
19
void testme (int x, int y) { 1. z = 2 * y; 2. if (z == x) { 3. if (x > y+10) { 4. ERROR; 5. } 6. } 7.}
20
void testme (int x, int y) { 1. z = 2 * y; 2. if (z == x) { 3. if (x > y+10) { 4. ERROR; 5. } 6. } 7.}
Path constraint x y z true x0 y0 undef
21
void testme (int x, int y) { 1. z = 2 * y; 2. if (z == x) { 3. if (x > y+10) { 4. ERROR; 5. } 6. } 7.}
22
Path constraint x y z true x0 y0 2y0
void testme (int x, int y) { 1. z = 2 * y; 2. if (z == x) { 3. if (x > y+10) { 4. ERROR; 5. } 6. } 7.}
23
Path constraint x y z 2y0 = x0 x0 y0 2y0
void testme (int x, int y) { 1. z = 2 * y; 2. if (z == x) { 3. if (x > y+10) { 4. ERROR; 5. } 6. } 7.}
24
Path constraint x y z 2y0 = x0 /\ x0 > y0 + 10 x0 y0 2y0
void testme (int x, int y) { 1. z = 2 * y; 2. if (z == x) { 3. if (x > y+10) { 4. ERROR; 5. } 6. } 7.}
25
Path constraint x y z 2y0 = x0 /\ x0 > y0 + 10 22 11 Solve Test Inputs
– Projects at Intel, Google, MathWorks, NTT, SalesForce – PEX, SAGE, and YOGI at Microsoft – Apollo at IBM, and Conbol and Jalangi at Samsung – BitBlaze, jFuzz, Oasis, and SmartFuzz in academia
26
27
28
29
Program
30
Fuzzer Program
31
Fuzzer Program
Input Input Input Input
H@5^23#t.f
Randomly generate Input
32
./Program < /dev/random
Fuzzer Program
Input Input Input Input
Run on Inputs
33
Randomly generate Input ./Program < /dev/random
H@5^23#t.f
Program
. . . . .
Input Input Input
Seed Interesting Input(s)
34
Fuzzer Program
. . . . .
Input Input Input
Seed Interesting Input(s)
35
Fuzzer Program
. . . . .
Input Input Input
Seed Interesting Input(s)
Pick an Input
36
Fuzzer Program
Input Input Input Input
<!BTTLIST
. . . . .
Input Input Input
Seed Interesting Input(s)
Pick an Input Mutate the Input
37 <!ATTLIST
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Input(s)
Pick an Input Mutate the Input Run on Inputs
38 <!BTTLIST <!ATTLIST
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Input(s)
Pick an Input Mutate the Input Run on Inputs
39 <!BTTLIST <!ATTLIST
Mutational Fuzzers
40
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
41
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
42
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
43
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input
44
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
45
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
46
Lots of choices:
input?
generate?
input is interesting? Resolved using heuristics
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
47
Lots of choices:
input?
generate?
input is interesting? Resolved using heuristics
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
48
Lots of choices:
input?
generate?
input is interesting? Resolved using heuristics
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
49
Lots of choices:
input?
generate?
input is interesting? Resolved using heuristics
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
50
Lots of choices:
input?
generate?
input is interesting? Resolved using heuristics
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
51
Lots of choices:
input?
generate?
input is interesting? Resolved using heuristics
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
52
Fuzzers:
53
– GNU Bash through 4.3 bash43-026 does not properly parse function definitions in the values of environment ...
– A read buffer overflow allowed an attacker to extract information from servers using OpenSSL
– imagemagick: memory allocate failure in AcquireQuantumPixels (quantum.c)
– Mozilla Firefox before 32.0, Firefox ESR 31.x before 31.1, and Thunderbird 31.x before 31.1 do not properly initialize memory for GIF rendering
– Integer signedness error in the window drawing implementation in Apple Java for Mac OS X 10.5 ...
security vulnerabilities found by a state-of-the-art fuzzer AFL
54
55
int process_xml(char * fuzzed_data, int fuzzed_data_len) { if (fuzzed_data_len >= 10) { // more code } // ... if (starts_with(fuzzed_data, “<!ATTLIST”)){ // ... } // ... return process_result; } Hit by 100k+ inputs Hit by 1 input Code under is well-covered
Code under is barely covered 56
source: https://github.com/carolemieux/afl-rb
57
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
58
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
59
by few inputs (rare branches)
can be mutated and hit branch
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
60
by few inputs (rare branches)
input can be mutated and hit branch
61
62
Caroline Lemieux, Rohan Padhye, Koushik Sen, Dawn Song University of California, Berkeley
source: https://github.com/carolemieux/perffuzz
63
poor user experience excessive resource consumption security vulnerabilities (DoS)
64
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
Yes: add Input No: Discard input
65
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
branch is executed
Interesting?
Yes: add Input No: Discard input
66
times each branch is executed
execution of some branch
libxml2 libpng libjpeg- turbo zlib
67
libxml2 libpng libjpeg- turbo zlib
24.7x
68
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
at each malloc()
Interesting?
allocated at some call?
Yes: add Input No: Discard input
69
bytes allocated at each malloc() call
bytes allocated than any other input
70
1. 100 bytes Input with large dimensions
2. 100 bytes Input with large color space, but fixed dimension
1. 50 bytes zipped file: 4GB output 2. Memory leaks with LZMA compression (32 byte ZIP leaks 96 bytes)
Rohan Padhye and Caroline Lemieux and Koushik Sen and Laurent Simon and Hayawardh Vijayakumar
source: https://github.com/rohanpadhye/FuzzFactory
71
– “increase coverage amongst valid inputs”
– “increase path length”
– “maximize branch exec counts”
– “leak more info on the side channel”
– “access new input-dependent memory locations”
72
Common Strategy: Save intermediate inputs
“Waypoints”
73
Fuzzer Program
Input Input Input Input Inputs
. . . . .
Input Input Input
Seed Interesting Inputs
Pick an Input Mutate the Input Run on Inputs
Feedback
Interesting?
some k? Yes: add Input No: Discard input
74
(key-value map)
– Goal: Test programs whose inputs require magic bytes, checksums, etc. – Waypoints: inputs which increase progress of strcmp, memcmp, strstr, etc.
– Goal: Find memory allocation and management related bugs – Waypoints: input which which increase args to malloc()
– Goal: Find memory mgmt bugs in programs with magic bytes, checksums, etc. – Waypoints: CMP or MEM
75
76
77
LZ4 Bomb (4GB alloc when decoding 21-byte input) PNG Bomb (2GB alloc when reading ~100 byte 20px image)
78
79
80
A Randomized Generator A Precondition on Inputs ...
Rohan Padhye (UC Berkeley), Caroline Lemieux (UC Berkeley), Koushik Sen (UC Berkeley), Mike Papadakis (U. Luxembourg), Yves Le Traon (U. Luxembourg)
source: https://github.com/rohanpadhye/jqf
81
82
public XMLElement genXML(Random random) { // Generate a random tag name String name = random.nextString(MAX_TAG_LENGTH); XMLElement node = new XMLElement(name); // Generate a random number of children int n = random.nextInt(MAX_CHILDREN); for (int i = 0; i < n; i++) { // Generate child nodes recursively node.addChild(genXML(random)); } // Maybe insert text inside element if (random.nextBoolean()) { node.addText(random.nextString(MAX_TEXT_LENGTH)); } return node; }
✗ May not conform to
83
Example generated: <foo><i>xyz</i><br/></foo>
foo i br xyz
Fuzzer Program
Input Input Input Input params
. . . . .
params params params
Seed Interesting Inputs
Pick a set
Mutate the params
Feedback
Interesting?
Yes: add Input No: Discard input
84
Generator Augmented Program
Google Closure Compiler: #2842, #2843, #3220, #3173 OpenJDK: JDK-8190332, JDK-8190511, JDK-8190512, JDK-8190997, JDK- 8191023, JDK-8191076, JDK-8191109, JDK-8191174,JDK-8191073, JDK- 8193444, JDK-8193877, CVE-2018-3214 Apache Commons: LANG-1385, COMPRESS-424, COLLECTIONS-714, CVE-2018- 11771 Apache Ant: #62655 Apache Maven: #34, #57 Apache PDFBox: PDFBOX-4333, PDFBOX-4338, PDFBOX-4339, CVE-2018-8036 Apache TIKA: CVE-2018-8017, CVE-2018-12418 Apache BCEL: BCEL-303, BCEL-307, BCEL-308, BCEL-309, BCEL-310, BCEL- 311, BCEL-312, BCEL-313 Mozilla Rhino: #405, #406, #407, #409, #410
85
On this JavaScript input, Google’s Closure compiler throws an “IllegalStateException: Unexpected variable” during optimization passes
86
87
A Randomized Generator A Precondition on Inputs ...
Rafael Dutra, Kevin Laeufer, Jonathan Bachrach, and Koushik Sen EECS Department UC Berkeley
source: https://github.com/RafaelTupynamba/quicksampler
88
89
(x + y = 4 ∧ x ≥ 0 ∧ x < 4) ∧ (mem’[1] < 0 ∨ mem’[1] ≥ 4), where x = mem[0], y = mem[1], mem’ = store(mem, mem[0], -1 * mem[mem[0]]) mem ∈ Array(BV[4], BV[4]) In SMT (Satisfiability Modulo Theories)
Goal: Quickly generate lots of solutions that satisfy the constraint Input: Logical constraint (SAT formula)
(x1 x4) (x1 ¬x3 ¬x8) (x1 x8 x6) (x2 x5) (¬x7 ¬x3 x9) (¬x7 x8 ¬x9) (x7 x8 ¬x10) (x7 x10 ¬x6)
1 0 0 0 1 0 0 0
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10
1 0 σ0 0 0 0 1 1 0 0 1 1 0 σ1 1 1 0 0 1 0 0 0 1 0 σ2 0 1 0 1 1 0 0 1 1 0 σ3 1 0 1 0 1 0 0 0 1 0 σ4 1 1 1 0 1 0 0 0 1 0 σ5
91
92
Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
93
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
94
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
Formula φ(x0,x1,x2,x3,y0,y1,y2,y3) 0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
MAX-SAT
95
Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
σ0
96
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
σ0
97
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
σ0
98
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1
σ0
99
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1
σ0
100
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1
σ0
101
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT
σ0
102
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT
σ0
103
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
σ0
104
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
......
σ0
105
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0
σ0
106
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 = δ0 ∨ δ1
σ0
107
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01
σ0
108
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 = δ0 ∨ δ3
σ0
109
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03
σ0
110
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03 δ13 0 1 0 1 0 1 0 0 = δ1 ∨ δ3
σ0
111
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03 δ13 0 1 0 1 0 1 0 0 = δ1 ∨ δ3
σ0
112
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03 δ013 1 1 0 1 1 1 0 0 = δ0 ∨ δ1 ∨ δ3
σ0
113
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03 δ013 1 1 0 1 1 1 0 0 = δ0 ∨ δ1 ∨ δ3
σ0
114
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03
σ0
115
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03
115
At most n MAX-SAT calls to generate atomic mutations samples by combining mutations: NO MAX-SAT =O(n6)
n 6
σ0
116
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03
116
At most 50 MAX-SAT calls to generate atomic mutations 15 890 700 samples by combining mutations: NO MAX-SAT
σ0
117
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03
σ0
118
1 0 1 0 0 1 1 0 Formula φ(x0,x1,x2,x3,y0,y1,y2,y3)
MAX-SAT
Solution σ
0 0 1 0 1 1 1 0
MAX-SAT
0 0 1 0 1 1 0 0
Random assignment σ’ x0 x1 x2 x3 y0 y1 y2 y3
0 1 1 1 1 0 1 0
σ1 UNSAT0 0 1 1 1 1 1 0 σ3
...... 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0
δ3
1 0 0 0 1 0 0 0
δ1 δ0 = σ ⊕ σ1 = σ ⊕ σ3 = σ ⊕ σ0 δ01 1 1 0 1 1 1 0 0 σ01 1 1 1 1 0 0 1 0 = σ ⊕ δ01 δ03 1 0 0 1 1 0 0 0 σ03 1 0 1 1 0 1 1 0 = σ ⊕ δ03
120
(x + y = 4 ∧ x ≥ 0 ∧ x < 4) ∧ (mem’[1] < 0 ∨ mem’[1] ≥ 4), where x = mem[0], y = mem[1], mem’ = store(mem, mem[0], -1 * mem[mem[0]]) mem ∈ Array(BV[4], BV[4]) SMT (Satisfiability Modulo Theories)
121
– Uses universal hashing to partition the solution space and produce provably uniform samples
– Generates pseudo-solutions: partial assignments that can be completed to full solutions
[1] Supratik Chakraborty, Daniel J Fremont, Kuldeep S Meel, Sanjit A Seshia, and Moshe Y Vardi. 2015. On Parallel Scalable Uniform SAT Witness Generation. In TACAS 2015. [2] Stefano Ermon, Carla P Gomes, and Bart Selman. 2012. Uniform solution sampling using a constraint solver as an oracle. In UAI 2012.
122
124
125
Higher is better
126
127
128
129
130
131
132
Symbolic Execution Smart Fuzzing
133
Symbolic Execution Smart Fuzzing Hybrid
134
Symbolic Execution Smart Fuzzing Hybrid Human Guidance
Generators Preconditions Path Annotations ...
135
Symbolic Execution Smart Fuzzing Hybrid
Generators Preconditions Path Annotations ...
136
Rohan Bavishi Rafael Dutra Kevin Laeufer Caroline Lemieux Rohan Padhye Koushik Sen Ed Younis Abdus Salam Azad