Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ target/
build
.vscode
log
*.log
*.log
flamegraph.svg
56 changes: 55 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/movy-fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ move-vm-stack = {workspace = true}
move-vm-types = {workspace = true}
sui-types = {workspace = true}
sui-json-rpc-types = {workspace = true}
pprof = {workspace = true, optional = true}
pprof = {workspace = true, optional = true, features = ["flamegraph"] }
4 changes: 2 additions & 2 deletions crates/movy-fuzz/src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{borrow::Cow, collections::BTreeMap, fmt::Display, marker::PhantomData};
use std::{borrow::Cow, collections::BTreeMap, fmt::Display, marker::PhantomData, ops::AddAssign};

use libafl::{
HasMetadata,
Expand Down Expand Up @@ -126,7 +126,7 @@ where
self.oracles.pre_execution(&db, state, input.sequence())?;

trace!("Executing input: {}", input.sequence());

state.executions_mut().add_assign(1);
let gas_id = state.fuzz_state().gas_id;
let tracer = SuiFuzzTracer::new(&mut self.ob, state, &mut self.oracles, CODE_OBSERVER_NAME);

Expand Down
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/operations/sui_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ where
executor: executor_inner,
ob: tuple_list!(code_observer),
attacker,
oracles: oracles(false),
oracles: oracles(true),
disable_oracles: false,
epoch: state.fuzz_state().epoch,
epoch_ms: state.fuzz_state().epoch_ms,
Expand Down
4 changes: 2 additions & 2 deletions crates/movy-fuzz/src/oracles/sui/bool_judgement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ impl<T, S> SuiGeneralOracle<T, S> for BoolJudgementOracle {
event: &TraceEvent,
_stack: Option<&Stack>,
symbol_stack: &ConcolicState,
current_function: Option<movy_types::input::FunctionIdent>,
current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
match event {
TraceEvent::BeforeInstruction {
pc, instruction, ..
} => {
let stack_syms = &symbol_stack.stack;
let current = current_function.as_ref().and_then(to_module_func);
let current = current_function.and_then(to_module_func);
let loss = match instruction {
Bytecode::Eq
| Bytecode::Neq
Expand Down
4 changes: 2 additions & 2 deletions crates/movy-fuzz/src/oracles/sui/infinite_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<T, S> SuiGeneralOracle<T, S> for InfiniteLoopOracle {
event: &TraceEvent,
_stack: Option<&Stack>,
symbol_stack: &ConcolicState,
current_function: Option<movy_types::input::FunctionIdent>,
current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
match event {
Expand All @@ -54,7 +54,7 @@ impl<T, S> SuiGeneralOracle<T, S> for InfiniteLoopOracle {
} => {
match instruction {
Bytecode::BrFalse(_) | Bytecode::BrTrue(_) => {
let Some(func) = current_function.as_ref().and_then(to_module_func) else {
let Some(func) = current_function.and_then(to_module_func) else {
return Ok(vec![]);
};
if symbol_stack.stack.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/oracles/sui/overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<T, S> SuiGeneralOracle<T, S> for OverflowOracle {
event: &TraceEvent,
stack: Option<&Stack>,
_symbol_stack: &ConcolicState,
current_function: Option<movy_types::input::FunctionIdent>,
current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
match event {
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/oracles/sui/precision_loss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<T, S> SuiGeneralOracle<T, S> for PrecisionLossOracle {
event: &TraceEvent,
_stack: Option<&Stack>,
symbol_stack: &ConcolicState,
current_function: Option<movy_types::input::FunctionIdent>,
current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
match event {
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/oracles/sui/proceeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ where
_event: &TraceEvent,
_stack: Option<&Stack>,
_symbol_stack: &ConcolicState,
_current_function: Option<movy_types::input::FunctionIdent>,
_current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
Ok(vec![])
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/oracles/sui/type_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<T, S> SuiGeneralOracle<T, S> for TypeConversionOracle {
event: &TraceEvent,
stack: Option<&Stack>,
_symbol_stack: &ConcolicState,
current_function: Option<movy_types::input::FunctionIdent>,
current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
match event {
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/oracles/sui/typed_bug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
_event: &TraceEvent,
_stack: Option<&Stack>,
_symbol_stack: &ConcolicState,
_current_function: Option<movy_types::input::FunctionIdent>,
_current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
Ok(vec![])
Expand Down
6 changes: 3 additions & 3 deletions crates/movy-replay/src/tracer/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ where
let rhs = stack
.value
.get(stack_len - 1)
.ok_or_eyre(eyre!("stack less than 2?!"))?
.ok_or_else(|| eyre!("stack less than 2?!"))?
.copy_value()?
.value_as::<IntegerValue>()?
.into();
let lhs = stack
.value
.get(stack_len - 2)
.ok_or_eyre(eyre!("stack less than 2?!"))?
.ok_or_else(|| eyre!("stack less than 2?!"))?
.copy_value()?
.value_as::<IntegerValue>()?
.into();
Expand All @@ -190,7 +190,7 @@ where
event,
stack,
&self.outcome.concolic,
self.current_functions.last().cloned(),
self.current_functions.last(),
self.state,
)?;
if !oracle_vulns.is_empty() {
Expand Down
41 changes: 20 additions & 21 deletions crates/movy-replay/src/tracer/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub trait SuiGeneralOracle<T, S> {
event: &TraceEvent,
stack: Option<&Stack>,
symbol_stack: &ConcolicState,
current_function: Option<FunctionIdent>,
current_function: Option<&FunctionIdent>,
state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError>;

Expand All @@ -49,7 +49,7 @@ impl<T, S> SuiGeneralOracle<T, S> for () {
_event: &TraceEvent,
_stack: Option<&Stack>,
_symbol_stack: &ConcolicState,
_current_function: Option<movy_types::input::FunctionIdent>,
_current_function: Option<&movy_types::input::FunctionIdent>,
_state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
Ok(vec![])
Expand Down Expand Up @@ -85,22 +85,19 @@ where
event: &TraceEvent,
stack: Option<&Stack>,
symbol_stack: &ConcolicState,
current_function: Option<movy_types::input::FunctionIdent>,
current_function: Option<&movy_types::input::FunctionIdent>,
state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
let mut findings = vec![];
findings.extend(self.0.event(
event,
stack,
symbol_stack,
current_function.clone(),
state,
)?);
findings.extend(
self.1
.event(event, stack, symbol_stack, current_function, state)?,
);
Ok(findings)
Ok(self
.0
.event(event, stack, symbol_stack, current_function.clone(), state)?
.into_iter()
.chain(
self.1
.event(event, stack, symbol_stack, current_function, state)?
.into_iter(),
)
.collect())
}

fn done_execution(
Expand All @@ -109,10 +106,12 @@ where
state: &mut S,
effects: &TransactionEffects,
) -> Result<Vec<OracleFinding>, MovyError> {
let mut findings = vec![];
findings.extend(self.0.done_execution(db, state, effects)?);
findings.extend(self.1.done_execution(db, state, effects)?);
Ok(findings)
Ok(self
.0
.done_execution(db, state, effects)?
.into_iter()
.chain(self.1.done_execution(db, state, effects)?.into_iter())
.collect())
}
}

Expand Down Expand Up @@ -148,7 +147,7 @@ where
event: &TraceEvent,
stack: Option<&Stack>,
symbol_stack: &ConcolicState,
current_function: Option<FunctionIdent>,
current_function: Option<&FunctionIdent>,
state: &mut S,
) -> Result<Vec<OracleFinding>, MovyError> {
if self.disabled {
Expand Down
Loading
Loading