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

'noreentrancy' flag #2619

Closed
mezrin opened this issue Jul 21, 2017 · 6 comments
Closed

'noreentrancy' flag #2619

mezrin opened this issue Jul 21, 2017 · 6 comments

Comments

@mezrin
Copy link

mezrin commented Jul 21, 2017

There are really many attacks that use reentrancy. It would be amazing to have a modifier for functions noreentrancy. Just like constant

If function marked with this flag and called twice in one transaction - exception was thrown

It is even better to break backwards compatibility and make this flag default for all public functions. I.e.:

  • by default public functions are not allow reentrancy
  • a public function can be marked with 'reentrant'
@federicobond
Copy link
Contributor

Keep in mind that reentrancy is different from calling a function twice. There is usually nothing wrong with the latter.

Also, should the reentrancy guard lock the whole contract or just that particular function? It may be safer (and cheaper) to do the first, to better protect contract invariants.

@roadriverrail
Copy link
Contributor

roadriverrail commented Jul 21, 2017 via email

@mezrin
Copy link
Author

mezrin commented Jul 21, 2017

Keep in mind that reentrancy is different from calling a function twice. There is usually nothing wrong with the latter.

I think people should start to write better contracts. And implement business-logic in internal functions. In this case, we can do smth like this:
The public function of a contract called -> contract does smth, make a call to external contract / transfer ETH -> calls to public functions of this contract become prohibited, even if they performed from inside the contract as an internal call.

It should be easier to implement and it is quite straightforward security model.

Also, should the reentrancy guard lock the whole contract or just that particular function? It may be safer (and cheaper) to do the first, to better protect contract invariants.

I think some use-cases require reentrancy and we need to have function-level modifiers that allow this. In this case, this is up to the developer to implement needed security measures

@axic
Copy link
Member

axic commented Jul 21, 2017

This has been discussed twice in #656 and #662, things may have changed since, but it is perhaps worth reading those two threads.

@EricR
Copy link

EricR commented Jul 23, 2017

I want to point out that this issue is also being addressed in EIP 214, which adds a new opcode aptly named STATICCALL.

@chriseth
Copy link
Contributor

I don't think it is beneficial to the discussion to keep this issue open. Please discuss on the other two issues and be advised that "noreentrancy" does not have to be a language feature.

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

6 participants