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

Prevent common & tricky bugs at compile time #519

Open
WilfredTA opened this issue Aug 23, 2021 · 2 comments
Open

Prevent common & tricky bugs at compile time #519

WilfredTA opened this issue Aug 23, 2021 · 2 comments

Comments

@WilfredTA
Copy link
Contributor

What is wrong?

There are many classes of bugs and unexpected behaviors that can occur in smart contracts. There are many resources cataloguing and classifying these. There is also available research on how to prevent them with proper design patterns in languages such as Solidity as well as on experimental languages that prevent them with different type systems. It is currently only partially defined what Fe's type system is. It is also unclear which classes of errors or unexpected (but non-erroneous though non-desirable) behaviors that are prevented by Fe.

How can it be fixed

We should skim available research and compile a history of notable so-called "smart contract hacks". Then, we should identify how these problems can be reduced to statically detectable patterns and/or type errors, which we can then incorporate into Fe's compile-time analysis and type checking.

In many ways, smart contract execution is similar to a single threaded concurrent program. Therefore, some of the more sophisticated issues that appear in smart contract systems are potentially resolved by principles similar to those employed by compiled languages that are meant to provide strong protection against concurrency bugs.

@cburgdorf
Copy link
Collaborator

Just to add a concrete example based on a recent vulnerability in SushiSwap that is explained in detail here

The specific issue of using msg.value in a loop that performs a mutation could be abstracted as some combination of lifetimes + mutability. A naive and potentially overly restrictive concept would be "values that last longer than current scope can only be read once by functions with side effects.

@g-r-a-n-t
Copy link
Member

Sigp's solidity security blog is a pretty good resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants