Skip to content

Commit

Permalink
Make sure we don't use cheat codes to form fuzzing call sequences (#993)
Browse files Browse the repository at this point in the history
arcz authored Mar 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent eea4296 commit a2d5b14
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
@@ -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)
6 changes: 4 additions & 2 deletions lib/Echidna/Campaign.hs
Original file line number Diff line number Diff line change
@@ -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))
@@ -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

0 comments on commit a2d5b14

Please sign in to comment.