-
Notifications
You must be signed in to change notification settings - Fork 148
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
New code insertion is inconsistent with middlewares #484
Comments
Nice catches.
I agree. @shouc Can you confirm if there's specific concerns not using |
Yeah I agree. The reason that flashloan middleware is left alone is because flashloan middleware is used in each fuzzing iteration to record the fund changes. Going through a loop every iteration just to find flashloan middleware is a bit costly.
This is ignored because we found adding created contracts during fuzzing can significantly impact the performance. For example, when fuzzing Uniswap Factory, it would deploy millions of pools (contracts), which would stall the fuzzer. Also, these contracts created on the fly are not added to the state but instead directly added to the shared code hashmap used by all states. So, ItyFuzz disallows creating contracts during fuzzing. |
Maybe add a flag to not ignore CREATE and CREATE2? In some situations you may want to sacrifice some performance to find a vulnerability or break an invariant which is possible only when a new contract is created dynamically. |
I've been looking to add in a middleware that does contract analysis whenever new code is discovered. I looked for similar ideas that already are in the codebase, but many implementations are inconsistent. Want to note these down.
I think the best thing to do is use
invoke_middleware!(..., on_insert)
consistently everywhere possible.Coverage middleware
✅ uses
on_insert
as middleware step.👎 in
evm_fuzzer()
, it specifically calls outcoverage.on_insert
rather than invoking all middleware withinvoke_middleware!(..., on_insert)
ityfuzz/src/fuzzers/evm_fuzzer.rs
Lines 303 to 311 in 9840724
Flashloan middleware
👎 uses
on_contract_insertion()
rather thanon_insert()
for contract code👎 uses
handle_contract_insertion!()
macroinvoke_middleware!()
👎 specifically references flashloan middleware rather than doing it in the middleware iteration
ityfuzz/src/evm/host.rs
Lines 984 to 1008 in 9840724
bytecode_analyzers::add_analysis_result_to_state()
This is done to add
ConstantHint
s to dictionary✅ done on contracts ityfuzz inits with
corpus_initializer.rs::initialize_contract()
✅ done on newly loaded onchain code in
load_code()
👎 not done on newly deployed code through the
CREATE
andCREATE2
opcodes in runtimeHost
set_code()
✅ done on contracts ityfuzz inits with
corpus_initializer.rs::initialize_contract()
✅ done on newly loaded onchain code in
load_code()
✅ done on newly deployed code through the
CREATE
andCREATE2
opcodes in runtime✅ calls
invoke_middleware!(..., on_insert)
👎 doesn't call
bytecode_analyzers::add_analysis_result_to_state()
The text was updated successfully, but these errors were encountered: