• Aucun résultat trouvé

Browser Fuzzing with a Twist (and a Shake)

N/A
N/A
Protected

Academic year: 2022

Partager "Browser Fuzzing with a Twist (and a Shake)"

Copied!
55
0
0

Texte intégral

(1)

Browser Fuzzing with a Twist (and a Shake)

Jeremy Brown, 2015

(2)

Agenda

I. Introduc*on

I. Target Architecture II. Infrastructure Notes

II. ShakeIt

I. Current Tooling II. Internals

III. IncubaHon Results

III. Conclusion

(3)

#whoami

•  Jeremy Brown

– Independent researcher / consultant – Formerly of MicrosoN

•  Windows/Phone/Xbox Security

•  Malware ProtecHon Center

– Also, Tenable

•  Nessus

•  RE patches

(4)

What I’m not covering

•  Comprehensive browser fundamentals

– Just enough to get your feet wet

•  Looking for bugs outside of rendering engines

– There’s plenty of other aWack surface, but this one is really juicy & oNen no user interacHon required

•  Sandbox escapes

– This is needed post-compromise of renderer

(5)
(6)

What I’m covering

•  The fuzzing engine part of the puzzle

– But ShakeIt is not a fuzzer, it is a mutator

•  Working with grammar-based parsing engines

– Not specific to browsers, but they’re a primary target

•  Overall setup you need to do so effecHvely

– But not claiming I fuzz as well as Ben Nagy – A lot of hard lessons learned

(7)

Why

•  Share the research instead of just le_ng it sit on my box

– Projects oNen fade away aNer incubaHon, but are more valuable in collaboraHon

•  Not many talks detail the process and how the engine actually works

– Most engines are not rocket science

– Fuzzing really has no rules, any method fair game

(8)

AWack Surface Overview

(9)

Credit:

Chris Rolf / LeafSR (now Yahoo!)

hWp://blog.leafsr.com/2012/09/09/google-naHve-client-aWack-surface-and-vulnerabiliHes-part-4/

(10)

Reference:

“Inside Adobe Reader Protected Mode - Part 1 - Design” – Security @ Adobe

hWp://blogs.adobe.com/security/2010/10/inside-adobe-reader-protected-mode-part-1-design.html

(11)

Fuzzing OpHons

•  GeneraHon

Reference: hWp://www.peachfuzzer.com

(12)

Fuzzing OpHons

•  MutaHon

– Zzuf is the canonical example here

Reference: hWp://caca.zoy.org/wiki/zzuf

(13)

Fuzzing OpHons

•  Code-assisted (eg. sub-evoluHonary)

– American Fuzzy Lop

Reference: hWp://lcamtuf.coredump.cx/afl/

(14)

Fuzzing OpHons

Reference: hWp://lcamtuf.coredump.cx/afl/

(15)

Infrastructure

(16)

Pieces to the Puzzle

•  A complete fuzzing framework has

– Fuzzing Engine

– System Harnesses

– Scaling Infrastructure – Target-specific Support – Helpers

(17)

Pieces to the Puzzle

•  Fuzzing Engine

– Generator per specificaHons

– Mutator based on parHcular algorithms – InstrumentaHon for code-assisted fuzzing

(18)

Pieces to the Puzzle

•  Local System Harnesses

– Debug harness to catch crashes

– Filesystem monitor for interesHng read/write

– Dedicated and high performance database server

•  Or SSD for fast access to local sqlite db

(19)

Pieces to the Puzzle

•  Scaling Infrastructure

– High-performance machines with hypervisors – Clusters in a master/slave setup

– An Army of Droids (eg. jduck)

– UHlizing the online cloud providers

(20)

Pieces to the Puzzle

•  Target-specific Support

– File store for templates (eg. html, xml, pdf)

•  Client to add new templates / remove bad ones

•  WinAppDbg

– Great framework, very versaHle

– Provides a ton of opHons for instrumentaHon – Run into interesHng issues someHmes, eg.

boWleneck with db server / aWach memory errors

(21)

Pieces to the Puzzle

•  Helpers

– Pause/Restart support

– AutomaHc repro / PoC generaHon – Data failure backup mechanisms – Minset support

– InstrumentaHon / Code Coverage

(22)

Agenda

I. IntroducHon

I. Target Architecture II. Infrastructure Notes

II. ShakeIt

I. Current Tooling II. Internals

III. IncubaHon Results

III. Conclusion

(23)

Current Tooling

•  Cross_fuzz

– Cross-document DOM binding fuzzer by lcamtuf – Similar concept to ShakeIt as it either selects or

reuses input fragments

•  Fuzzinator

– Tokenizes a collecHon of input and builds new tests from those

References:

hWp://lcamtuf.coredump.cx/cross_fuzz/

hWp://browser.sed.hu/blog/20141023/fuzzinator-reloaded

(24)

Current Tooling

•  Jsfunfuzz

– JavaScript fuzzer from Jesse Ruderman

– Uses generaHonal method to create interesHng JS

•  LangFuzz

– Grammar-based fuzzer by Mozilla / Saarland Uni – UHlizes the ANTLR suite for parsing

– Like Cross_fuzz, it can reuse input fragments

References:

hWps://github.com/MozillaSecurity/funfuzz/blob/master/js/jsfunfuzz/README.md hWps://www.st.cs.uni-saarland.de/publicaHons/files/holler-usenix-2012.pdf

(25)

DeviaHons from ShakeIt

•  DicHonary

– Defining a dicHonary of valid tokens and replacing them with either randomly generated or oracle input

•  NesHng

– DuplicaHng or mulHplying tokens to create nesHng in random or strategic locaHons

(26)

ShakeIt Algorithm

(27)

High-level Diagram

(28)

How it works

•  CollecHon of tokens or “changeables”

– Data

– PosiHon

•  Switch the data a random posiHons

•  Fix it all back up and generate new test case

•  Idea is simple, but implementaHon is more

complex

(29)

Process

•  Step 1

– Feed it templates (HTML, XML, JS, PDF + JS, etc) – Can handle simple or complex input

(30)

ImplementaHon Details

•  Consume template

– Modes for HTML/JS or PDF/JS

•  Call Shake.It

– It calls Token.Find to find all the tokens – We need at least (2) to perform mutaHon – Token.Find uses extensive set of regex’s

(31)

ImplementaHon Details

•  Token.Match successful, save it and conHnue

•  Once complete, Shake.Shuffle all the tokens

– Iterate from the end, choosing random index and removing items from the pool unHl exhausHon

(32)

ImplementaHon Details

•  ANer Shuffle, now build out the mutaHon

– Find each shuffled posiHon, insert new data and append all other template content appropriately

(33)

ImplementaHon Details

•  Write to output and repeat n iteraHons!

– We use .NET threads to uHlize compuHng power – SHA1 for *unique filenames

•  * We don’t care about collisions here J

(34)

Example Template

(35)
(36)

Fuzzing Strategy

•  Tries to “confuse” the rendering engine

•  Mixes types, parameters, values, objects

•  Tries to put the browser in a weird state and force it to make bad decisions

– “Shaking the memory corrupHon tree”

(37)

Mutated Examples

(38)
(39)
(40)
(41)

Process

•  Step 2

– Store mutated collecHon on file or web server – Make it accessible to a browser

(42)

Process

•  Step 3

– Setup target with harness, iterate over collecHon – Store results in database for sorHng, repros on

network share for debugging promising crashes

(43)

ImplementaHon

•  WriWen in C#

– Algorithm is portable though

•  Available aNer this talk

(44)

IncubaHon

(45)

IncubaHon Results

•  InteresHng Chrome/Opera crashes

– Sadly hard to save repros per infrastructure issues – Could not determine if crashes can from render

bugs or aWach/synchronizaHon issues

(46)

IncubaHon Results

•  MulHple crashes in WebKit/GTK+

– Only 2 / 4 repro’d

– Suspected invalid access on garbage collecHon

(47)

IncubaHon Results

•  Unremarkable crash in KHTML

– ConHnuous memory allocaHons and copies

(48)

IncubaHon Results

•  Likely exploitable memory corrupHon bug in Netsurf (popular embedded device browser)

– CorrupHon of internal structure pointer – Triggered by mutated tag property

(49)

IncubaHon Results

•  InteresHng crash in Phonon (VLC @ web)

– Triggered by parsing mulHmedia content / tags

(50)

Challenges / Lessons Learned

•  Comprehensive fuzzing harnesses enable a smooth process

•  Without a complete system, it’s tough to be successful

– Bandwidth, resources or tooling are boWlenecks

(51)

Agenda

I. IntroducHon

I. Target Architecture II. Infrastructure Notes

II. ShakeIt

I. Current Tooling II. Internals

III. IncubaHon Results

III. Conclusion

(52)

Future Work

•  Enable ShakeIt in scalable environment OR

•  Port it to exisHng fuzzing frameworks

– Joxean’s Nightmare Fuzzer

– <insert your custom fuzzing framework @ home>

– Perhaps even a Metasploit auxiliary module

(53)

Conclusion

•  Fuzzing is more than a mutaHon engine

– Strategy and infrastructure maWer too

•  Investment in tooling is paramount

– But don’t micro-manage ROI!

•  More complexity == more fuzzing bugs

– Code review for complex operaHons is expensive – Manually pen-tesHng is great for logic bugs

– Does anyone seeing so>ware becoming simpler?

(54)

Conclusion

•  Sandboxes cannot save you from bugs

– You just need +1 more bug

•  SDL cannot save you from bugs

– Too much old code, too much new code, not

enough eyes or interested people to throw at it

•  MiHgaHons cannot save you from bugs

– They only make them +n days harder to exploit

•  Managed code is a posi*ve step forward

(55)

The End

QuesHons?

Références

Documents relatifs

To mitigate this limitation, each high-level goal in the tree-list features an option to export a model slice[3], which retrieves all design features contributing to that goal,

To do so, it will be necessary to organize the early retirement or retrofit of some existing capital, to accelerate capital turnover and/or to target the drivers of energy

core values and beliefs, competencies, behaviours, activities, tasks, knowledge and skills, as required, based on the intended applications of the competency

sentations of it. By reducing the complexity of software, visualisations are especially useful when dealing with large amounts of code. One domain that usually deals with large

However, for regular users that sim- ply wish to create new content, a text parser based on a markup language has been implemented (Figure 7).. Beyond:

Fig. The Work Flow Chart in H-Fuzzing Method. H-Fuzzing is composed of two processes: static analysis process and fuzzing process. 1 illustrates the working flow of H-Fuzzing.

The study of mean periodic functions on H 71 is closely related to the study of twisted mean periodic functions on the phase space C 71. If / is a continuous function on C 71 and

The Tor Browser [62] blocks by default APIs like Canvas or WebGL and the Brave browser [34] provides a built-in fingerprinting protection [46] against techniques like Canvas, WebGL,