Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Fuzz Testing and go-fuzz
Search
Poga Po
April 18, 2017
Programming
390
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Fuzz Testing and go-fuzz
Poga Po
April 18, 2017
More Decks by Poga Po
See All by Poga Po
Spacer - iThome Serverless All-Star
poga
2
310
civic-notebook
poga
0
110
everything is log
poga
12
1.9k
g0v intro
poga
0
110
新聞產生器
poga
0
690
RESTful API @ Front-End Developers Taiwan 2014-04-23
poga
3
200
Dependency Management in Go
poga
4
670
Redis: based on real story
poga
16
1.4k
Other Decks in Programming
See All in Programming
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.2k
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
140
OSもどきOS
arkw
0
570
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
New "Type" system on PicoRuby
pocke
1
960
Oxcを導入して開発体験が向上した話
yug1224
4
320
3Dシーンの圧縮
fadis
1
770
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.2k
CSC307 Lecture 17
javiergs
PRO
0
320
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
170
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
240
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
KATA
mclloyd
PRO
35
15k
Designing Experiences People Love
moore
143
24k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
230
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
210
Are puppies a ranking factor?
jonoalderson
1
3.6k
Visualization
eitanlees
152
17k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
Transcript
Fuzz Testing and go- fuzz
Testing • Unit Test • Integration Test
Hard-to-test • Combination • Uncontrolled Input • hard to define
"Corner cases"
Randomized Test?
Parsing email address Any string that doesn't contains @ will
be ignored. func parseAddress(address string) { if (!address.contains("@")) return .... }
Fuzzing Feeding programs with automatically generated inputs to trigger unexpected
behaviour.
Coverage-guided Fuzzing assume we have a huge function func parseAddress(address
string) { // ----------------- switch .... { case : // ----------------- // ----------------- if (...) { // ----------------- // ----------------- } case : if (...) { // ----------------- // ----------------- } case : // ----------------- // ----------------- } }
Coverage-guided Fuzzing First input func parseAddress(address string) { // *****************
switch .... { case : // ----------------- // ----------------- if (...) { // ----------------- // ----------------- } case : if (...) { // ----------------- // ----------------- } case : // ***************** // ***************** } }
Coverage-guided Fuzzing Any input that changed the coverage is an
effective input func parseAddress(address string) { // ***************** switch .... { case : // ***************** // ***************** if (...) { // ----------------- // ----------------- } case : if (...) { // ----------------- // ----------------- } case : // ----------------- // ----------------- } }
American Fuzz Lop
American Fuzz Lop American Fuzzy Lop is a brute-force fuzzer
coupled with an exceedingly simple but rock-solid instrumentation-guided genetic algorithm. It uses a modified form of edge coverage to effortlessly pick up subtle, local-scale changes to program control flow.
go-fuzz
Trophy ... * 50 pages
Setup project for go-fuzz Use AST-rewrite to get coverage information
$ go get github.com/dvyukov/go-fuzz/go-fuzz $ go get github.com/dvyukov/go-fuzz/go-fuzz-build
Write the fuzz function // +build gofuzz // application-level fuzzing
func Fuzz(data []byte) int { img, err := png.Decode(bytes.NewReader(data)) if err != nil { if img != nil { panic("img != nil on error") } return 0 } var w bytes.Buffer err = png.Encode(&w, img) if err != nil { panic(err) } return 1 }
Build fuzzer // put initial corpus to go-fuzz/examples/png/corpus $ go-fuzz-build
github.com/dvyukov/go-fuzz/examples/png // generate png-fuzz.zip
Run the test $ go-fuzz -bin=./png-fuzz.zip -workdir=examples/png $ tree examples/png
examples/png/ !"" corpus # !"" 00184ecf083019781fa3cd954f07ae5f6f8996c5-4 # !"" 00694592b23b147b3ed48fdd58ad93190495c0e1-6 # !"" e1ffccce440e7d27f9f8f4f21b57e1092d5701bc-13 # !"" f1c9f52119ce4f4086ce39c50c84c88373284bb9-9 # !"" f4b5fde0975f447920100b63ca8faa811cd084e5-10 # !"" f4fcdc199b808050a943d900e04e5507d8ccc0f1-7 # $"" f84b0521ed4ee32fcc6f87f1af486efab81986cb-13 # $"" ... !"" crashers $"" suppressions
Examine the output [~/projects/fuzz-test] $ go-fuzz -bin=./png-fuzz.zip -workdir=examples/png 2017/04/17 00:10:44
slaves: 4, corpus: 19 (0s ago), crashers: 0, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 3s 2017/04/17 00:10:47 slaves: 4, corpus: 20 (2s ago), crashers: 0, restarts: 1/3370, execs: 10110 (1681/sec), cover: 173, uptime: 6s 2017/04/17 00:10:50 slaves: 4, corpus: 20 (5s ago), crashers: 0, restarts: 1/4501, execs: 54021 (5964/sec), cover: 173, uptime: 9s ... • slave: concurrent test count • corpus: generated corpus • crashers: corpus which crash the program • restarts: restart rate (due to crashes) • execs: total number of execution • cover: coverage bits
• When should I run fuzz test?: CI • Fuzz
test is only for security issue?: NO • How do I know which corpus crashed my program?: quoted input • Who should write Fuzz test?: You!
Thank you! @devpoga
[email protected]