Here are three specific DeFi smart contract vulnerabilities commonly identified in security audits, described with technical precision suitable for an audit report.
1. Reentrancy via Unprotected State Updates
Vulnerability Type: Reentrancy
Severity: High
Affected Component: Token Withdrawal Function (withdraw())
Description:
The contract allows users to withdraw their deposited assets. The implementation follows the "interaction before state update" pattern, where the external call to transfer tokens to the user occurs before the internal state variable tracking the user's balance is updated to zero.
Exploit Mechanism:
If the user is an attacker-controlled contract, the receive() or onERC20Conformance() hook can be triggered during the token transfer. Within this hook, the attacker can re-enter the withdraw() function. Because the state variable (userBalances[attacker]) has not yet been decremented, the contract still believes the
Top comments (0)