Skip to main content

What Specific Code Vulnerability in the DAO Contract Allowed the Reentrancy?

The vulnerability was in the DAO's splitDAO function, which was used to withdraw funds. The code first checked the user's balance, then performed an external call to send the user their Ether ( msg.sender.call.value() ), and only after that did it update the internal ledger to reflect the withdrawal.

This violated the Checks-Effects-Interactions pattern. By making the external call before updating the state, it opened the door for the attacker to recursively call the function and withdraw the same funds repeatedly before the balance was set to zero.

What Is a Reentrancy Attack in Smart Contracts?
How Do Solidity Modifiers like Nonreentrant Implement the CEI Principle?
Why Is Updating State before an External Call the Critical Part of the CEI Pattern?
If a User Has an Allowance of 100 Tokens and a Balance of 50, What Is the Maximum the Contract Can Pull?