-
Notifications
You must be signed in to change notification settings - Fork 64
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
Flow analysis + memory modeling #39
Comments
Hi Sebastian, and thanks for the kind words. As for the memory de-aliasing, I'm not sure I follow the suggestion, because I had thought that this is exactly what the "free pointer is unchanged" predicates are used for already. But I haven't looked in a long while, and we'd love to work more on this direction, anyway. Do you have specific examples of contracts/bytecode patterns where you think the decompiler should understand aliases a lot more? Thanks! |
Thank you Yannis! One of the simplest examples I can think of is the one to detect when a call uses a static function signature:
As you mention, "free pointer is unchanged" is a good way of improving this analysis but I'm confused of why it's not used in the different flow analysis passes. My idea was to re-implement (or expand) one of the flows passes with memory modeling and pointer aliasing. I see that this was baked in the symvalic analysis to some extent so I'd like your input on if this is even a good idea or if you have a pointer to what would be a good way of implementing it? |
Hi Sebastian, As Yannis said we haven't added data flows through memory to the main If I were to make a flows component that tracked data flow through memory I'd do it adding more base case Thanks, |
Thank you Sifis, The reason for having the pointer aliasing information in the flow analysis is that I needed to track what's going in the calldata array (to be passed to other functions). I see that solidity does something like
without tracking those aliases (var1 and var2) and memcpy (from var1/var2 to var3) information gets lost. So far only added these constructs to my poor man flow analysis which isn't precise but helps me track what is going into external calls. On a side note, I think this information could also augment the decompilation used by contract-library which tends to have lots of MEM[64] without variable bindings. |
Hi, first I'd like to thank you for making gigahorse open source. It's an amazing research project and tool. This is not a concrete issue but more of a brain dump with which am looking for ideas.
I've been using gigahorse to write rules to experiment with known bugs and found a limitation at the time of making flow analysis (both using clientlib and symvalic).
To me it looks like the main issue is that the analysis passes don't tend to make a lot of use of the memory modeling module so data flowing through the memory gets "lost". Even after adding relations to improve the memory modeling (specially around
MemoryCopyLoop
) for the latest solidity versions (0.7, 0.8), the flow analysis tend to be limited to statement uses and defines.So my question is what do you think it would be a good way to augment the flow analysis passes with memory modeling? I was thinking of adding more more "Array/Tuple/Memory Contents" relations to DataFlows/VarMayBe but I may be missing context on why this is the way it is.
And the other is, have you considered or have thoughts about making a "de-aliasing" pass? I haven't given it too much thought but it looks to me like something as basic as merging aliases with
MLOADSFreePtrUnchanged
would normalize all the array/tuple access and make the other passes much easier to follow (I'm aware of the symbolic array equivalence but don't think that's used for flow anal). On the other hand, I think, some information could be lost in the process (RawDataArray
->AbiArray
, etc) or completely fail if the modeling is inaccurate.Also, do you hang out in any messaging platform (Discord or other) to discuss gigahorse and evm/solidity?
The text was updated successfully, but these errors were encountered: