24
Sophia Antipolis, French Riviera 20-22 October 2015 Fuzz Testing of Web Browsers Presented by Renata Hodovan © All rights reserved

Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Embed Size (px)

Citation preview

Page 1: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Sophia Antipolis, French Riviera20-22 October 2015

Fuzz Testing of Web BrowsersPresented by Renata Hodovan

© All rights reserved

Page 2: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Outline

2

• Principles of random testing• Pros & Cons of fuzzing• How to fuzz a browser?• Evaluation of a real life framework

© All rights reserved

Page 3: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Principles of Fuzz Testing

3

• Idea: Stress testing the target with deformed inputs• Expected bugs (primarily):

Implementation mistakesNon-semantic issues

• Automated testing

© All rights reserved

Page 4: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Possible Issue Types

4

• Stability issuesCrashesMemory corruptionsHangs

• Semantic issuesAssertion failuresOutput mismatch with an oracle

© All rights reserved

Page 5: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Pros & Cons

5

• ProsIt works! :-)Fast and cheapNo need for source codePortable

• ConsSmart fuzzing can be challenging

© All rights reserved

Page 6: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

How to Fuzz a Browser?

© All rights reserved

Page 7: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

What do You Need ?

7

• Evil test generator algorithm• Transfer mechanism• Monitoring framework

© All rights reserved

Page 8: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Browser Fuzzing Framework

8 © All rights reserved

Test

Test

Test

Page 9: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Variations for Generators

9

• Random noise• Mutation based• Generation based• Combination of the above

© All rights reserved

Page 10: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

First Steps ...

10

• Tests with random character sequences• Pros:

Fast and easy to implement

• Cons:Mostly fails on the first checksNot able to find complex errors

• Found bug in WebKit (Apple Safari)&#6198&#656

© All rights reserved

Page 11: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Mutation Based Approaches

11

• Idea: the most error-prone tests are the almost good ones• Let's mess up existing tests!• Pros:

Still easy to implementMuch more effective than purely random

• Cons:The variety of possible tests depends on the initial test set

© All rights reserved

Page 12: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Mutation Based Approaches

12

• Ingredients:

Existing test casesParser for the testsTest domain (in)competence

© All rights reserved

Page 13: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Mutation Based Approaches

13

• Replace tokens with random contents:

<applet code="good.class"></applet>

<applet code="foo.bar"></applet>

(Google Chrome issue)

© All rights reserved

Page 14: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Generation Based Approach

14

• Ingredients:

Model/grammar describing the input formatE.g., in BNF format

Automatism that processes the description and generates a fuzzerANTLR

© All rights reserved

Page 15: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Generation Based Approach

15 © All rights reserved

ANTLRJAVA

Fuzzergrammar

Inputgrammar

Page 16: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Generation Based Approach

16

• Pros:Not bound to any input test setEasier to extendIncreased coverage

• Cons:Needs much more preliminary work

© All rights reserved

Page 17: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

How to Obtain the Input Grammar?

17

• Make your hands dirty! Write it yourself!• Extract it from standards

E.g., from XSD or IDL definitionsThey can be processed automatically

• Extract from existing test casesUncover undocumented features

• Combine all of them

© All rights reserved

Page 18: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Further Challenges

18

• Grammars can only describe syntactic requirements but not semantic ones. E.g.,:

Variable matchingUsing functions with “correct” parameter listBuilding valid relations between XML nodes

• Solution:Adding semantic information manually

E.g., using symbol tables

© All rights reserved

Page 19: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

How to Obtain the Input Grammar?

19

• Make your hands dirty! Write it yourself!• Extract it from standards

E.g., from XSD or IDL definitionsThey can be processed automatically

• Extract from existing test casesUncover undocumented features

• Combine all of them

© All rights reserved

Page 20: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Generation Based Approach

20

function f_0(){

for(var v_0 in [10]){

try {

for(var v_1 in [10])

return;

} finally {}

}

}

for(var v_2 in f_0()) {}

(JavaScriptCore issue)

© All rights reserved

Page 21: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Fuzzinator

© All rights reserved

Page 22: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Features

22

• Supported languagesHTMLSVGMathMLCSSJavaScriptCombinations of the above

© All rights reserved

• Applied techniquesMutationGeneration

• Grammar sourcesHand-writtenExtracted from XSD, IDL, web standards

• Advanced featuresID matching, self adapting weights

Page 23: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Results in Numbers

23 © All rights reserved

Engine Number of bugs

Google Chrome 274

Apple Safari 257

Jerryscript (JS engine) 96

Page 24: Fuzz Testing of Web Browsers - ETSI · Principles of Fuzz Testing 3 • Idea: Stress testing the target with deformed inputs • Expected bugs (primarily): Implementation mistakes

Questions?

24 © All rights reserved