DeFi Smart Contract Vulnerabilities Audit Guide
Here are three specific DeFi smart contract vulnerabilities suitable for inclusion in a professional audit report. Each entry follows a standard vulnerability reporting structure: Title, Description, Impact, and Recommen
Here are three specific DeFi smart contract vulnerabilities suitable for inclusion in a professional audit report. Each entry follows a standard vulnerability reporting structure: Title, Description, Impact, and Recommended Mitigation.
1. Reentrancy in Callback Functions (CWE-201)
Description:
The withdraw() function in the LiquidityPool contract allows users to claim their liquidity shares. The function performs the following sequence:
- Calculates the userβs balance.
- Sends ETH to the user via
call{value: amount}(_user). - Updates the userβs balance in the internal state variable
balances[_user] = 0.
Because the external call to _user occurs before the state update, a malicious contract can re-enter the withdraw() function during the execution of the receive() or fallback() function. If the external contract calls withdraw() again before
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.