Fuzzing
Search…
πŸ”€
Fuzzing 1-2-3
How to get from zero to fuzzing hero πŸ’ͺ
There are going to be three main steps to set up fuzzing:
1. Write properties using Scribble​
2. Deploy annotated contracts to Ganache
3. Start Fuzzing!

Writing Properties

The first step is where you’ll be using Scribble to write properties that the fuzzer should check. Without this, fuzzing can only find generic vulnerabilities and assertion violations.
Interested in vulnerability detection? Check out our other product, MythX. It uses fuzzing, symbolic execution and static analysis to detect tons of different vulnerabilities out of the box.
There are tons of ways that you can write properties and property checks. We recommend Scribble! A tool was tailored for property based testing and fuzzing!
You can find the Scribble documentation here.
You can learn everything you need about writing properties here:

Seed Deployments

In the second step, you’ll deploy Scribble instrumented smart contracts to a Ganache node. Why? We will copy over this deployment into our fuzzer and use it as a seed to initialize our fuzzing campaign. This way, fuzzing starts on an actual deployment of the components in your system, and we’re able to test how the system components interact.
πŸ’‘ You can often use existing test fixtures or deployment scripts for your fuzzing seeds!
Browse over to the following page for more information about seed deployments:

Fuzzing

The last step is where the fun is at! We’ll start fuzzing!
We first build a simple configuration that tells our CLI (how to install the cli?) utils where to find all the artifacts needed for fuzzing.
1
# .fuzz_token.yml
2
​
3
analyze:
4
# We need to know where the dependencies live
5
remappings:
6
- "@openzeppelin=./node_modules/@openzeppelin"
7
fuzz:
8
# Tell the CLI where to find the compiled contracts and compilation artifacts
9
build_directory: artifacts
10
11
# The following address is going to be the main target for the fuzzing campaign
12
deployed_contract_address: "0x48b8050b4174f7871ce53AaF76BEAcA765037BFf"
13
14
# We'll do fuzzing with 4 cores πŸš€
15
number_of_cores: 4
16
17
# When the campaign is created it'll get a name <prefix>_<random_characters>
18
campaign_name_prefix: "my-first-campaign"
19
20
# Enable this option if you're fuzzing Scribble annotated code
21
# It'll visualise all the results for the original source code,
22
# instead of the instrumentation code.
23
map_to_original_source: true
24
25
# Point to your ganache node which holds the seed 🌱
26
rpc_url: "http://localhost:8545"
27
28
# This is the contract that the campaign will show coverage for, map issues to, etc.
29
# It's a list of all the relevant contracts (don't worry about dependencies, we'll get those automatically πŸ™Œ)
30
targets:
31
- "contracts/Token.sol"
Copied!
You only need to setup your configuration once! Then you're all set to fuzz in seconds!
Want to learn more about the configuration options?
You can now start a fuzzing campaign!
1
$ fuzz -c .fuzz_token.yml run
2
​
3
You can find your report at: <report_url>
Copied!
🀞 Let's hope we don't find any bugs in your contracts!
For more information on the fuzzing campaign reports check out this page: