Here are three critical DeFi smart contract vulnerabilities, described with the level of specificity required for a professional security audit report. Each entry includes the vulnerability classification, root cause, impact analysis, and a recommended mitigation strategy.
1. Reentrancy via External Call Before State Update
Vulnerability Class: Reentrancy (CWE-841)
Severity: Critical
Affected Function: withdraw(uint256 _amount) in a staking or lending protocol.
Description:
The withdraw function performs an external call to a user-controlled IERC20 token contract (token.transfer(msg.sender, _amount)) before updating the internal accounting state (userBalances[msg.sender] -= _amount). If the token is a malicious or non-standard ERC-20 implementation, it can re-enter the withdraw function during the execution of transfer by calling back into the protocol. Since the balance has not
Top comments (0)