The redeemWToken function on line 224 in the contract IAaveDIVAWrapper.sol accepts a wToken and allows its redemption into the collateral token, but there is no explicit check to ensure that the wToken is valid and registered before redemption.
If an unsupported or malicious wToken is provided, the contract might malfunction, or unexpected behavior could arise.
Potential loss of funds if malicious tokens are used, or the function could revert.
redeemWToken"Overview
The function redeemWToken in the AaveDIVAWrapperCore.sol contract allows users to redeem wrapped tokens (wToken) into the collateral token. However, there is no check to ensure that the wToken provided is supported, i.e., it's associated with a valid collateral token. This absence of a validation check could lead to unexpected behavior or fund loss if the user attempts to redeem an unsupported wToken.
Actors
Attacker: An attacker who attempts to redeem an unsupported wToken.
Victim: A user who may unknowingly interact with unsupported or malicious wToken.
Protocol: The AaveDIVAWrapperCore.sol contract.
Working Test Case
We will create a malicious contract to simulate an unsupported wToken. The test will show how redeeming this unsupported token might lead to unexpected behavior or a failed transaction.
Deploy the MaliciousWToken contract: This contract simulates an unsupported wToken (MaliciousWToken).
The MaliciousWToken contract behaves like a standard ERC20 token but isn't registered or supported in the AaveDIVAWrapperCore.sol contract.
Deploy the Attacker contract: This contract simulates the attacker who will attempt to redeem the unsupported wToken.
The attacker deploys the Attacker contract, passing the address of the AaveDIVAWrapperCore.sol contract and the MaliciousWToken address.
Attack execution: The attacker calls the attack() function in the Attacker contract, which:
Transfers a specified amount of MaliciousWToken to the AaveDIVAWrapperCore.sol contract.
Attempts to redeem the unsupported MaliciousWToken via the redeemWToken function.
Expected Outcome: Since the redeemWToken function does not validate whether the wToken is supported, the contract could:
Fail silently, reverting the transaction without any explanation, or
If improperly handled, it may allow an invalid token redemption.
Implications:
The user or attacker may attempt to redeem unsupported tokens, which could lead to the funds being lost or an unexpected behavior.
It highlights the lack of validation, which could compromise user funds and contract integrity.
Manual code review
Validation Check: Add a check to ensure that the wToken provided in the redeemWToken function is registered and associated with a supported collateral token. This could be done by checking a list of valid tokens stored in the contract.
Testing & Auditing: Make sure to thoroughly test edge cases where tokens may be malformed or unexpected. Proper validation in critical functions is crucial for maintaining the security and integrity of the contract.
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.