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.

Why Is Updating State before an External Call the Critical Part of the CEI Pattern?
What Is the Role of a Fallback Function in Facilitating a Reentrancy Attack?
What Is the Smallest Unit of Ether?
Define a “Reentrancy Attack” in Smart Contracts
How Do Decentralized Exchanges (DEXs) Mitigate Reentrancy Risks in Their Swap Functions?
What Is a Mutex in Traditional Programming, and How Does It Relate to a Reentrancy Guard?
What Is a ‘Reentrancy Attack’ and How Does It Exploit Smart Contract Logic?
How Did the DAO Hack Use a Reentrancy Vulnerability?

Glossar