Top Banner
Semantic Fuzzing with Zest Rohan Padhye, Caroline Lemieux, Koushik Sen, Mike Papadakis, Yves Le Traon
54

Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

May 12, 2020

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: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Semantic Fuzzing with ZestRohan Padhye, Caroline Lemieux, Koushik Sen, Mike Papadakis, Yves Le Traon

Page 2: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Fuzz Testing

Comic: https://xkcd.com/1210, licensed CC BY-NC 2.5

Semantic Fuzzing with Zest 2

Page 3: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Fuzz Testing is Extremely Popular and Effective

Semantic Fuzzing with Zest 3

CVE-2014-6277: “ShellShock” bug in Bash

CVE-2014-0160: “Heartbleed” bug in OpenSSL

Page 4: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Fuzz Testing is Extremely Popular and Effective

Semantic Fuzzing with Zest 4

CVE-2014-6277: “ShellShock” bug in Bash

CVE-2014-0160: “Heartbleed” bug in OpenSSL

Buffer overflowsMemory leaksUse-after-free

Page 5: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Many test programs look like this:

Input Syntax Analysis

Semantic Analysis Main Logic

Program

Syntax Error

Semantic Error

Valid

Semantic Fuzzing with Zest 5

Page 6: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Many test programs look like this:

Input Syntax Analysis

Semantic Analysis Main Logic

Program

Syntax Error

Semantic Error

Valid

Semantic Fuzzing with Zest 6

Most exploredby fuzzing

Page 7: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Many test programs look like this:

Input Syntax Analysis

Semantic Analysis Main Logic

Program

Syntax Error

Semantic Error

Valid

Semantic Fuzzing with Zest 7

Most exploredby fuzzing

Our goal

Page 8: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

This Talk: Sneak Peak

Fuzzing Apache Ant Syntax Error Semantic Error Semantically Valid

Baseline 1 (AFL) 99.63 % 0.37 % 0 %

Baseline 2 (QuickCheck) 0 % 99.99% 0.0000005%

Semantic Fuzzing with Zest 0 % 80.12 % 19.88 %

Semantic Fuzzing with Zest 8

Page 9: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Semantic Fuzzing with Zest 9

1. Coverage-guided Fuzzing(prior work)

2. Generator-based Fuzzing(prior work)

3. Semantic Fuzzing with Zest(our work)

Page 10: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Semantic Fuzzing with Zest 10

1. Coverage-guided Fuzzing(prior work)

2. Generator-based Fuzzing(prior work)

3. Semantic Fuzzing with Zest(our work)

Page 11: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Case Study$ ant –f build.xml

Logo © Apache Ant Project Team. Apache License 2.0.

Semantic Fuzzing with Zest 11

Page 12: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Mutation-based Fuzzing

<project default=“dist”><target name="init"><mkdir dir="${build}"/></target>…

<project default=“dist”> <taWget name="init"><madir dir="2{build}"/@</tar?get>…

Semantic Fuzzing with Zest 12

Valid Seed Input (build.xml) New Input (Mutated from Seed)

Page 13: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Coverage-guided fuzzing

InputPick

Input’Random Mutation ProgramExecute

Save?Execution feedback

No

Yes

AddInput’

InitialInput

InputInput

Input

Seeds

CoverageInstrumentation

𝑐𝑜𝑣𝑒𝑟𝑎𝑔𝑒New branch coverage?

Semantic Fuzzing with Zest 13

<foo></foo> <woo>?</oo>

Page 14: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Fuzzing Apache Ant

Syntax Error Semantic Error Semanically Valid

AFL (Coverage-guided fuzzing) 99.63 % 0.37 % 0 %

Example: ... <taWget name="init"><madir dir="2{build}"/@</tar?get> ...

Semantic Fuzzing with Zest 14

AFL generates ~500,000 new build.xml files in 1 hour

Input Syntax Analysis Semantic Analysis Main Logic

Program

Syntax Error

Semantic Error

Valid

Most exploredby fuzzing

Page 15: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Semantic Fuzzing with Zest 15

1. Coverage-guided Fuzzing(prior work)

2. Generator-based Fuzzing(prior work)

3. Semantic Fuzzing with Zest(our work)

Page 16: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Let’s generate syntactically valid inputs

• QuickCheck Generator Functions• Context-Free Grammars• Peach Pits• Protocol Buffers• etc.

Semantic Fuzzing with Zest 16

Page 17: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

A Simple XML Generatorpublic XMLElement genXML(Random random)

Semantic Fuzzing with Zest 17

Page 18: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

A Simple XML Generatorpublic XMLElement genXML(Random random) {

fooXMLElement node = new XMLElement(random.nextString());

“foo”

Semantic Fuzzing with Zest 18

Page 19: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

A Simple XML Generatorpublic XMLElement genXML(Random random) {

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

2

Semantic Fuzzing with Zest 19

Page 20: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

A Simple XML Generatorpublic XMLElement genXML(Random random) {

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Semantic Fuzzing with Zest 20

Page 21: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

A Simple XML Generatorpublic XMLElement genXML(Random random) {

Attr{a=42}

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

/* ... Maybe add attributes ... */return node;

Semantic Fuzzing with Zest 21

}

Page 22: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

A Simple XML Generatorpublic XMLElement genXML(Random random) {

<foo><bar a=“42” /><baz>xyz</baz></foo>

Attr{a=42}

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 22

}

Page 23: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

A Simple XML Generatorpublic XMLElement genXML(Random random) {

<foo><bar a=“42” /><baz>xyz</baz></foo>

Attr{a=42}

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 23

}

Observations:

1. Generators are easy to write

2. Every execution produces a syntactically valid input(not necessary semantically valid)

Page 24: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Fuzzing Apache Ant

Syntax Error Semantic Error Semantically Valid

AFL 99.63 % 0.37 % 0 %

QuickCheck (Generator-based fuzzing) 0 % 99.99% 0.0000005%

Example: <sleep><delete copy="propertyhelper” /></sleep>

Semantic Fuzzing with Zest 24

Input Syntax Analysis Semantic Analysis

Main Logic

Program

Syntax Error

Semantic Error

Valid

Page 25: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Semantic Fuzzing with Zest 25

1. Coverage-guided Fuzzing(prior work)

2. Generator-based Fuzzing(prior work)+

???

Page 26: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Semantic Fuzzing with Zest 26

1. Coverage-guided Fuzzing(prior work)

2. Generator-based Fuzzing(prior work)

3. Semantic Fuzzing with Zest(our work)

+

+ =

Page 27: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random)

Semantic Fuzzing with Zest 27

Page 28: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random)

Semantic Fuzzing with Zest 28

Pseudo-random bits: 0000 0011 0110 0110 0110 1111 0110 1111 0000 0010 ….

Page 29: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random) {

<foo><bar a=“42” /><baz>xyz</baz></foo>

Attr{a=42}

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 29

Pseudo-random bits: 0000 0011 0110 0110 0110 1111 0110 1111 0000 0010 ….

}

Page 30: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random) {

<foo><bar a=“42” /><baz>xyz</baz></foo>

Attr{a=42}

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 30

Pseudo-random bits: 0000 0011 0110 0110 0110 1111 0110 1111 0000 0010 ….

“foo”

}

Page 31: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random)

<foo><bar a=“42” /><baz>xyz</baz></foo>

Attr{a=42}

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 31

Pseudo-random bits: 0000 0011 0110 0110 0110 1111 0110 1111 0000 0010 ….

“foo”

Page 32: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random) {

<foo><bar a=“42” /><baz>xyz</baz></foo>

Attr{a=42}

fooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 32

Pseudo-random bits: 0000 0011 0101 0111 0110 1111 0110 1111 0000 0010 ….

“foo” => “woo”

}

Page 33: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random) {

<woo><bar a=“42” /><baz>xyz</baz></woo>

Attr{a=42}

wooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 33

Pseudo-random bits: 0000 0011 0101 0111 0110 1111 0110 1111 0000 0010 ….

“foo” => “woo”

}

Page 34: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random) {

<woo><bar a=“42” /><baz>xyz</baz></woo>

Attr{a=42}

wooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar baz

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

Text{”xyz”}if (random.nextBoolean()) {

node.addText(random.nextString()); }

Semantic Fuzzing with Zest 34

Pseudo-random bits: 0000 0011 0101 0111 0110 1111 0110 1111 0000 0010 ….

2

}

Page 35: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Idea: Parametric Generators

public XMLElement genXML(Random random) {

Attr{a=42}

wooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

if (random.nextBoolean()) {node.addText(random.nextString());

}

Semantic Fuzzing with Zest 35

Pseudo-random bits: 0000 0011 0101 0111 0110 1111 0110 1111 0000 0001 ….

2 => 1

<woo><bar a=“42” /></woo>}

Page 36: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Pseudo-random bits: 0000 0011 0101 0111 0110 1111 0110 1111 0000 0001 ….

public XMLElement genXML(Random random)

Idea: Parametric Generators

<woo><bar a=“42” /></woo>

Attr{a=42}

wooXMLElement node = new XMLElement(random.nextString());

int children = random.nextInt(0, MAX_CHILDREN);

bar

for (int i = 0; i < children; i++) { node.addChild(genXML(random));

}

if (random.nextBoolean()) {node.addText(random.nextString());

}

Key takeaways:

1. Mutations in “parameter” bits = structural mutations in input

2. Every execution produces a syntactically valid input

Semantic Fuzzing with Zest 36

Page 37: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Coverage-guided fuzzing

ProgramExecute

Save?Execution feedback

No

Yes

AddInput’

𝑐𝑜𝑣𝑒𝑟𝑎𝑔𝑒New branch coverage?

Semantic Fuzzing with Zest 37

<foo></foo> <woo>?</oo>

InputPick

Input’RandomMutation

InitialInput

InputInput

Input

Seeds

CoverageInstrumentation

Page 38: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Coverage-guided fuzzing with Parametric Generators

ParamPick

Param’RandomMutation

Save?Execution feedback

No

Yes

AddParam’

InitialInput

InputInput

Param

Seeds

Generator ProgramInput’

Execute

CoverageInstrumentation

New branch coverage?

Semantic Fuzzing with Zest 38

𝑐𝑜𝑣𝑒𝑟𝑎𝑔𝑒

<woo></woo>011000100…. 011001110….

(Structural mutation)

Page 39: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Zest: Validity Fuzzing + Parametric Generators

ParamPick

Param’

Save?Execution feedback

No

Yes

AddParam’

InitialInput

InputInput

Param

Seeds

Generator ProgramExecute

CoverageInstrumentation

New branch coverage? -- OR --

Semantically Valid input with new coverage

among other valid inputs?Semantic Fuzzing with Zest 41

ProgramInput’

<woo></woo>011000100…. 011001110….

𝑐𝑜𝑣𝑒𝑟𝑎𝑔𝑒𝑠𝑒𝑚𝑣𝑎𝑙𝑖𝑑 ∈ { true, false }

RandomMutation

(Structural mutation)

Page 40: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Fuzzing Apache Ant

Syntax Error Semantic Error Semantically Valid

AFL 99.63 % 0.37 % 0 %

QuickCheck 0 % 99.99% 0.0000005%

Semantic Fuzzing with Zest 0 % 80.12 % 19.88 %

Example: <project><augment></augment><target name="init"></target></project>

Ant Bug #62655: Uncaught Exception when augmenting task

Semantic Fuzzing with Zest 43

Input Syntax Analysis Semantic Analysis

Main Logic

Program

Syntax Error

Semantic Error

Valid

Page 41: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Evaluation of Zest

Benchmark Generator Semantic Validity

Apache Ant- Process build.xml

XML Generator (75 LOC)

Ant Build Schema

Apache Maven- Process pom.xml Maven POM Schema

Semantic Fuzzing with Zest 44

Page 42: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Evaluation of Zest

Benchmark Generator Semantic Validity

Apache Ant- Process build.xml

XML Generator (75 LOC)

Ant Build Schema

Apache Maven- Process pom.xml Maven POM Schema

Google Closure Compiler- Optimize JavaScript

JavaScript AST Generator (300 LoC)

Valid ES6

Mozilla Rhino- Translate JavaScript Can be translated to JVM bytecode

Semantic Fuzzing with Zest 45

Page 43: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Evaluation of Zest

Benchmark Generator Semantic Validity

Apache Ant- Process build.xml

XML Generator (75 LOC)

Ant Build Schema

Apache Maven- Process pom.xml Maven POM Schema

Google Closure Compiler- Optimize JavaScript

JavaScript AST Generator (300 LoC)

Valid ES6

Mozilla Rhino- Translate JavaScript Can be translated to JVM bytecode

Apache BCEL- Verify .class files Java Class Generator (500 LoC) Passes bytecode verification

Semantic Fuzzing with Zest 46

Page 44: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Zest attains significantly higher semantic coverage

Semantic Fuzzing with Zest 47

Higher is better

Page 45: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Zest finds semantic bugs reliably and quickly

• Most unique bugs (10)• Quickest (< 10 minutes)• Reliable (across repeated trials)

5% 100%Reliability

Too little too late

Semantic Fuzzing with Zest 48

Page 46: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Zest finds complex semantic bugs

IllegalStateException in VarCheckduring optimization

Google Closure Compiler

Logo CC-by-SA 4.0: https://en.wikipedia.org/wiki/File:Closure_logo.svg

Zest-generated JavaScript input

Semantic Fuzzing with Zest 49

Page 47: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

More semantic bugs…

Mozilla Rhino: Compiler output fails bytecode verification

Google Closure Compiler: Function inlining fails during decomposition

Apache BCEL: Assertion violation when invoking unresolved method

Semantic Fuzzing with Zest 50

Page 48: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Zest is open-source!

https://github.com/rohanpadhye/jqf

Integrated into JQF, our Java fuzzing framework • Used by OSS-community + industry to find 40+ new bugs / CVEs

Semantic Fuzzing with Zest 51

[ISSTA ‘19 Distinguished Artifact]

[ISSTA ‘19 Best Tool Demo]

Page 49: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Summary

Semantic Fuzzing with Zest 52

Page 50: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Backup slides

Validity FuzzingGeneratorsSyntax vs. Semantic AnalysisRelated Work

Semantic Fuzzing with Zest 53

Page 51: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Validity Fuzzing

Semantically Valid Seed

Semantically Invalid Input

SemanticallyValid Input

Covers {A, B}

Covers {A, B, C}Covers {A, B, C}

Random Mutatio

ns

Random Mutations

Semantic Fuzzing with Zest 54

Backup slides

Page 52: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Generators in Practice• Erdős–Rényi model: Generator for random graphs (1959)

• https://en.wikipedia.org/wiki/Erdos-Renyi_model

• DartFuzz: Generator for Dart programs written in Dart

• https://github.com/dart-lang/sdk/blob/master/runtime/tools/dartfuzz/dartfuzz.dart

• Csmith: Generator for C programs written in C++

• https://github.com/csmith-project/csmith [PLDI ‘11]

• StringFuzz: Generator for SMT-lib formulas written in Python

• https://github.com/dblotsky/stringfuzz [ASE ‘18]

• … and many more!

Semantic Fuzzing with Zest 55

Backup slides

Page 53: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Benchmarks: Identification of Stages

Name Syntax Analysis Classes Semantic Analysis Classes

Apache Ant- Process build.xml

com.sun.org.apache.xerces org.apache.tools.ant

Apache Maven- Process pom.xml

org.codehaus.plexus.util.xml org.apache.maven.model

Google Closure Compiler- Optimize JavaScript

com.google.javascript.jscomp.parsing com.google.javascript.jscomp.[A-Z]

Mozilla Rhino- Translate JavaScript

org.mozilla.javascript.Parser org.mozilla.javascript.optimizerorg.mozilla.javascript.CodeGen

Apache BCEL- Verify .class files

org.apache.bcel.classfile org.apache.bcel.verifier

Semantic Fuzzing with Zest 56

Backup slides

Page 54: Semantic Fuzzing with Zest - People @ EECS at UC Berkeleyrohanpadhye/files/zest-issta19... · Apache Maven-Process pom.xml Maven POM Schema Google Closure Compiler-Optimize JavaScript

Structure-aware greybox fuzzing

• Zest [ISSTA ‘19]

• libFuzzer + protobuf [LLVM ‘18]

• Nautilus [NDSS’19]

• Superion [ICSE’19]

• Greybox fuzzing with grammars [fuzzingbook.org]

• AFLSmart

• CGPT [OOPSLA 2019]

Semantic Fuzzing with Zest 57

Backup slides