Coverage-guided Fuzzing
- f Individual Functions
Without Source Code
Alessandro Di Federico
Politecnico di Milano
October 25, 2018
1
Coverage-guided Fuzzing of Individual Functions Without Source Code - - PowerPoint PPT Presentation
Coverage-guided Fuzzing of Individual Functions Without Source Code Alessandro Di Federico Politecnico di Milano October 25, 2018 1 Index Coverage-guided fuzzing An overview of rev.ng Experimental results 2 Fuzzing 3 Fuzzing 1 Generate
Alessandro Di Federico
Politecnico di Milano
October 25, 2018
1
Coverage-guided fuzzing An overview of rev.ng Experimental results
2
3
1 Generate a lot of different inputs 2 Feed them to a program 3 Wait for it to reach an invalid state 4 Collect a report for the analyst 4
Pros:
Cons:
5
6
Privilege inputs leading to cover new code paths
7
int main() { if (A && B) { crash (); } else { all_good (); } }
8
A B
9
Input: 0000 0000 0000 0000
A B
10
Input: 0000 0000 0000 0000
A B
11
Input: 0000 0000 0000 0000
A B
12
Input: 0000 0000 0000 0000
A B
13
Input: 0000 0000 0000 0001
A B
14
Input: 0000 0000 0000 0001
A B
15
Input: 0000 0000 0000 0001
A B
16
Input: 0000 0000 0000 0001
A B
17
18
Input: 0001 0000 0000 0000
A B
19
Input: 0001 0000 0000 0000
A B
20
Input: 0001 0000 0000 0000
A B
21
Input: 0001 0000 0000 0000
A B
22
Input: 0001 0000 0000 0000
A B
23
24
Input: 0011 0000 0000 0000
A B
25
Input: 0011 0000 0000 0000
A B
26
Input: 0011 0000 0000 0000
A B
27
Input: 0011 0000 0000 0000
A B
28
Input: 0011 0000 0000 0000
A B
29
30
Instrumentation is performed at compiler-level
31
Instrumentation is performed at compiler-level
int main() { record (1); if (A && B) { record (2); crash (); } else { record (3); all_good (); } record (4); }
32
An emulator is employed to detect executed basic blocks
33
An emulator is employed to detect executed basic blocks
34
35
Famous for its C/C++ frontend (clang) and its intermediate representation (the LLVM IR)
36
It doesn’t fork
int main() { while (true) { char *new_input = random_input (); target(new_input ); } }
37
Coverage-guided fuzzing An overview of rev.ng Experimental results
38
39
Everything you’ll see here is architecture-agnostic
40
41
AArch64 AArch64 ARM Alpha CRIS Unicore SPARC SPARC64 SuperH SystemZ PowerPC PowerPC64 XCore MIPS MIPS64 OpenRISC MicroBlaze x86-64 x86 RISC V QEMU IR QEMU IR AArch64 ARM x86 x86-64 MIPS PowerPC SystemZ SPARC TCI
42
AArch64 AArch64 ARM Alpha CRIS Unicore SPARC SPARC64 SuperH SystemZ PowerPC PowerPC64 XCore MIPS MIPS64 OpenRISC MicroBlaze x86-64 x86 RISC V QEMU IR QEMU IR AArch64 ARM x86 x86-64 MIPS PowerPC SystemZ SPARC TCI
43
44
45
md5sum.arm Collect entry points Lift to QEMU IR Translate to LLVM IR Collect new entry points Link runtime functions md5sum.x86-64
46
QEMU IR Alpha ARM AArch64 RISC V Hexagon x86 x86-64 MicroBlaze OpenRISC MIPS64 MIPS XCore PowerPC64 PowerPC SystemZ SuperH SPARC SPARC64 Unicore CRIS
47
LLVM IR Alpha ARM AArch64 RISC V Hexagon x86 x86-64 MicroBlaze OpenRISC MIPS64 MIPS XCore PowerPC64 PowerPC SystemZ SuperH SPARC SPARC64 Unicore CRIS
48
rev.ng Alpha ARM AArch64 RISC V Hexagon x86 x86-64 MicroBlaze OpenRISC MIPS64 MIPS XCore PowerPC64 PowerPC SystemZ SuperH SPARC SPARC64 Unicore CRIS
49
rev.ng Alpha ARM AArch64 RISC V Hexagon x86 x86-64 MicroBlaze OpenRISC MIPS64 MIPS XCore PowerPC64 PowerPC SystemZ SuperH SPARC SPARC64 Unicore CRIS
50
51
52
1 Lift the program to LLVM IR 2 Identify all the functions 3 Identify a function to fuzz 4 Create the fuzzing function 5 Compile fuzzing function 6 Instrument using libfuzzer 7 Launch the fuzzer 53
1 Lift the program to LLVM IR 2 Identify all the functions 3 Identify a function to fuzz MANUAL 4 Create the fuzzing function MANUAL 5 Compile fuzzing function 6 Instrument using libfuzzer 7 Launch the fuzzer 54
Coverage-guided fuzzing An overview of rev.ng Experimental results
55
56
1 The LLVM optimizer has a wider view on the code 2 The translation is performed offline 57
458.sjeng 464.h264ref 400.perlbench 471.omnetpp 462.libquantum 473.astar
1000 2000 3000 4000
Native QEMU rev.ng 401.bzip2 483.xalancbmk 429.mcf 403.gcc 445.gobmk 456.hmmer
500 1000 1500 2000 58
59
60
Not directly, but embedded in another program (less)
61
1 Lift the program to LLVM IR 2 Identify all the functions 3 Identify a function to fuzz 4 Create the fuzzing function 5 Compile fuzzing function 6 Instrument using libfuzzer 7 Launch the fuzzer 62
1 Lift the program to LLVM IR 2 Identify all the functions 3 Identify a function to fuzz 4 Create the fuzzing function 5 Compile fuzzing function 6 Instrument using libfuzzer 7 Launch the fuzzer 63
int LLVMFuzzerTestOneInput(uint8_t *data , size_t size) { char input_string [] = "Test␣string!"; void *compiled_re; compiled_re = pcre_compile(data); pcre_exec(compiled_re , input_string , strlen(input_string )); pcre_free(compiled_re ); return 0; }
64
We were able to find a known vulnerability in PCRE
65
66
Execs per second Total execs 1 min 10 min 60 min 60 min afl 3 582 3 495 3 682 13 187 295 rev.ng 150 617 79 701 78 306 271 217 728
67
68
69
70
71
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/
900, Mountain View, California, 94041, USA.
72