Reentrancy Attacks
CVSS 9.8 CriticalReentrancy remains one of the most devastating smart contract vulnerabilities, responsible for some of the largest DeFi exploits in history, including the infamous DAO hack. The vulnerability occurs when a contract makes an external call before updating its internal state.
Real-World Example
A lending protocol in the Bay Area DeFi ecosystem was found to have a reentrancy vulnerability in its liquidation function. An attacker could recursively call the liquidation function, draining the contract's ETH balance before the internal accounting was updated.
Prevention Strategies
- 01Follow the Checks-Effects-Interactions (CEI) pattern in all external calls
- 02Use OpenZeppelin's ReentrancyGuard modifier for critical functions
- 03Implement mutex locks for state-changing operations with external calls
- 04Use pull-payment patterns instead of push-payment where possible