The AaveDIVAWrapper contract applies the nonReentrant modifier to prevent reentrancy attacks. However, multiple state-modifying functions call external functions (such as _addLiquidity, _removeLiquidity, _redeemPositionToken, and _redeemWToken), which may interact with untrusted ERC-20 tokens. This introduces a potential reentrancy risk, as these functions could invoke malicious token contracts that exploit callback mechanisms.
addLiquidity
removeLiquidity
redeemPositionToken
redeemWToken
batchAddLiquidity
batchRemoveLiquidity
batchRedeemPositionToken
batchRedeemWToken
The function calls _addLiquidity, which might interact with untrusted ERC-20 tokens.
If _addLiquidity triggers an external call (e.g., ERC20.transfer), a malicious token can execute a callback function and reenter the contract.
Even though nonReentrant protects addLiquidity, the underlying _addLiquidity function may still allow reentrancy if external calls occur before state updates.
The contract uses the nonReentrant modifier to prevent reentrancy but does not account for external calls made within _addLiquidity, _removeLiquidity, _redeemPositionToken, and _redeemWToken.
ERC-20 tokens with callbacks (e.g., ERC-777 or malicious ERC-20 implementations) can exploit this issue.
If a malicious token's transfer or transferFrom function executes reentrant logic, it may allow an attacker to withdraw more funds than intended.
Fund Drain: A reentrancy attack could allow an attacker to repeatedly withdraw funds before balances update, leading to financial losses.
Logic Corruption: Incomplete state updates may allow attackers to manipulate pool balances or positions.
Denial of Service (DoS): If a malicious token enters an infinite reentrancy loop, it may block other users from interacting with the contract.
Hardhat (for local testing and PoC simulation)
Slither (for static analysis)
Echidna (for fuzz testing)
The following Hardhat test simulates a reentrancy attack using a malicious token contract that exploits addLiquidity.
Ensure that all state changes occur before calling external contracts. Modify _addLiquidity, _removeLiquidity, _redeemPositionToken, and _redeemWToken as follows:
This ensures the contract updates balances before interacting with untrusted tokens.
Instead of relying solely on nonReentrant in public functions, apply reentrancy protection to _addLiquidity, _removeLiquidity, _redeemPositionToken, and _redeemWToken:
Since ERC-777 tokens allow reentrant calls via hooks, add an allowlist for safe ERC-20 tokens or explicitly reject ERC-777 tokens:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.