The function claimYield on line 237 in IAaveDIVAWrapper.sol contract allows the owner of the contract to claim accrued yield, but there may be scenarios where the contract owner could be compromised, leading to unauthorized claims.
If the owner’s private key is compromised, the attacker could withdraw all the accrued yield, which might be significant.
The function does not include additional access controls or multi-sig mechanisms to ensure the action is authorized.
If the owner is compromised, an attacker can withdraw all the funds (yield).
The claimYield function in the contract allows the contract owner to claim accrued yield, but without any further restrictions. This PoC demonstrates how an attacker could claim yield if they gain control of the owner’s account (private key).
Attacker: An unauthorized user trying to claim the yield.
Victim: The legitimate contract owner (or whoever has access to the function).
Protocol: The contract that manages the yield claims.
Deploy Contract: Deploy a contract that implements the claimYield function.
Compromise the Owner: The attacker obtains control over the contract owner's private key.
Claim Yield: The attacker calls claimYield to steal yield.
Test Case to Demonstrate Attack:
Initial Setup: The contract is deployed, and the owner funds the contract with 10 ether. The claimYield function allows only the owner to claim the yield.
Compromise: The attacker somehow gains control of the owner's private key (e.g., via a phishing attack, keylogger, or other methods).
Attack: The attacker then connects to the contract as the owner (since they control the owner's private key) and calls claimYield. The attacker successfully withdraws the yield (10 ether) from the contract, even though they are not the legitimate owner.
Outcome: The attacker now holds the yield that should have gone to the legitimate owner.
The attacker can claim the yield intended for the contract owner if they compromise the owner’s private key.
This could result in the loss of funds and trust in the protocol.
Without proper access control, an attacker can exploit the function by pretending to be the owner.
To mitigate this vulnerability, consider the following:
Multi-sig Wallet: Use a multi-sig wallet to require multiple signers before any yield can be claimed.
Role-Based Access Control (RBAC): Implement role-based access control using OpenZeppelin’s AccessControl to manage permissions for claiming yield.
Delay Mechanisms: Implement a time-lock mechanism where yield claims require a delay, reducing the risk of immediate exploitation after a private key compromise.
For example, using AccessControl from OpenZeppelin:
By using the AccessControl contract, only addresses with the OWNER_ROLE can claim the yield, preventing unauthorized users from doing so.
Manual code review
Consider adding additional layers of access control, such as a multi-sig wallet for yield claim or a time-lock mechanism that requires a delay for sensitive operations.
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.