Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016...

25
SEI Research Review 2016 Vulnerability Discovery Research Review 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution. Vulnerability Discovery David Warren

Transcript of Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016...

Page 1: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

1Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Vulnerability Discovery Research Review 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

Vulnerability DiscoveryDavid Warren

Page 2: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

2Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Copyright 2016 Carnegie Mellon University

This material is based upon work funded and supported by the Department of Defense under Contract No. FA8721-05-C-0003 with Carnegie Mellon University for the operation of the Software Engineering Institute, a federally funded research and development center.

Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the United States Department of Defense.

References herein to any specific commercial product, process, or service by trade name, trade mark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by Carnegie Mellon University or its Software Engineering Institute.

NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN “AS-IS” BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.

[Distribution Statement A] This material has been approved for public release and unlimited distribution. Please see Copyright notice for non-US Government use and distribution.

This material may be reproduced in its entirety, without modification, and freely distributed in written or electronic form without requesting formal permission. Permission is required for any other use. Requests for permission should be directed to the Software Engineering Institute at [email protected].

Carnegie Mellon®, CERT® and CERT Coordination Center® are registered marks of Carnegie Mellon University.

DM-0004078

Page 3: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

3Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Increase assurance of DoD software through enhanced vulnerability discovery techniques

Vulnerability Discovery Project

Page 4: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

4Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Team

• Edward Schwartz, PhD, CERT

• David Warren, CERT

• Allen Householder, CERT

• David Brumley, PhD

• Thanassis Avgerinos, PhD

• Tyler Nighswander

Page 5: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

5Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Revisiting Widely Held Beliefs

about Black-Box Fuzzing

SMART Fuzzing: How to

Intelligently Combine a Fuzzer

with a Concolic Executor

Agenda

Page 6: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

6Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Vulnerability Discovery© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

Revisiting Widely Held Beliefs About Black-Box Fuzzing

Page 7: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

7Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Testing of programs by randomly mutating program inputs (seeds)

Background: Mutational Fuzzing of Software

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLAZ.................................NN.........|...LL...c.

P

Crash

.PN5........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c..PNG..........DR.............Z#+l....PLTE.................................NN.........|...LL...c..PNG........IHDR.............Z#+l....PLTE.................................FM.........|...LL...c.

Crash

Seed File

Mutated File

Program

Page 8: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

8Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Challenge: How Many Software Vulnerabilities Are There?

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

Crash

Page 9: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

9Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Problem: Distinguishing One Vulnerability From Another

I don’t know how to specify a vulnerability, but I know how to fixone

Page 10: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

10Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

The Idea: Patches Define Vulnerabilities

P P’Patch for vulnerability V

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

Crash

.PNG........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

Fixed

Any crash that is fixed by the patch is also affected by vulnerability V

Page 11: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

11Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Example Ground Truth

P1

P2

P1 P2

.PN5........IHDR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG..........DR

.............Z#+l....PLTE.................................NN.........|...LL...c.

.PNG........IHDR

.............Z#+l....PLAZ.................................NN.........|...LL...c.

Page 12: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

12Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

• Fuzzed each program for 1 week with BFF fuzzer• Manually patched all vulnerabilities to collect ground truth

Patching software

Flasm ImageMagick Jasper OpenJpeg

Crashes (BFF) 253 64 93 145

Vulnerabilities 6 31 12 36

Page 13: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

13Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Belief 1: Stack backtrace hashing always accurately counts vulnerabilities.• Used by BFF and other fuzzers.

Belief 2: Sanitization never harms fuzzing performance.• Detects vulnerabilities that do not cause a crash.

Belief 3: The AFL fuzzer always finds more vulnerabilities than non-guided fuzzers.

• Newer is better.

Revisiting Common Beliefs about Black-Box Fuzzing

Page 14: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

14Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Undercount (UC)• # vulnerabilities missed by stack backtrace hashing on average• We never see these vulnerabilities

Overcount (OC)• # times a vulnerability is included more than once by stack backtrace hashing on

average• We see these vulnerabilities more than once

Belief 1: Stack Backtrace Hashing Always Accurately Counts Vulnerabilities

Program # Vuls UC % OC %

Flasm 6 1.8 29% 410.9 6,848%

ImageMagick 31 1.9 6% 67.9 219%

Jasper 12 0.0 0% 226.4 1,887%

OpenJpeg 36 0.1 0% 267.5 743%

Page 15: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

15Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Belief 2: Sanitization Never Harms Fuzzing Performance

Sanitizer

Sanitizer

Page 16: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

16Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Belief 3: The AFL Fuzzer Always Finds More Vulnerabilities Than Non-Guided Fuzzers

Page 17: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

17Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Vulnerability Discovery© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

Collaboration with ForAllSecure

Page 18: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

18Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Page 19: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

19Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Background: Concolic Execution

f t

rows, cols = input()

if rows > 0 && cols > 0

p=malloc(rows*cols*4)

rows=0cols=0

p[rows*cols-1] = 0xFF

exit

¬ (rows > 0&& cols > 0)Π

rows=5cols=10

Page 20: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

20Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Background: Concolic Execution

f t

rows, cols = input()

if rows > 0 && cols > 0

p=malloc(rows*cols*4)

rows=0cols=0

p[rows*cols-1] = 0xFF

exit

¬ (rows > 0&& cols > 0)Π

rows=5cols=10

rows*cols-1 >= rows*cols*4

rows=0x11111110cols=0x0000000f

Overflow?

Page 21: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

21Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Background: Fuzzing

f t

rows, cols = input()

if rows > 0 && cols > 0

p=malloc(rows*cols*4)

rows=0x00004014cols=0x00000034

p[rows*cols-1] = 0xFF

exit

rows=0x00000014cols=0x00000014

Overflow?

0xd040f >= 0x341040

No

Most mutations do not trigger

the overflow vulnerability

Page 22: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

22Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Concolic Execution vs. Fuzzing

Concolic Execution

Fuzzing

Easy constraints

Fast

Blunt

Hard constraints

Slow

Precise

Page 23: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

23Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

The Synergistic Mayhem AFL Research Tool

• Concolic execution: Mayhem (ForAllSecure+SEI)• Fuzzing: AFL• Periodically synchronize seed files between them

Challenges

How much should we use concolic execution?• ~104 times slower than fuzzing• Brute force vs. high cost

SMART

Page 24: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

24Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

0

5000

10000

15000

20000

25000

30000

35000

readelf objdump convert-png mplayer-mp3 pdf2svg-pdf

Edge Coverage After Two Days with Blank Seeds

Mayhem SMART

SMART evaluation

Page 25: Vulnerability Discovery - resources.sei.cmu.edu3 Vulnerability Discovery October 25, 2016 © 2016 Carnegie Mellon University [DISTRIBUTION STATEMENT A] This material has been approved

25Vulnerability Discovery

October 25, 2016© 2016 Carnegie Mellon University

[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribution.

SEI Research Review 2016

Summary

• Developing new techniques for discovering and mitigating vulnerabilities in the DoD

• Developed vulnerability uniqueness model and used ground truth to explore common fuzzing (mis-)beliefs

• ForAllSecure: Hybrid fuzzing and concolic tester

Team Members

• Edward Schwartz, PhD, CERT

• David Warren, CERT

• Allen Householder, CERT

ForAllSecure Inc.:

• David Brumley, PhD

• Thanassis Avgerinos, PhD

• Tyler Nighswander