Unclaimed rewards handling issue in AuraVault contract functions ( AuraVault::deposit , AuraVault::mint , AuraVault::withdraw and AuraVault::redeem )
The AuraVault contract's totalAssets() function only returns the balance of the underlying asset in the reward pool and ignores unclaimed rewards. This causes deposit, mint, withdraw, and redeem to calculate shares and assets incorrectly, potentially giving some users an unfair advantage and causing losses to others.
Submitted by Agontuk, also found by 0xc0ffEE
The AuraVault contract is designed to manage assets and distribute rewards from an Aura RewardsPool. The primary functions involved in asset management are deposit(), mint(), withdraw(), and redeem(). These functions rely on the totalAssets() function to calculate the total value of assets managed by the vault. However, the current implementation of totalAssets() does not account for unclaimed rewards, which can lead to incorrect calculations of shares and assets.
The totalAssets() function currently only returns the balance of the underlying asset in the reward pool:
File: AuraVault.sol
175: function totalAssets() public view virtual override(IERC4626, ERC4626) returns (uint256) {
176: return IPool(rewardPool).balanceOf(address(this));
177: }
This function does not include unclaimed rewards, which can be obtained using IPool(rewardPool).earned(address(this)). As a result, the deposit(), mint(), withdraw(), and redeem() functions may calculate shares and assets incorrectly, potentially causing users to receive more or fewer shares/assets than they should.
Impact
The primary impact of this issue is that users may receive an incorrect number of shares or assets due to the inaccurate calculation of totalAssets(). This can lead to financial discrepancies, where some users may gain an unfair advantage while others may suffer losses. The severity of this issue is medium to high, depending on the extent of the financial impact on users. An incorrect totalAssets() value affects the accuracy of the deposit(), mint(), withdraw(), and redeem() functions, leading to an unfair distribution of assets.
Proof of Concept
-
User deposits assets:
- User calls
deposit(1000, receiver). totalAssets()returns 10,000 (current balance in reward pool).previewDeposit(1000)calculates shares based on 10,000 total assets.- Unclaimed rewards of 500 are not included, leading to an incorrect share calculation.
- User calls
-
User mints shares:
- User calls
mint(100, receiver). totalAssets()returns 10,000 (current balance in reward pool).previewMint(100)calculates assets based on 10,000 total assets.- Unclaimed rewards of 500 are not included, leading to an incorrect asset calculation.
- User calls
-
User withdraws assets:
- User calls
withdraw(1000, receiver, owner). totalAssets()returns 10,000 (current balance in reward pool).previewWithdraw(1000)calculates shares based on 10,000 total assets.- Unclaimed rewards of 500 are not included, leading to an incorrect share calculation.
- User calls
-
User redeems shares:
- User calls
redeem(100, receiver, owner). totalAssets()returns 10,000 (current balance in reward pool).previewRedeem(100)calculates assets based on 10,000 total assets.- Unclaimed rewards of 500 are not included, leading to an incorrect asset calculation.
- User calls
Tools Used
Manual review
Recommended Mitigation Steps
To fix this issue, include unclaimed rewards in the totalAssets() calculation:
function totalAssets() public view virtual override(IERC4626, ERC4626) returns (uint256) {
- return IPool(rewardPool).balanceOf(address(this));
+ uint256 unclaimedRewards = IPool(rewardPool).earned(address(this));
+ return IPool(rewardPool).balanceOf(address(this)) + unclaimedRewards;
}
This ensures that the shares and assets are correctly calculated in the deposit(), mint(), withdraw(), and redeem() functions.
amarcu (LoopFi) acknowledged and commented:
Acknowledged, but we will remove and not use the AuraVault.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the totalAssets() function was implemented to only return the reward pool balance and omitted the earned but unclaimed rewards.
Impact
Users may receive an incorrect number of shares or assets, leading to financial discrepancies where some users gain an unfair advantage while others suffer losses; the severity is medium to high depending on the extent of the financial impact.
What the attacker needed
Unclaimed rewards exist in the reward pool
The fix
The totalAssets() function should be updated to include unclaimed rewards by adding IPool(rewardPool).earned(address(this)) to the balance.
How it was found
- User calls deposit(1000, receiver).
- totalAssets() returns 10,000 (current balance in reward pool).
- previewDeposit(1000) calculates shares based on 10,000 total assets.
- Unclaimed rewards of 500 are not included, leading to an incorrect share calculation.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A vault contract lets people deposit assets and receive shares representing their portion. The vault's total value should include all assets it owns, but here it forgot to count rewards that have been earned but not yet claimed. So when people deposit or withdraw, the share price is wrong, and some may get more or less than they deserve.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.