This repository has been archived by the owner on Oct 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
122 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,4 @@ members = [ | |
"gateway", | ||
"genesis", | ||
] | ||
exclude = ["tests"] | ||
exclude = ["tests", "fuzz"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "fuzz" | ||
version = "0.1.0" | ||
authors = ["Oasis Labs <feedback@oasislabs.com>"] | ||
edition = "2018" | ||
publish = false | ||
|
||
[dependencies] | ||
# arbitrary = "0.2" | ||
runtime-ethereum = { path = "..", features = ["test"] } | ||
honggfuzz = "0.5" | ||
|
||
[patch.crates-io] | ||
ring = { git = "https://github.com/akash-fortanix/ring", branch = "sgx-target" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Runtime fuzzing infra | ||
|
||
The runtime is fuzzed using [honggfuzz](https://github.com/google/honggfuzz) via [cargo hfuzz](https://crates.io/crates/honggfuzz). | ||
|
||
Available fuzzing targets are in `src/bin/*.rs`. | ||
Currently there are two targets: | ||
* `create_contract`, which creates a new contract and, if that succeeds, calls it | ||
* `tx`, which sends random transactions to random addresses | ||
|
||
To begin fuzzing, | ||
|
||
1. install the hfuzz [dependencies](https://github.com/rust-fuzz/honggfuzz-rs#dependencies) | ||
2. `cargo install honggfuzz` | ||
3. ensure that runtime is buildable (i.e. build or otherwise obtain Ekiden enclaves) | ||
4. `./run.sh <target name>` | ||
|
||
At the current time, both targets have been fuzzed for over 1m iterations with no crashes found. | ||
While encouraging, don't let this stop you from trying! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
repo_root=$(git rev-parse --show-toplevel) | ||
|
||
export KM_ENCLAVE_PATH="$repo_root/.ekiden/target/x86_64-fortanix-unknown-sgx/debug/ekiden-keymanager-runtime.sgxs" | ||
export RUSTFLAGS='-Ctarget-feature=+aes,+ssse3' | ||
|
||
cd "$repo_root/fuzz" | ||
|
||
cargo hfuzz run $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
fn main() { | ||
let mut client = runtime_ethereum::test::Client::new(); | ||
loop { | ||
honggfuzz::fuzz!(|params: ( | ||
Vec<u8>, | ||
[u8; 32], | ||
Option<u64>, | ||
Option<bool>, | ||
Vec<u8>, | ||
[u8; 32] | ||
)| { | ||
let (code, balance, expiry, c10lity, call_data, call_value) = params; | ||
let addr = | ||
match client.create_contract_with_header(code, &balance.into(), expiry, c10lity) { | ||
Ok((_hash, addr)) => addr, | ||
Err(_) => return, | ||
}; | ||
client.call(&addr, call_data, &call_value.into()).ok(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
fn main() { | ||
let mut client = runtime_ethereum::test::Client::new(); | ||
loop { | ||
honggfuzz::fuzz!(|params: ([u8; 20], Vec<u8>, [u8; 32])| { | ||
let (addr, data, value) = params; | ||
client | ||
.send( | ||
Some(&addr.into()), | ||
data, | ||
&value.into(), | ||
None, /* nonce */ | ||
) | ||
.ok(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters