What is Reentrancy Attack?
A reentrancy attack exploits a smart contract vulnerability where an external call allows the attacker to re-enter the contract before the first execution completes — potentially draining funds by repeating withdrawal logic.
WHY IT MATTERS
Reentrancy is the most famous smart contract vulnerability. The pattern: a contract sends ETH to an address before updating its state. The receiving contract's fallback function re-calls the original contract, which still shows the old (higher) balance. The withdrawal repeats until the contract is drained.
The DAO hack (2016, $60M) was a reentrancy attack that led to Ethereum's most controversial hard fork. Despite being well-known, reentrancy variants continue to cause exploits — cross-function reentrancy, cross-contract reentrancy, and read-only reentrancy.
Prevention: follow the checks-effects-interactions pattern (update state before external calls), use reentrancy guards (mutexes), and consider using pull-over-push payment patterns.