Summary
The AaveDIVAWrapperCore
and AaveDIVAWrapper
contracts assume ERC20 compliance for collateral tokens, failing to account for the reentrancy behavior introduced by ERC777 tokens through tokensReceived
and tokensToSend
hooks. This vulnerability allows attackers to exploit reentrancy during critical operations, such as token registration and liquidity management, resulting in fund drainage, manipulated state variables, and collateral locking.
This report provides a detailed analysis, attack scenarios, and a validated Proof of Concept (PoC) demonstrating the exploitability of the issue.
The contracts do not validate the token standard during registration and fail to safeguard against hooks triggered by ERC777 tokens. Specifically:
Lack of Standard Verification: Functions such as _registerCollateralToken
do not confirm that tokens comply strictly with ERC20.
Unprotected Token Transfers: Functions like batchAddLiquidity
and batchRedeemPositionToken
interact with tokens without mitigating reentrancy triggered by ERC777 hooks.
Vulnerable Code:
This function iterates over an input array and transfers tokens without mitigating reentrancy risks triggered by malicious ERC777 hooks.
Deploy a malicious ERC777 token overriding the tokensReceived
hook.
Register this malicious token as collateral using registerCollateralToken
.
Trigger the batchAddLiquidity
function, initiating a token transfer.
The malicious token’s tokensReceived
hook re-enters the function, manipulating internal state or triggering unauthorized actions.
Impact:
Fund Drainage: Unauthorized withdrawal of collateral or yields.
Collateral Locking: Disruption of liquidity management, leaving collateral inaccessible to legitimate users.
The ERC777 token overrides the tokensReceived
hook to re-enter the vulnerable function.
Call the registerCollateralToken
function to register the malicious token as collateral.
Trigger the batchAddLiquidity
function with a payload designed to manipulate state variables during the reentrancy.
The malicious token triggers its tokensReceived
hook during the batchAddLiquidity
function.
The hook re-enters the function, allowing the attacker to:
Manipulate state variables (e.g., bypassing collateral checks).
Execute unauthorized fund transfers.
The attacker successfully drains collateral by bypassing standard checks.
Internal state variables are manipulated, causing protocol inconsistencies.
Fund Drainage:
Exploited reentrancy allows attackers to withdraw funds unauthorizedly.
Collateral Locking:
Malicious operations disrupt liquidity management, locking user funds.
Protocol Instability:
Manipulated state variables lead to inconsistent and unpredictable protocol behavior.
Verify token compliance during registration:
Protect functions interacting with tokens using ReentrancyGuard
:
Use low-level calls or OpenZeppelin’s IERC20
interface to bypass hooks:
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.