Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Go Fuzz
Search
Oleg Kovalov
January 15, 2019
Programming
95
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go Fuzz
Oleg Kovalov
January 15, 2019
More Decks by Oleg Kovalov
See All by Oleg Kovalov
Embedded Postgres in Go
olegkovalov
0
90
Hedged requests in Go
olegkovalov
0
450
Writing faster Redis client
olegkovalov
0
240
Moments before main()
olegkovalov
0
120
За пару мгновений до main() [RUS]
olegkovalov
1
660
Bencode - serializer and deserializer in Go
olegkovalov
0
690
impguard - protect your project structure
olegkovalov
0
780
Versioning
olegkovalov
0
150
Modifiability
olegkovalov
0
150
Other Decks in Programming
See All in Programming
ジョジョの世界をXRで再現する
mofurune
0
140
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.6k
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
360
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
5.7k
AWSに止められる覚悟してますか?
morizo_1984
2
520
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
640
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
340
パーソナライズPodcastを作った話
repunit11
0
130
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
320
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
200
Jetpack Compose Mechanisms
skydoves
2
640
Simple Storage Service(S3) is not simple
iwatsukayura
0
230
Featured
See All Featured
WENDY [Excerpt]
tessaabrams
14
40k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Discover your Explorer Soul
emna__ayadi
2
1.3k
The Limits of Empathy - UXLibs8
cassininazir
2
710
Facilitating Awesome Meetings
lara
57
7.2k
Are puppies a ranking factor?
jonoalderson
2
4k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Transcript
go-fuzz or new unit testing WARSAW, JAN 15 2019 Oleg
Kovalov Allegro Twitter: oleg_kovalov Github: cristaloleg
Me - Gopher for ~3 years - Open-source contributor -
Engineer at Allegro.pl core team Twitter: @oleg_kovalov Github: @cristaloleg
Everything start from the Wikipedia Fuzzing is a software testing
technique, often automated or semi-automated, that involves providing invalid, unexpected, or random data to the inputs of a computer program.
go-fuzz - Made by The Dmitry Vyukov aka Bug Slaughterer
at Google - 300+ fixes in Go compiler and stdlib - +inf in the wild, or more - See AFL and syzkaller
What to test? - text format/media codecs - crypto -
network protocols - compression - compilers, interpreters, databases - or anything where you can pass []byte
- horribly easy to use - no human interaction -
designed for computers But why fuzzing?
- out-of-bounds accesses - nil derefs - division by 0/floating-point
- infinite loops - Segfaults (CGo) - … What it may (and will) find?
How does it work? 1. Instrument program for code coverage
2. Collect initial corpus of inputs for { 3. Randomly mutate an input from the corpus 4. Execute and collect coverage if the input gives new coverage { 5. Add the input to corpus } } One cozy loop
func SafeFunc(input string) { if input[0] == 'A' { if
input[1] == 'B' { if input[2] == 'C' { if input[3] == 'D' { print(input[4]) // }}}}} Brute force generation O(2^8^4) = O(2^32) tries. Bruteforce “SafeFunc”
func SafeFunc(input string) { if input[0] == 'A' { if
input[1] == 'B' { if input[2] == 'C' { if input[3] == 'D' { print(input[4]) // }}}}} Brute force generation O(2^8^4) = O(2^32) tries. 0. {} 1. {"A"} 2. {"A", "AB"} 3. {"A", "AB", "ABC"} 4. {"A", "AB", "ABC", "ABCD"} Coverage-guided fuzzer needs O(4 * 2^8) = O(2^10) tries. Smartforce “SafeFunc”
So how to run it? $ go get github.com/dvyukov/go-fuzz/go-fuzz $
go get github.com/dvyukov/go-fuzz/go-fuzz-build # build an executable $ go-fuzz-build github.com/pkg/mypkg # run fuzzing $ go-fuzz -bin=./mypkg-fuzz.zip -workdir=workdir # and follow the logs workers: 8, corpus: 1525 (6s ago), crashers: 6, execs: 0 (0/sec), cover: 1651, uptime: 6s workers: 8, corpus: 1525 (9s ago), crashers: 6, execs: 16787 (1860/sec), cover: 1651, uptime: 9s workers: 8, corpus: 1525 (12s ago), crashers: 6, execs: 29840 (2482/sec), cover: 1651, uptime: 12s Fuzzing
func Fuzz([]byte) int // +build gofuzz package mypkg func Fuzz(data
[]byte) int { _, err := WellTestedFunc(string(data)) if err != nil { return 0 } return 1 } 95% fuzz funcs
- do not run on each build - but run
regularly - fuzz 1 func at time - it’s not unit test replacement - SecOps be aware (doesn’t work with go modules?) Best practices
That’s all folks Thank you Questions? Twitter: @oleg_kovalov Github: @cristaloleg