Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we don't use cheat codes to form fuzzing call sequences #993

Merged
merged 1 commit into from
Mar 22, 2023
Merged
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 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