Skip to content

Commit dfab064

Browse files
xgreenxmaxammannnetromeAurelienFT
authored
Add advanced fuzzer (#724) (#733)
* Add advanced fuzzer (#724) * Add initial fuzz files * Fix original fuzz test * Add byte-based script functions back for fuzzing * Disable some errors for fuzzing * Fix new fuzz test due to changes in fuel-vm * Remove unused target * Add readme * feat: Store example corpus in version control * chore: Instructions for how to generate a seed corpus * chore: Remove unused dependencies in binaries * fix: Cargo fmt * fix: Clippy * fix: Pass `fuzzing` as rustc flag when compiling fuzz binaries * feat: Remove broken `grammar_aware` fuzz target in favor of `grammar_aware_advanced` * feat: Default to LibAFL fuzzer * docs: Improve code coverage instructions * feat: Use feature flags to toggle between libFuzzer and LibAFL * docs: Further improvements to code coverage instructions * docs: Clarify what the execute binary does * fix: Minor cleanup * chore: Remove `arbitrary` dependency * feat: Link investigation ticket to ignored assertions * fix: Resurrect proptest arbitrary usage in `fuel-merkle` crate * fix: Remove gas statistics output * fix: typo in fuel-vm/fuzz/README.md Co-authored-by: AurelienFT <[email protected]> * chore: Remove example corpus and update README.md * fix: Minor enhancements from PR review * fix: Remove redundant magic 256 term * fix: Cargo fmt * chore: Bump secp256k1 version and re-enable disabled code paths for fuzzing * chore: Add changelog entry * fix: Clippy fix * fix: Format * Update fuel-crypto/src/secp256/signature_format.rs * chore: Add supported rust version to fuzzer readme * refactor: use `expect` instead of `unwrap` in a lot of places * refactor: Apply review suggestions * fix: More unwrap -> expect --------- Co-authored-by: Max Ammann <[email protected]> Co-authored-by: Mårten Blankfors <[email protected]> Co-authored-by: Mårten Blankfors <[email protected]> Co-authored-by: AurelienFT <[email protected]>
1 parent d28a143 commit dfab064

File tree

22 files changed

+458
-66
lines changed

22 files changed

+458
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [Unreleased]
99

1010
### Added
11-
1211
- [#670](https://github.com/FuelLabs/fuel-vm/pull/670): Add DA compression functionality to `Transaction` and any types within
12+
- [#733](https://github.com/FuelLabs/fuel-vm/pull/733): Add LibAFL based fuzzer and update `secp256k1` version to 0.29.1.
1313

1414
### Changed
1515

1616
#### Breaking
17-
1817
- [#670](https://github.com/FuelLabs/fuel-vm/pull/670): The `predicate` field of `fuel_tx::input::Coin` is now a wrapper struct `PredicateCode`.
1918

2019
## [Version 0.56.0]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ It returns `receipts` that contain result of execution. The `assert_panics` can
8888
The `fuel-tx` provides `fuel_tx::TransactionBuilder` that simplifies the building
8989
of custom transaction for testing purposes.
9090

91-
You can check how `TransactionBuilder::script` or `TransactionBuilder::create` are used for better understanding.
91+
You can check how `TransactionBuilder::script` or `TransactionBuilder::create` are used for better understanding.

fuel-asm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ repository = { workspace = true }
1111
description = "Atomic types of the FuelVM."
1212

1313
[dependencies]
14-
arbitrary = { version = "1.1", features = ["derive"], optional = true }
1514
bitflags = { workspace = true }
1615
fuel-types = { workspace = true, default-features = false }
1716
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }

fuel-asm/src/args.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ crate::enum_try_from! {
1111
#[cfg_attr(feature = "typescript", wasm_bindgen::prelude::wasm_bindgen)]
1212
#[repr(u8)]
1313
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1514
/// Argument list for GM (get metadata) instruction
1615
/// The VM is the only who should match this struct, and it *MUST* always perform
1716
/// exhaustive match so all offered variants are covered.
@@ -51,7 +50,6 @@ crate::enum_try_from! {
5150
#[cfg_attr(feature = "typescript", wasm_bindgen::prelude::wasm_bindgen)]
5251
#[repr(u16)]
5352
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
54-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
5553
pub enum GTFArgs {
5654
/// Set `$rA` to `tx.type`
5755
Type = 0x001,

fuel-asm/src/panic_instruction.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::{
1111
#[cfg_attr(feature = "typescript", wasm_bindgen::prelude::wasm_bindgen)]
1212
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1313
#[derive(fuel_types::canonical::Deserialize, fuel_types::canonical::Serialize)]
14-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1514
/// Describe a panic reason with the instruction that generated it
1615
pub struct PanicInstruction {
1716
reason: PanicReason,

fuel-asm/src/panic_reason.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ enum_from! {
2727
#[cfg_attr(feature = "typescript", wasm_bindgen::prelude::wasm_bindgen)]
2828
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2929
#[derive(fuel_types::canonical::Serialize, fuel_types::canonical::Deserialize)]
30-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
3130
#[repr(u8)]
3231
#[non_exhaustive]
3332
/// Panic reason representation for the interpreter.

fuel-crypto/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ p256 = { version = "0.13", default-features = false, features = ["digest", "ecd
2222
rand = { version = "0.8", default-features = false, optional = true }
2323
# `rand-std` is used to further protect the blinders from side-channel attacks and won't compromise
2424
# the deterministic arguments of the signature (key, nonce, message), as defined in the RFC-6979
25-
secp256k1 = { version = "0.26", default-features = false, features = ["rand-std", "recovery"], optional = true }
25+
secp256k1 = { version = "0.29.1", default-features = false, features = ["rand-std", "recovery"], optional = true }
2626
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
2727
sha2 = { version = "0.10", default-features = false }
2828
zeroize = { version = "1.5", features = ["derive"] }
@@ -41,6 +41,9 @@ serde = ["dep:serde", "fuel-types/serde"]
4141
std = ["alloc", "coins-bip32", "secp256k1", "coins-bip39", "fuel-types/std", "lazy_static", "rand?/std_rng", "serde?/default"]
4242
test-helpers = []
4343

44+
[lints.rust]
45+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
46+
4447
[[bench]]
4548
name = "signature"
4649
harness = false

fuel-crypto/benches/signature.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ fn signatures(c: &mut Criterion) {
7070

7171
let public = PublicKey::from_secret_key(&secp, &key);
7272
let message = fuel_crypto::Message::new(message);
73-
let message =
74-
Message::from_slice(message.as_ref()).expect("failed to create secp message");
73+
let message = Message::from_digest_slice(message.as_ref())
74+
.expect("failed to create secp message");
7575
let signature = secp_signing.sign_ecdsa(&message, &key);
7676
let recoverable = secp.sign_ecdsa_recoverable(&message, &key);
7777

fuel-crypto/src/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ impl fmt::Display for Message {
118118
#[cfg(feature = "std")]
119119
impl From<&Message> for secp256k1::Message {
120120
fn from(message: &Message) -> Self {
121-
secp256k1::Message::from_slice(&*message.0).expect("length always matches")
121+
secp256k1::Message::from_digest_slice(&*message.0).expect("length always matches")
122122
}
123123
}

fuel-tx/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ alloc = ["hashbrown", "fuel-types/alloc", "itertools/use_alloc", "derivative", "
5959
# serde is requiring alloc because its mandatory for serde_json. to avoid adding a new feature only for serde_json, we just require `alloc` here since as of the moment we don't have a use case of serde without alloc.
6060
serde = ["alloc", "fuel-asm/serde", "fuel-crypto/serde", "fuel-merkle/serde", "serde_json", "hashbrown/serde", "bitflags/serde"]
6161
da-compression = ["serde", "fuel-compression"]
62+
63+
[lints.rust]
64+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }

0 commit comments

Comments
 (0)