solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Explained Checks-Effects-Interactions and added info on Checks-Effects-Events-Interactions

Open lukehutch opened this issue 3 years ago • 2 comments

lukehutch avatar Jun 25 '22 23:06 lukehutch

Small tweak: "makes" (twice in the first paragraph) should read "make"

lukehutch avatar Jun 25 '22 23:06 lukehutch

I can't speak for the correctness of the content, but to get your CI tests fixed you need to rebase on our latest develop. Further, please amend the commits into one (I see a merge commit)

Marenz avatar Jun 30 '22 15:06 Marenz

@leonardoalt it's a dangerous precedent though to say to your users "you can use this, but you have to be smarter than your potential attackers at reasoning your way through a complex set of logic that proves than any state they can manipulate in the middle of a transaction will ultimately have no negative effect on any user". Far better to make a blanket statement that calling any contract before state is finalized is extremely likely to open you to security vulnerabilities, which it is, and that these security vulnerabilities have lost hundreds of millions of dollars for victims, which they have.

lukehutch avatar Aug 15 '22 14:08 lukehutch

@leonardoalt it's a dangerous precedent though to say to your users "you can use this, but you have to be smarter than your potential attackers at reasoning your way through a complex set of logic that proves than any state they can manipulate in the middle of a transaction will ultimately have no negative effect on any user". Far better to make a blanket statement that calling any contract before state is finalized is extremely likely to open you to security vulnerabilities, which it is, and that these security vulnerabilities have lost hundreds of millions of dollars for victims, which they have.

Sure, I haven't advocated for that at all. What I disagree with is the imprecise wording in the particular line I commented. I'm all for recommending CEIs, but it is simply incorrect to say that this is the only way.

leonardoalt avatar Aug 15 '22 15:08 leonardoalt

OK, I understand your point better now. Thanks for the feedback.

My main reasons for creating this PR is that the current wording is a bit too weak -- users need to know what a huge source of potential vulnerabilities it is to call external contracts before finalizing state -- and also to point out that events should also only be emitted after finalizing state, because otherwise it is possible to trick 3rd parties into believing false things about the final state of the contract after the transaction. (This latter point is raised almost nowhere.)

I'm happy for my suggestion to be completely rewritten, taking these points into account. Unfortunately I don't have bandwidth for this, I was just trying to be helpful by submitting a ready-made change.

lukehutch avatar Aug 15 '22 16:08 lukehutch

Sounds good, thanks for it. If you don't mind then someone from the team will rewrite some of the wording and we'll bring it up in the call whether we want to have a section for CEIs.

leonardoalt avatar Aug 15 '22 17:08 leonardoalt

Please go ahead, thanks. You can close this PR whenever somebody writes something better!

lukehutch avatar Aug 15 '22 18:08 lukehutch

We'll just try to keep this PR and adjust on top of it.

leonardoalt avatar Aug 15 '22 19:08 leonardoalt

I tried pushing my changes directly to the given repo/branch, which is usually possible when external contributors make PRs to this repo, but this was not possible. So I made another branch/PR: https://github.com/ethereum/solidity/pull/13457 (keeping author's credit) and am closing this one.

leonardoalt avatar Aug 30 '22 10:08 leonardoalt