79
The Aftermath of a Fuzz Run: What to do with all those crashes? David Moore

The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

The Aftermath of a Fuzz Run:What to do with all those crashes?

David Moore

Page 2: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

David Moore Bio

Page 3: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

NeXT, Apple, Weblogic, BEA Systems, Azul Systems

Page 4: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 5: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 6: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Google, Twitter, Netflix, Optimizely, Card, kernel, 

ruby, php, cpio

Page 7: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Founder/CEO

Page 8: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Talk Outline1> Introduce/Review Memory Corruption Bugs

2> A Post Fuzz Run Workflow

3> Real World Examples

Page 9: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Section 1a:Introduce / Review 

Memory Corruption Bugs

Page 10: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

InvalidReads/Writes

Page 11: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Stack vs HeapCorruption

Page 12: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

int main (int argc, char **argv) { char buf[8]; strcpy(buf, argv[1]);}

./a.out AAAAAAAAAAAA

Page 13: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Use After Free

Page 14: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

char* x = (char*)malloc(4);...

free(x);…

printf(x)   // uaf

Page 15: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Other Memory Bugs

Page 16: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Section 1b:What is Exploitability?

Page 17: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Re­programming with input data ­

not code

Page 18: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Re­programming with existing code in the 

process

Page 19: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Does “exploitability” 

matter?

Page 20: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

ExploitableBy Whom?

Page 21: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

GoogleProject Zero

Page 22: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

NSA

Page 23: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

hhhhh??

Page 24: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Many modern exploits are bug 

chains

Page 25: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Surprisingly Exploitable

Page 26: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

C­Ares / Chrome OS Remote Code 

Execution

Page 27: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 28: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 29: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Triggered by a trailing escaped dot:

www.foo.com\.

Page 30: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Section 1c:Memory Corruption 

Mitigations

Page 31: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Stack Canaries

Page 32: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 33: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 34: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

DEPData Execution

Prevention

Page 35: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

ASLRAddress Space Layout

Randomization

Page 36: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 37: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 38: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 39: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Section 2:A Post Fuzz Run Workflow

2a> Minimize crash corpus 2b> Use Memory Corruption Tools 2c> Determine Exploitability ­ or ­  Find the Root Cause

Page 40: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Whyminimize?

Page 41: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Minimize the Corpus of Crashes

Page 42: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Minimize each crashing case individually

Page 43: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

fdupes

Page 44: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Section 2b:Memory Corruption 

Analysis Tools

Page 45: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

All Bets are Off

Page 46: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Address Sanitizer

ASAN­fsanitize­address

Page 47: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 48: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Valgrind(memcheck)

Page 49: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 50: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Exploitable

Page 51: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 52: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 53: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Section 2c:Determine

Exploitability /Find the Root Cause

Page 54: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Disable ASLRecho 0 | sudo tee

/proc/sys/kernel/randomize_va_space

Page 55: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Identify critical memory

locations

Page 56: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

gdbgcc ­g ­O0 target.c

Page 57: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

./target AAAA

0x41414141

Page 58: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

rr

rr­project.org

Page 59: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 60: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

It is OK and normal to:

Feel lost / frustratedTake a lot of time

Feel like your wheels are spinningGet sick of staring at hex

Page 61: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

OneMore Thing:

Once the bugs are fixed -Fuzz the target again

Page 62: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Section 3: Real World Examples

Page 63: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

PHP:Low invalid read

Page 64: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 65: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 66: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 67: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 68: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Ruby:Heap Buffer

Overflow

Page 69: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 70: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 71: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 72: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 73: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Netflix Dynomite: Invalid Write

Page 74: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Netflix Dynomite:● Running in production ~2 

years● 1000 Customer facing nodes● 1 Million ops/sec peak load

Page 75: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 76: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 77: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>
Page 78: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

References:● RPI ­ Modern Binary Exploitation ­ 

GitHub: rpisec/mbe● Hacking: The Art of Exploitation ­ Jon 

Erickson● Project Zero Blog ­ What is Good 

Memory Corruption?● Sean Heelan’s Blog ­ Tracking Down 

Heap Overflows with rr

Page 79: The Aftermath of a Fuzz Run · 2017-12-14 · The Aftermath of a Fuzz Run: ... Founder/CEO. Talk Outline 1> Introduce/Review Memory Corruption Bugs 2> A Post Fuzz Run Workflow 3>

Thank You!David Moore@grajagandev

[email protected]