The contract AaveDIVAWrapper contains functions approveCollateralTokenForAave and batchApproveCollateralTokenForAave that allow anyone to approve collateral tokens for the Aave protocol. This lack of proper access control poses a significant risk, as any user can call these functions and potentially manipulate collateral approval without authorization.
Vulnerable Functions:
approveCollateralTokenForAave(address _collateralToken)
batchApproveCollateralTokenForAave(address[] calldata _collateralTokens)
Vulnerability:
These functions currently do not include any access control mechanisms such as onlyOwner or any privileged role checks. As a result, any external address (including malicious actors) can call these functions and approve tokens for Aave. This could potentially lead to unauthorized token approvals, allowing users to interact with the Aave protocol in unintended ways.
The root cause of this issue is the absence of access control restrictions on critical functions that interact with external protocols. Functions like approveCollateralTokenForAave should only be callable by trusted addresses (e.g., the owner or a designated privileged role) to avoid abuse.
https://github.com/Cyfrin/2025-01-diva/blob/main/contracts/src/AaveDIVAWrapper.sol#L202
Token Manipulation Risk:
Any attacker could call the approveCollateralTokenForAave or batchApproveCollateralTokenForAave functions, potentially approving tokens for Aave and allowing them to use these tokens in the system maliciously.
Unauthorized Access to Aave Protocol:
Unauthorized users could approve tokens for use in liquidity pools, leading to the possibility of financial exploits and loss of funds by the legitimate contract owner or users.
Loss of Reputation:
If this vulnerability is exploited, the reputation of the project could be severely damaged. Trust from users and investors could be undermined.
Static Analysis Tools:
MythX
Slither
Securify
Manual Review:
Code inspection to identify logical flaws and access control issues.
Scenario:
Suppose an attacker knows the contract's address and the collateral token's address. They can directly call the approveCollateralTokenForAave function and approve any token they choose for Aave without any authorization check.
The attacker could invoke the function as follows:
This would allow the attacker to approve tokens without any validation.
Batch Approval:
Similarly, with batchApproveCollateralTokenForAave, an attacker could approve multiple tokens for Aave, thereby bypassing security and exposing the system to potential financial exploitation.
To fix this vulnerability, the following steps are recommended:
Access Control:
Implement access control modifiers, such as onlyOwner or a specific role-based restriction, to ensure that only authorized addresses can call these functions.
Example code for access control:
Role-based Access Control:
For more flexibility, integrate the AccessControl contract from OpenZeppelin to manage privileged roles dynamically.
Example:
The lack of access control on critical functions like approveCollateralTokenForAave and batchApproveCollateralTokenForAave poses a significant security risk. By implementing appropriate access control mechanisms (e.g., onlyOwner, onlyRole), the contract can be made secure against unauthorized users, mitigating the risk of manipulation and protecting user funds.
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.