Skip to content

Commit

Permalink
Make sure we don't use cheat codes to form fuzzing call sequences (cr…
Browse files Browse the repository at this point in the history
  • Loading branch information
arcz authored Mar 22, 2023
1 parent eea4296 commit a2d5b14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Echidna.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ prepareContract env contracts solFiles specifiedContract seed = do
<> deployedAddresses

let dict = mkGenDict env.cfg.campaignConf.dictFreq
constants
-- make sure we don't use cheat codes to form fuzzing call sequences
(Set.delete (AbiAddress cheatCode) constants)
Set.empty
seed
(returnTypes contracts)
Expand Down
6 changes: 4 additions & 2 deletions lib/Echidna/Campaign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Data.Set qualified as Set
import Data.Text (Text)
import System.Random (mkStdGen)

import EVM (Contract, VM(..), VMResult(..), bytecode)
import EVM (Contract, VM(..), VMResult(..), bytecode, cheatCode)
import EVM qualified (Env(..))
import EVM.ABI (getAbi, AbiType(AbiAddressType), AbiValue(AbiAddress))
import EVM.Types (Addr, Expr(ConcreteBuf))
Expand Down Expand Up @@ -246,7 +246,9 @@ callseq initialCorpus vm world seqLen = do
case result of
VMSuccess (ConcreteBuf buf) ->
case runGetOrFail (getAbi type') (LBS.fromStrict buf) of
Right (_, _, abiValue) -> Just (type', Set.singleton abiValue)
-- make sure we don't use cheat codes to form fuzzing call sequences
Right (_, _, abiValue) | abiValue /= AbiAddress cheatCode ->
Just (type', Set.singleton abiValue)
_ -> Nothing
_ -> Nothing

Expand Down

0 comments on commit a2d5b14

Please sign in to comment.