Skip to main content

What Would Be the Vulnerable Code Structure That Violates the CEI Pattern?

A vulnerable code structure violates CEI by performing the external interaction before the state change. For example, a withdrawal function that first sends the Ether ( msg.sender.call{value: amount}("") ) and then updates the user's balance ( balance = 0 ) is vulnerable.

The attacker's fallback function is executed during the external call, allowing them to re-enter and withdraw again before the balance is zeroed.

What Specific Code Vulnerability in the DAO Contract Allowed the Reentrancy?
What Is the Checks-Effects-Interactions Pattern and How Does It Prevent Reentrancy?
Provide an Example of How Two Functions Might Share a State That Could Be Exploited
Why Is Updating State before an External Call the Critical Part of the CEI Pattern?