-
Notifications
You must be signed in to change notification settings - Fork 752
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
How to make Mythril analyze all functions to their regular end at RETURN/STOP? #1777
Comments
Here are the functions that I want Mythril to report:
|
Mythril visits all functions. You can prefer using bfs as a strategy to make it prioritise the breadth over depth. If your goal is to simply |
@norhh Thanks for your suggestion. However, the option
|
|
You should add |
@norhh Thanks for the hint regarding Adding Might it be the case that Mythril stops its analysis when encountering a state similar to ones seen before? Actually, the state at the end of a getter is not really the same as at the end of other getters, as they return different storage values. Is there a way to let Mythril also explore such parts of the search space? |
Simple getters such as |
A quick fix for fixing the getter issue will be to solve for the first 4 bytes of calldata to get the function signature. I'll push that fix today sometime. |
Of course they do, how would the EVM otherwise return control to the calling context, with a return value? Below is the sequence of instructions for
|
The |
The bytecode maps the final |
Thanks for the explanations, I think I now understand. |
Nevermind, Actually Mythril seems to detect getters at the return by matching the |
Commenting out:
|
@gsalzer , can you try it with the latest commit? |
@norhh With
but the following ones are still missing:
|
You can increase the transaction count to |
@norhh I'm puzzled. Doesn't |
Let's take a function:
It's not possible to hit
Where the transaction only ends with Also, the issue with |
Thanks for the explanation. It is definitely a valid argument in the case of source code/bytecode where Mythril may take the state of the contract, after initialization, into account. But in the case of |
You'll have to use |
Thanks regarding
Functions reported even though they are not there:
Do you have an explanation why Mythril reports |
Yes, there was the issue of |
How to add a constraint to the calldata? For example constrain the
|
Hi @aj3423, this is an example of how it is done: mythril/mythril/laser/ethereum/transaction/symbolic.py Lines 99 to 101 in 39b79ca
|
@norhh Thanks, this is really helpful. Btw, maybe this loop can be optimised, currently it's: mythril/mythril/laser/ethereum/transaction/symbolic.py Lines 89 to 102 in 39b79ca
It always generates 4 constraints even with a transaction sequence like
I think it should be:
|
Description:While using Mythril, I encountered an issue similar to one reported above. The problem still persists. When running the following command (address: 0x0aaeb2f7209b5796a3f323dcdf9cc4a7981ec8bf ,func:
I observed incorrect function signature identification in mythril/mythril/disassembler/disassembly.py. Specifically, the jump_table_indices output includes the following:
This indicates that Mythril mistakenly identifies the
Workaround:To address this issue temporarily, I have bypassed the
Proposed Solutions:
@norhh Would it be acceptable for me to submit a PR implementing my workaround or a generalized solution as described above? |
I try to understand how Mythril/Laser traverses the execution traces, with the aim to let it reach the regular end of as many functions as possible. For testing, I added a module
Function
in a filemythril/analysis/module/modules/function.py
, see below for the code. Its purpose is to report the name of the current function when reaching its regular end (RETURN
). I run it aswhere
ShieldController.hex
is the contract creation code at https://etherscan.io/address/0x860b3913e248e6ba352120d550567379cb48fdd6#code.The expected output are the functions listed by
solc --optimize --hashes ShieldController.sol
for contractShieldController
. However, the call above just reports theconstructor
and a functiontransferFrom(address,address,uint256)
, which does not occur inShieldController
, but seems to be a function in a contract deployed byShieldController
.Which settings are needed for Mythril/Laser (like
max-depth
,loop-bound
,call-depth-limit
,transaction-count
and the search strategy) such that it analyzes the main branches of all (or most) functions until their finalRETURN
? In the intended application, reachingRETURN
will trigger checks for that function.Contents of
mythril/analysis/module/modules/function.py
:In
mythril/analysis/module/loader.py
, I addedThe text was updated successfully, but these errors were encountered: