Top Banner
All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos, David Brumley Presented by: Vaibhav Rastogi 1
40

All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

Mar 28, 2015

Download

Documents

Melinda Jinkins
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: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

1

All You Ever Wanted to Know About Dynamic Taint Analysis & Forward

Symbolic Execution (but might have been afraid to ask)

Edward J. Schwartz, ThanassisAvgerinos, David Brumley

Presented by: Vaibhav Rastogi

Page 2: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

2

The Root of All Evil

Humans write programs

This Talk:Computers Analyzing Programs Dynamically at Runtime

Page 3: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

3

Two Essential Runtime Analyses

Dynamic Taint Analysis:What values are derived from this source?

Forward Symbolic Execution:What input will make execution reach this line of code?

Malware Analysis

Privacy Leakage Detection

Vulnerability Detection

Automatic Test-case Generation

Input Filter Generation

Malware Analysis

Page 4: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

4

ContributionsFormalize English descriptions• An algorithm / operational

semantics

Technical highlights, caveats, issues, and

unsolved problems that are deceptively hard

Systematize recurring themes in a wealth of

previous work

Page 5: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

5

Contributions

Page 6: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

6

Dynamic Taint Analysis

How it Works

Example Policies

Issues

Page 7: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

7

Example

Page 8: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

8

Example

Input is tainted

Page 9: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

9

Taint Introduction

Tainted Untainted

x

Input is tainted

Page 10: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

10

Taint Introduction

Var Val Taint ( T | F)x 7 T

Page 11: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

11

Taint Propagation

Tainted Untainted

x

Data derived from user input

is tainted

xy 42

Page 12: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

12

Taint Propagation

Var Val Taint ( T | F)x 7 Ty 49 T

Page 13: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

13

Taint Checking

Tainted Untainted

x

Policy violation detected

xy 42

y

Page 14: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

14

So What?

x

xy 42

y

Exploit Detection

Tainted return

address

Page 15: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

15

Taint Checking

Var Val Taint ( T | F)x 7 Ty 49 T

Page 16: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

16

Taint Semantics in SIMPIL

Page 17: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

17

SIMPIL Operational Semanticstl;dr

Page 18: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

18

Operational Semantics for Tainting

Page 19: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

19

Operational Semantics for Tainting

Page 20: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

20

Example Taint Semantics

Page 21: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

21

Example Taint Policy

Page 22: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

22

Dynamic Tainting Issues

Tainted Addresses• To taint, or not to taint

Undertainting• Control flows discussed earlier

Overtainting• Sanitization

Time of Detection vs. Time of Attack• Overwritten return address detected only at return

Page 23: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

23

Dynamic Tainting Issues

x

xy 42

y

Overwritten return address detected only at return

Page 24: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

24

Tainted Addresses

Don’t taint y• Table indices, e.g. ,a[i] == i

Taint y• tcpdump uses packet data

to compute function pointers

Page 25: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

25

Dilemma

Undertainting:False Negatives Overtainting:

False Positives

Page 26: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

26

Forward Symbolic Execution

How it Works

Challenges

Proposed Solutions

Page 27: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

27

Example

bad_abs(x is input) if (x < 0) return -x if (x = 0x12345678) return -xreturn x

Page 28: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

28

Example

232 possible inputs

0x12345678

bad_abs(x is input) if (x < 0) return -x if (x = 0x12345678) return -xreturn x

What input will execute this line of code?

Page 29: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

29

Workingbad_abs(x is

input)

if (x < 0)

return -xif (x =

0x12345678)

return -xreturn x

F T

TF

x ≥ 0 x < 0

x ≥ 0 &&x == 0x12345678

x ≥ 0 &&x != 0x12345678

Page 30: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

30

Workingbad_abs(x is

input)

if (x < 0)

return -xif (x =

0x12345678)

return -xreturn x

F T

TF

x ≥ 0 x < 0

x ≥ 0 &&x == 0x12345678

x ≥ 0 &&x != 0x12345678

What input will execute this line of code?

Page 31: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

31

Operational Semantics

Page 32: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

32

Operational Semantics

Page 33: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

33

Challenges

Exponential Number of Paths

Symbolic Memory

System Calls

Page 34: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

34

Exponential Number of Paths

Page 35: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

35

Exploration Strategies

•Bounded necessary – else loops mayn’t terminate!

Bounded Depth First Search

•Possibly different weights to different paths

Random Paths

•Mix symbolic and concrete execution

•Make symbolic execution follow a concrete execution path

Concolic Execution

Page 36: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

36

Symbolic memory

• Example: tables

• Aliasing issues• Solutions:– Make unsound assumptions– Let the SMT solver do the work– Perform alias analysis

• A static analysis – may not be acceptable

• Related Problem: Symbolic jumps

addr1 = get_input()store(addr1, v)z = load(addr2)

Page 37: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

37

Symbolic Jumps

Explore jump targets found in concrete execution

Let the solver solve it

Do static analysis

The pc depends on the user input

Page 38: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

38

System and Library Calls

• What are effects of such calls?

• Manual summarization is possible in some cases

• Use results from concrete execution– Not sound

Page 39: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

39

Symbolic Execution is not Easy

• Exponential number of paths

• Exponentially sized formulas with substitution

• Solving a formula is NP-complete

s + s + s + s + s +s + s + s + s + s + s + s +s = 42

Page 40: All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, ThanassisAvgerinos,

40

Conclusion

• Dynamic Taint Analysis and Forward Symbolic Execution both extensively used– A number of options explored

• This talk provided– Overview of the techniques– Applications– Issues and state-of-the-art solutions