Top Banner
Introduction to Fuzzing Alma Oracevic alma [email protected]
160

Introduction to Fuzzing

Mar 12, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Fuzzing

Introduction to Fuzzing

Alma Oracevic

[email protected]

Page 2: Introduction to Fuzzing

About the technique

2

▪It is about Fuzzing

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 3: Introduction to Fuzzing

About the technique

▪It is about Fuzzing

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

3

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 4: Introduction to Fuzzing

About the technique

▪It is about Fuzzing

▪No, it is not about Fuzzy logic

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

4

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 5: Introduction to Fuzzing

About the technique

▪It is about Fuzzing

▪No, it is not about Fuzzy logic

▪Neither about fuzzy set membership

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

5

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 6: Introduction to Fuzzing

About the technique

▪It is about Fuzzing

▪No, it is not about Fuzzy logic

▪Neither about fuzzy set membership

Software Testing

6

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 7: Introduction to Fuzzing

About the technique

▪It is about Fuzzing

▪No, it is not about Fuzzy logic

▪Neither about fuzzy set membership

Security Software Testing

7

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 8: Introduction to Fuzzing

About the technique

▪It is about Fuzzing

▪No, it is not about Fuzzy logic

▪Neither about fuzzy set membership

Security Software Testing

Memory- corruption bugs

8

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 9: Introduction to Fuzzing

About the technique

▪It is about Fuzzing

▪No, it is not about Fuzzy logic

▪Neither about fuzzy set membership

Security Software Testing

Memory- corruption bugs

Exploitable!

9

References:

1. book (Chapter

1, section 1.3):

Fuzzing for

Software Security

Testing and

Quality Assurance.

By Ari Takanen,

Jared DeMott,

Charlie Miller

2. Article "Fuzzing:

Hack, Art, and

Science”

By P. Godefroid

Page 10: Introduction to Fuzzing

Why do we care?

10

Page 11: Introduction to Fuzzing

Why do we care?

**http://www.cvedetails.com

11

Page 12: Introduction to Fuzzing

Organization

14

▪Memory corruption vulnerabilities

▪Fuzzing- finding vulnerabilities

▪Types of Fuzzing

▪Some existing solutions

Page 13: Introduction to Fuzzing

Memory Corruption Vulnerabilities

15

▪WYSINWYX: What You See Is Not What You eXecute by G. Balakrishnan et. al.

– Higher level code -> low-level representation

– Seemingly separate variables -> contiguous memory addresses

▪Contiguous memory locations allow for boundary violations!

Page 14: Introduction to Fuzzing

example

17

#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

Page 15: Introduction to Fuzzing

example#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

name

18

Page 16: Introduction to Fuzzing

example#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

name

cookie

19

Page 17: Introduction to Fuzzing

example#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

name

cookie

Saved RET

20

Page 18: Introduction to Fuzzing

example#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

name

cookie

Saved RET

21

Page 19: Introduction to Fuzzing

name

cookie

Saved RET

example#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

22

Page 20: Introduction to Fuzzing

example#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

name

cookie

Saved RET

23

Page 21: Introduction to Fuzzing

example#include <stdio.h>

int get_cookie(){

return rand();}

int main(){

int cookie;

char name[40];

cookie = get_cookie();

gets(name);

if (cookie == 0x41424344)

printf("You win %s\n!", name);

else printf("better luck next time :(");

return 0;

}

name

cookie

Saved RET

Memory

corruption

24

Page 22: Introduction to Fuzzing

Side effects

25

Page 23: Introduction to Fuzzing

Side effects

26

▪Over/underflow

Page 24: Introduction to Fuzzing

Side effects

27

▪Over/underflow

▪Sensitive data corruption

Page 25: Introduction to Fuzzing

Side effects

28

▪Over/underflow

▪Sensitive data corruption

▪Control data corruption (control hijacking)

Page 26: Introduction to Fuzzing

Side effects

29

▪Over/underflow

▪Sensitive data corruption

▪Control data corruption (control hijacking)

Page 27: Introduction to Fuzzing

Side effects

30

▪Over/underflow

▪Sensitive data corruption

▪Control data corruption (control hijacking)

Otherwise crash!

Page 28: Introduction to Fuzzing

Fuzzing

37

Page 29: Introduction to Fuzzing

Fuzzing

▪It started on a dark and stormy night…. [Barton P. Miller, late1980s]

38

Page 30: Introduction to Fuzzing

Fuzzing

39

Page 31: Introduction to Fuzzing

Fuzzing

40

●Run program on many abnormal/malformed inputs, look for unintended

behavior, e.g. crash.

Page 32: Introduction to Fuzzing

Fuzzing

●Run program on many abnormal/malformed inputs, look for unintended

behavior, e.g. crash.

● An observable (measurable) side effect is essential

41

Page 33: Introduction to Fuzzing

Fuzzing

●Run program on many abnormal/malformed inputs, look for unintended

behavior, e.g. crash.

● An observable (measurable) side effect is essential

● Should be scalable

42

Page 34: Introduction to Fuzzing

Fuzzing

●Run program on many abnormal/malformed inputs, look for unintended

behavior, e.g. crash.

● An observable (measurable) side effect is essential

● Should be scalable

●Underlying assumption: if the unintended behavior is dependent on input, an attacker can craft such an input to exploit the bug.

43

Page 35: Introduction to Fuzzing

Types of Fuzzing

44

▪Input based: mutational and Generative (grammar based)

▪Application based: black-box and white-box

▪Input Strategy: memory-less and evolutionary

Page 36: Introduction to Fuzzing

Input Generation

45

Page 37: Introduction to Fuzzing

Input Generation

46

▪Mutation Based: mutate seed inputs to create new test inputs

- Simple strategy is to randomly choose an offset and change

the byte.

Page 38: Introduction to Fuzzing

Input Generation

47

▪Mutation Based: mutate seed inputs to create new test inputs

-

-

-

Simple strategy is to randomly choose an offset and change

the byte.

Pros: easy to implement and low overhead

Cons: highly structured inputs will become invalid quickly →

low coverage.

Page 39: Introduction to Fuzzing

Cont..● Generation (Grammar) Based: Learn/create the format/model of

the input and based on the learned model, generate new inputs.

-

-

-

e.g. well-known file formats (jpeg, xml, etc.)

Pros: Highly effective for complex structured input parsing

applications → high coverage

Cons: expensive as models are not easy to learn or obtain.

Page 40: Introduction to Fuzzing

JPEG file

format

Page 41: Introduction to Fuzzing

JPEG file

format

Page 42: Introduction to Fuzzing

Application Monitoring

51

Page 43: Introduction to Fuzzing

Application Monitoring

▪Blackbox: Only interface is known.

52

Page 44: Introduction to Fuzzing

Application Monitoring

▪Blackbox: Only interface is known.

53

Page 45: Introduction to Fuzzing

Application Monitoring

▪Blackbox: Only interface is known.

● Whitebox: Application can

be analysed/monitored.

Static & Dynamic analysis

54

Page 46: Introduction to Fuzzing

Problem with Traditional Fuzzing

55

Page 47: Introduction to Fuzzing

Problem with Traditional Fuzzing

Blackbox + mutation: Aiming with luck!

56

Page 48: Introduction to Fuzzing

Problem with Traditional Fuzzing

Blackbox + mutation: Aiming with luck!

57

Page 49: Introduction to Fuzzing

Problem with Traditional Fuzzing

Blackbox + mutation: Aiming with luck!

58

... //JPEG parsing

read(fd, buf, size);

if (buf[1] == 0xD8 && buf[0] == 0xFF)

// interesting code here

else

pr_exit(“Invalid file”);

Page 50: Introduction to Fuzzing

Problem with Traditional Fuzzing

Blackbox + mutation: Aiming with luck!

... //JPEG parsing

read(fd, buf, size);

if (buf[1] == 0xD8 && buf[0] == 0xFF)

// interesting code here

else

pr_exit(“Invalid file”);

59

Page 51: Introduction to Fuzzing

Problem with Traditional Fuzzing

60

Page 52: Introduction to Fuzzing

Problem with Traditional Fuzzing

61

▪Apply more heuristics to:– Mutate better

– Learn good inputs

Page 53: Introduction to Fuzzing

Problem with Traditional Fuzzing

▪Apply more heuristics to:– Mutate better

– Learn good inputs

▪Apply more analysis (static/dynamic) to understand the application behavior.

➢But remember the scalability factor!

62

Page 54: Introduction to Fuzzing

Problem with Traditional Smart Fuzzing

63

Page 55: Introduction to Fuzzing

Problem with Traditional Smart Fuzzing

smart fuzzing: Aiming with educated guess!

64

Page 56: Introduction to Fuzzing

Problem with Traditional Smart Fuzzing

smart fuzzing: Aiming with educated guess!

65

Page 57: Introduction to Fuzzing

Evolutionary Fuzzing

66

Page 58: Introduction to Fuzzing

Evolutionary Fuzzing

67

▪Recall: memory-less and Evolutionary fuzzing

Page 59: Introduction to Fuzzing

Evolutionary Fuzzing

68

▪Recall: memory-less and Evolutionary fuzzing

▪Rather than throwing inputs, evolve them.

Page 60: Introduction to Fuzzing

Evolutionary Fuzzing

69

▪Recall: memory-less and Evolutionary fuzzing

▪Rather than throwing inputs, evolve them.

▪Underlying assumption:– Inputs are parsed enough before going further deep in execution

Page 61: Introduction to Fuzzing

Evolutionary Fuzzing

70

▪Recall: memory-less and Evolutionary fuzzing

▪Rather than throwing inputs, evolve them.

▪Underlying assumption:– Inputs are parsed enough before going further deep in execution

Page 62: Introduction to Fuzzing

Evolutionary Fuzzing

71

▪What should be the feedback to evolve?– Code-coverage based fuzzing

➢Most of the contemporary fuzzers are here (AFL, AFLFast, Driller, VUzzer, ProbeFuzzer, CollAFL, Angora, QSYM, Nautilus, …

➢Uses code-coverage as the proxy metric for the effectiveness of a fuzzer

– Directed fuzzing➢Not much explored (BuzzFuzz, AGLGo, … )

➢There should be a way to find the destination and a sense of direction.

Page 63: Introduction to Fuzzing

Evolving A Fuzzer

72

Page 64: Introduction to Fuzzing

Evolving A Fuzzer

73

▪Lets start with something we are more familiar with- AFL

Page 65: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

74

Q

Page 66: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

75

Page 67: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

76

Execute and

monitor

edges (BB)

Page 68: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

Execute and

monitor

edges (BB)

New

edge

?

77

Page 69: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

Execute and

monitor

edges (BB)

New

edge

?

Yes, add input to Q

78

Page 70: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

Execute and

monitor

edges (BB)

New

edge

?

Yes, add input to Q

No, (perhaps) try more mutation

79

Page 71: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

Execute and

monitor

edges (BB)

New

edge

?

Yes, add input to Q

No, (perhaps) try more mutation

80

Codecoverage-

Maximize it!

Page 72: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

Execute and

monitor

edges (BB)

New

edge

?

Yes, add input to Q

No, (perhaps) try more mutation

Codecoverage-

Maximize it!

You do

something to

maximize

CC

81

Page 73: Introduction to Fuzzing

Evolving A Fuzzer

▪Lets start with something we are more familiar with- AFL

inputs

Q

Mutate at

offset X

Bitflip,

replace,

arithmetic

Execute and

monitor

edges (BB)

New

edge

?

Yes, add input to Q

No, (perhaps) try more mutation

Codecoverage-

Maximize it!

You do

something to

maximize

CC

Analysis-

You need

something to

mutate in a

meaningful way

82

Page 74: Introduction to Fuzzing

Fuzzing- A balancing Act

Fuzzer

performance

scalability

Blind-

mutation

83

Page 75: Introduction to Fuzzing

Fuzzing- A balancing Act

Fuzzer

performance

scalability

Monitoring

Blind-

mutation

84

Page 76: Introduction to Fuzzing

Fuzzing- A balancing Act

Fuzzer

performance

scalability

Monitoring

Blind-

mutation

Analysis A

85

Page 77: Introduction to Fuzzing

Fuzzing- A balancing Act

Fuzzer

performance

scalability

Monitoring

Blind-

mutation

Analysis A

Analysis B

86

Page 78: Introduction to Fuzzing

Fuzzing- A balancing Act

Fuzzer

Analysis C

87

Page 79: Introduction to Fuzzing

Fuzzing- A balancing Act

Happy Advanced Fuzzer

performance

scalability

Monitoring

Blind-

mutation

Analysis A

Analysis C

Analysis B

88

Page 80: Introduction to Fuzzing

Problem Exemplified….

89

Page 81: Introduction to Fuzzing

Problem Exemplified….

90

Page 82: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

91

Page 83: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

92

Page 84: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

93

Page 85: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

94

Page 86: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

95

Page 87: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

96

Page 88: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

97

Page 89: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

98

Page 90: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

99

Page 91: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

100

Page 92: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

101

Page 93: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

102

Page 94: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

Easy paths (superficial

paths), error code

103

Page 95: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

Easy paths (superficial

paths), error code

104

Page 96: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

Easy paths (superficial

paths), error code

105

Page 97: Introduction to Fuzzing

Problem Exemplified….

a==\xffd8

Where is ‘a’?

What values?

Hard-to-reach-paths

(deeper buried bugs)

Easy paths (superficial

paths), error code

106

Page 98: Introduction to Fuzzing

Issues identified…

107

▪For smart code-coverage based fuzzer, it is important to have some knowledge about:

Page 99: Introduction to Fuzzing

Issues identified…

108

▪For smart code-coverage based fuzzer, it is important to have some knowledge about:

– Where (which offsets in input) to apply mutation

Page 100: Introduction to Fuzzing

Issues identified…

109

▪For smart code-coverage based fuzzer, it is important to have some knowledge about:

– Where (which offsets in input) to apply mutation

– What values to replace with.

Page 101: Introduction to Fuzzing

Issues identified…

110

▪For smart code-coverage based fuzzer, it is important to have some knowledge about:

– Where (which offsets in input) to apply mutation

– What values to replace with.

– How to avoid traps (paths leading to error handling code)

Page 102: Introduction to Fuzzing

Fuzzing+Symbex

111

Page 103: Introduction to Fuzzing

Fuzzing+Symbex

112

▪Symbolic/concolic execution can answer such questions.

– Driller: Augmenting Fuzzing Through Selective Symbolic Execution, NDSS’16

Page 104: Introduction to Fuzzing

Fuzzing+Symbex

113

▪Symbolic/concolic execution can answer such questions.– Driller: Augmenting Fuzzing Through Selective Symbolic

Execution, NDSS’16

▪But... Scalability?

Page 105: Introduction to Fuzzing

Fuzzing+Symbex

▪Symbolic/concolic execution can answer such questions.– Driller: Augmenting Fuzzing Through Selective Symbolic

Execution, NDSS’16

▪But... Scalability?

114

Page 106: Introduction to Fuzzing

Observations on Fuzzing+Symbex

115

▪Lava: Large-scale automated vulnerability addition,” in Proc. IEEE S&P ’16. IEEE Press, 2016.

Page 107: Introduction to Fuzzing

Observations on Fuzzing+Symbex

116

▪Lava: Large-scale automated vulnerability addition,” in Proc. IEEE S&P ’16. IEEE Press, 2016.

– quickly and automatically injecting large numbers of realistic bugs into program source code.

Page 108: Introduction to Fuzzing

Observations on Fuzzing+Symbex

117

▪Lava: Large-scale automated vulnerability addition,” in Proc. IEEE S&P ’16. IEEE Press, 2016.

– quickly and automatically injecting large numbers of realistic bugs into program source code.

– injected bug is designed to be triggered only if a particular set of multi-bytes in the input is set to a magic value

Page 109: Introduction to Fuzzing

Observations on Fuzzing+Symbex

118

▪Lava: Large-scale automated vulnerability addition,” in Proc. IEEE S&P ’16. IEEE Press, 2016.

– quickly and automatically injecting large numbers of realistic bugs into program source code.

– injected bug is designed to be triggered only if a particular set of multi-bytes in the input is set to a magic value

– Results are not very encouraging!

Page 110: Introduction to Fuzzing

Concrete results (From LAVA paper)

119

Page 111: Introduction to Fuzzing

QSYM- Enhancing Fuzzing by Enhancing Symbex

120

Page 112: Introduction to Fuzzing

QSYM- Enhancing Fuzzing by Enhancing Symbex

121

Page 113: Introduction to Fuzzing

QSYM- Enhancing Fuzzing by Enhancing Symbex

▪Presented in Usenix Sec’18

122

Page 114: Introduction to Fuzzing

QSYM- Enhancing Fuzzing by Enhancing Symbex

▪Presented in Usenix Sec’18

▪Focuses on scaling symbex– Native execution, contrary to IR based execution in existing symbex tools

– Instruction-level symbolic execution➢Only the relevant instructions are executed symbolically (taintflow analysis)

➢Solving only relevant constraints related to the target branch

– Optimistic Solving

– …

123

Page 115: Introduction to Fuzzing

QSYM- Enhancing Fuzzing by Enhancing Symbex

▪Presented in Usenix Sec’18

▪Focuses on scaling symbex

– Native execution, contrary to IR based execution in existing symbex tools

– Instruction-level symbolic execution➢Only the relevant instructions are executed symbolically (taintflow analysis)

➢Solving only relevant constraints related to the target branch

– Optimistic Solving

– …

▪Maintaining scalability with good heuristics + program analysis toimprove coverage

124

Page 116: Introduction to Fuzzing

VUzzer- going further with more analysis

125

Page 117: Introduction to Fuzzing

VUzzer- going further with more analysis

126

▪Presented at NDSS’17

▪Uses taintflow analysis + several heuristics

▪Main idea:

Page 118: Introduction to Fuzzing

VUzzer- going further with more analysis

▪Presented at NDSS’17

▪Uses taintflow analysis + several heuristics

▪Main idea:– Leverage application’s control- and data-flow features to infer input properties:

applications is designed to work with that input!➢ Dynamic taintfow analysis

– Prioritize and deprioritize paths: Certain paths are difficult to execute as they are guarded by constraints (nested conditions)!➢ Static analysis and error handling code

▪Combines static and dynamic analysis + heuristics to improve coverage

127

Page 119: Introduction to Fuzzing

Evolving Taintflow based Solution

128

Page 120: Introduction to Fuzzing

Evolving Taintflow based Solution

inputs

Q

▪Moving to Vuzzer…Bitflip,

replacement,ar

ithmeti

c

Mutate at

offset X

Execute and

monitor

edges (BB)

New

edg

e?

Yes, add input to Q

No, (perhaps) try more mutation

129

Page 121: Introduction to Fuzzing

Evolving Taintflow based Solution

inputs

Q

▪Moving to Vuzzer…Bitflip,

replacement,ar

ithmeti

c

Mutate at

offset X

Execute and

monitor

edges (BB)

New

edg

e?

Yes, add input to Q

No, (perhaps) try more mutation

130

Also perform taintflow to

determine interesting offsets/

values (O/V)

Page 122: Introduction to Fuzzing

Evolving Taintflow based Solution

▪Moving to Vuzzer…

inputs

Q

Bitflip,

replace

ment,ar

ithmeti

c

Mutate at

offset X

Execute and

monitor

edges (BB)

New

edg

e?

Yes, add input to Q

No, (perha ps) try more mutati on

Also perform taintflow to

determine interesting offsets/

values (O/V)

Is it error

handing BB? If

so, not

interesting.

131

Page 123: Introduction to Fuzzing

Evolving Taintflow based Solution

inputs

Q

▪Moving to Vuzzer…Bitflip,

replacement,ar

ithmeti

c

Mutate at

offset X

Execute and

monitor

edges (BB)

New

edg

e?

Yes, add input to Q

No, (perha ps) try more mutati on

Also perform taintflow to

determine interesting offsets/

values (O/V)

Is it error

handing BB? If

so, not

interesting.

132

Mutate only

interesting offsets

and with interesting

values (magic-bytes)

Page 124: Introduction to Fuzzing

Evolving Taintflow based Solution

inputs

Q

▪Moving to Vuzzer…Bitflip,

replacement,ar

ithmeti

c

Mutate at

offset X

Execute and

monitor

edges (BB)

New

edg

e?

Yes, add input to Q

No, (perha ps) try more mutati on

Also perform taintflow to

determine interesting offsets/

values (O/V)

Is it error

handing BB? If

so, not

interesting.

Mutate only

interesting offsets

and with interesting

values (magic-bytes)

Input preference

with path

prioritization- static

analysis

133

Page 125: Introduction to Fuzzing

There are problems… still!

134

Page 126: Introduction to Fuzzing

There are problems… still!

135

▪Unaware of whether offset is processed by application– Waste of mutation time

Page 127: Introduction to Fuzzing

There are problems… still!

136

▪Unaware of whether offset is processed by application– Waste of mutation time

▪What and Where to mutate– Different bugs have different triggering conditions

➢Buffer overflow involves buffer (strings, arrays etc.)

➢ Integer overflow involves integer data type.

Page 128: Introduction to Fuzzing

There are problems… still!

137

▪Unaware of whether offset is processed by application– Waste of mutation time

▪What and Where to mutate– Different bugs have different triggering conditions

➢Buffer overflow involves buffer (strings, arrays etc.)

➢ Integer overflow involves integer data type.

Traditional Byte by byte mutation may not be a very

effective strategy!

Page 129: Introduction to Fuzzing

There are problems… still!

138

▪Unaware of whether offset is processed by application– Waste of mutation time

▪What and Where to mutate– Different bugs have different triggering conditions

➢Buffer overflow involves buffer (strings, arrays etc.)

➢ Integer overflow involves integer data type.

Traditional Byte by byte mutation may not be a very

effective strategy!

TIFF (presented at ACSAC 2018)

Page 130: Introduction to Fuzzing

Type inference: Main Insight

139

Page 131: Introduction to Fuzzing

Type inference: Main Insight

Input

140

Page 132: Introduction to Fuzzing

Type inference: Main Insight

Input

141

Application

execution

Page 133: Introduction to Fuzzing

Type inference: Main Insight

Input

142

Application

execution

memory

Page 134: Introduction to Fuzzing

Type inference: Main Insight

Input

143

Application

execution

DSI

memory

Page 135: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

DSI

memory

INT8

144

Page 136: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

DSI

memory

INT8

String buffer

145

Page 137: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

DSI

memory

INT8

String buffer

INT32

146

Page 138: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

memory

INT8

String buffer

INT32

DSIDTA

147

Page 139: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

memory

INT8

String buffer

INT32

DSIDTA

148

Page 140: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

memory

INT8

String buffer

INT32

DSIDTA

149

Page 141: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

memory

INT8

String buffer

INT32

DSIDTA

150

Page 142: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

memory

INT8

String buffer

INT32

DSIDTA

151

Page 143: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

memory

INT8

String buffer

INT32

DSIDTA

152

Page 144: Introduction to Fuzzing

Type inference: Main Insight

InputApplication

execution

memory

INT8

String buffer

INT32

INT8

String buffer

INT32

Tagged input

Type inferenceDSI

DTA

153

Page 145: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

154

Page 146: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

155

Page 147: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

▪TIFF brought forward the idea of bringing grammar and mutation based fuzzing closer!

156

Page 148: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

▪TIFF brought forward the idea of bringing grammar and mutation based fuzzing closer!

▪Angora (S&P’18)- on source code (LLVM based)

157

Page 149: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

▪TIFF brought forward the idea of bringing grammar and mutation based fuzzing closer!

▪Angora (S&P’18)- on source code (LLVM based)

▪ProFuzzer ( S&P’19)- learning input structure with execution patterns

158

Page 150: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

▪TIFF brought forward the idea of bringing grammar and mutation based fuzzing closer!

▪Angora (S&P’18)- on source code (LLVM based)

▪ProFuzzer ( S&P’19)- learning input structure with execution patterns

▪GRIMOIRE: Synthesizing Structure while Fuzzing (Usenix Sec’19)-grammar inference.

159

Page 151: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

▪TIFF brought forward the idea of bringing grammar and mutation based fuzzing closer!

▪Angora (S&P’18)- on source code (LLVM based)

▪ProFuzzer ( S&P’19)- learning input structure with execution patterns

▪GRIMOIRE: Synthesizing Structure while Fuzzing (Usenix Sec’19)-grammar inference.

▪ and many more.. See: https://github.com/fengjixuchui/FuzzingPaper

160

Page 152: Introduction to Fuzzing

Input format learning (Grammar based fuzzing)

▪TIFF brought forward the idea of bringing grammar and mutation based fuzzing closer!

▪Angora (S&P’18)- on source code (LLVM based)

▪ProFuzzer ( S&P’19)- learning input structure with execution patterns

▪GRIMOIRE: Synthesizing Structure while Fuzzing (Usenix Sec’19)-grammar inference.

▪ and many more.. See: https://github.com/fengjixuchui/FuzzingPaper

▪Focus shifted to How to mutate sensibly?

161

Page 153: Introduction to Fuzzing

Evaluating Fuzzers- A tough question!

162

▪What experimental setup is needed to produce trustworthy results? [Evaluating Fuzz Testing, Klees et. al. CCS’18]

▪There is a randomness in mutation operation- thus results may differ run to run. Multiple runs.

▪Dataset- quite arbitrary (LAVA-M, Google fuzz, a set of real-world applications, binutils,..)

– VUzzer, perhaps for the 1st time, used three different datasets in the evaluation (DARPA CGC, LAVA-M, real-world apps)

▪Seed selection- which inputs to start with?

Page 154: Introduction to Fuzzing

Evaluating Fuzzers- A tough question!

163

▪How to measure efficiency?– Code-coverage, but what about directed fuzzers?

➢Also for binary only fuzzers, measuring code coverage is not that straight forward-static binary instrumentation

➢Also, for source code based fuzzers, what about library code?

– Uniqueness of crashes➢How to differentiate several crashes? Often coredump does not have enough

information!

➢Root-cause analysis (not much is there! Failure Sketching, G. Candea EPFL)

Page 155: Introduction to Fuzzing

Good Engineering

164

▪(the scope of) Optimization is everywhere in a fuzzer.

▪Light-weight fuzzers (e.g. AFL)– Branch bitmap (64K to be fit into the cache)

– Fork()

– Input trimming

▪Every program analysis introduces a performance hit– F1 (World’s fastest grammar based fuzzer- it is F0 by Brandon Falk)

▪VUzzer uses memory file system (tmpfs).

▪Vectorized Emulation: Putting it all together (Brandon Falk)

Page 156: Introduction to Fuzzing

Conclusions

165

Page 157: Introduction to Fuzzing

Conclusions

166

▪Fuzzing – seems easy unless you try it!

Page 158: Introduction to Fuzzing

Conclusions

167

▪Fuzzing – seems easy unless you try it!

▪Scalability and performance cannot be negotiated much!– A good engineering, hardware assisted monitoring

Page 159: Introduction to Fuzzing

Conclusions

168

▪Fuzzing – seems easy unless you try it!

▪Scalability and performance cannot be negotiated much!– A good engineering, hardware assisted monitoring

▪A good place to try program analysis techniques– Possibility to compromise correctness to make them scalable

Page 160: Introduction to Fuzzing

Conclusions

169

▪Fuzzing – seems easy unless you try it!

▪Scalability and performance cannot be negotiated much!– A good engineering, hardware assisted monitoring

▪A good place to try program analysis techniques– Possibility to compromise correctness to make them scalable

▪Software will remain integral part of the cyber world- make is secure!