AuraVault::claim reward calculation does not deduct fees from reward amount, causing DoS or extra rewards lost
The AuraVault claim function sends a fee percentage of rewards to the locker but then sends the full reward amount to the caller, so the contract can either run out of tokens and revert or pay out more than intended. An attacker could exploit this to take rewards that belong to others or cause a denial of service.
crypticdefense Follow with Agontuk and mrMorningstar
Originally disclosed on Code4rena
Submitted by crypticdefense, also found by Agontuk and mrMorningstar
AuraVault::claim allows users to claim rewards corresponding to the amount of WETH they are depositing in the same call.
Prior to sending rewards to msg.sender, a percentage of the rewards is sent to the vault locker rewards. However, the percentage of the rewards sent to the vault locker rewards is not deducted from the amount that is sent to the caller. The entire reward amount is sent to msg.sender.
This is problematic, as it creates two possible scenarios:
- Contract attempts to send more reward tokens than it holds, causing DoS.
- Contract successfully sends extra reward tokens, essentially stealing rewards from others.
Therefore, the impact ranges from stolen funds to Denial of Service.
Proof of Concept
As users interact with the AuraVault contract, the contract will accumulate rewards through interaction with an external rewards contract, which acts as an ERC-4626 vault.
Users can deposit, withdraw, redeem, and claim rewards:
/**
* @notice Allows anyone to claim accumulated rewards by depositing WETH instead
* @param amounts An array of reward amounts to be claimed ordered as [rewardToken, secondaryRewardToken]
* @param maxAmountIn The max amount of WETH to be sent to the Vault
*/
function claim(uint256[] memory amounts, uint256 maxAmountIn) external returns (uint256 amountIn) {
// Claim rewards from Aura reward pool
IPool(rewardPool).getReward();
// Compute assets amount to be sent to the Vault
VaultConfig memory _config = vaultConfig;
amountIn = _previewReward(amounts[0], amounts[1], _config);
// Transfer assets to Vault
require(amountIn <= maxAmountIn, "!Slippage");
IERC20(asset()).safeTransferFrom(msg.sender, address(this), amountIn);
// Compound assets into "asset" balance
IERC20(asset()).safeApprove(rewardPool, amountIn);
IPool(rewardPool).deposit(amountIn, address(this));
// Distribute BAL rewards
@> IERC20(BAL).safeTransfer(_config.lockerRewards, (amounts[0] * _config.lockerIncentive) / INCENTIVE_BASIS);
@> IERC20(BAL).safeTransfer(msg.sender, amounts[0]);
// Distribute AURA rewards
if (block.timestamp <= INFLATION_PROTECTION_TIME) {
@> IERC20(AURA).safeTransfer(_config.lockerRewards, (amounts[1] * _config.lockerIncentive) / INCENTIVE_BASIS);
@> IERC20(AURA).safeTransfer(msg.sender, amounts[1]);
} else {
// after INFLATION_PROTECTION_TIME
IERC20(AURA).safeTransfer(_config.lockerRewards, IERC20(AURA).balanceOf(address(this)));
}
emit Claimed(msg.sender, amounts[0], amounts[1], amountIn);
}
Firstly, rewards are claimed from the Aura reward pool, proceeded by a call to _previewReward() to calculate the amount of WETH the caller must deposit to receive the amount of rewards they have specified.
The issue is with the transferring of rewards. We can see the vault locker rewards receives a percentage of the rewards, calculated by (amounts[0] * _config.lockerIncentive) / INCENTIVE_BASIS).
However, the entire amount of rewards is still sent to the caller, without accounting for the percentage that was just sent to the vault locker rewards. Therefore, this call is sending extra rewards to the caller.
As mentioned, this leads to two scenarios:
- DoS due to insufficient rewards.
- Extra rewards successfully sent to the caller, essentially stealing rewards from others.
Consider the following scenario:
- Alice decides to deposit
WETHand claimBALandAURArewards via a call toAuraVault::claim._config.lockerIncentiveis set to 1000 andINCENTIVE_BASISis set to 10000, effectively setting the fee portion to 10%. - Alice sets
amounts[0] = 100e18 BALandamount[1] = 100e18 AURA. IPool(rewardPool).getReward();is called, setting the rewards held in theAuraVaultcontract to100e18 BALand100e18 AURA.IERC20(BAL).safeTransfer(_config.lockerRewards, (amounts[0] * _config.lockerIncentive) / INCENTIVE_BASIS);call sends100e18 * 1000 / 10000 = 10e18BALtokens to_config.lockerRewards, which is thevault locker rewards.- The
AuraVaultcontract now holds90e18 BALand100e18 AURA. IERC20(BAL).safeTransfer(msg.sender, amounts[0]);attempts to send100e18 BALtomsg.sender; however,10e18was already sent tolocker rewards, so this call will DoS due to insufficient funds.
The call will revert in the case described above, and Alice would have to specify a lower amount of rewards (i.e., 50e18 BAL and AURA), but we can see that the contract will still send more rewards than intended, effectively stealing rewards from others.
Tools Used
Foundry
Recommended Mitigation Steps
Ensure the amount sent to the locker is deducted from the amount sent to the caller:
/**
* @notice Allows anyone to claim accumulated rewards by depositing WETH instead
* @param amounts An array of reward amounts to be claimed ordered as [rewardToken, secondaryRewardToken]
* @param maxAmountIn The max amount of WETH to be sent to the Vault
*/
function claim(uint256[] memory amounts, uint256 maxAmountIn) external returns (uint256 amountIn) {
// Claim rewards from Aura reward pool
IPool(rewardPool).getReward();
// Compute assets amount to be sent to the Vault
VaultConfig memory _config = vaultConfig;
amountIn = _previewReward(amounts[0], amounts[1], _config);
// Transfer assets to Vault
require(amountIn <= maxAmountIn, "!Slippage");
IERC20(asset()).safeTransferFrom(msg.sender, address(this), amountIn);
// Compound assets into "asset" balance
IERC20(asset()).safeApprove(rewardPool, amountIn);
IPool(rewardPool).deposit(amountIn, address(this));
// Distribute BAL rewards
+ uint256 fee = (amounts[0] * _config.lockerIncentive) / INCENTIVE_BASIS;
+ uint256 amount = amounts[0] - fee;
- IERC20(BAL).safeTransfer(_config.lockerRewards, (amounts[0] * _config.lockerIncentive) / INCENTIVE_BASIS);
- IERC20(BAL).safeTransfer(msg.sender, amounts[0]);
+ IERC20(BAL).safeTransfer(_config.lockerRewards, fee);
+ IERC20(BAL).safeTransfer(msg.sender, amount);
// Distribute AURA rewards
if (block.timestamp <= INFLATION_PROTECTION_TIME) {
+ fee = (amounts[1] * _config.lockerIncentive) / INCENTIVE_BASIS;
+ amount = amounts[1] - fee;
- IERC20(AURA).safeTransfer(_config.lockerRewards, (amounts[1] * _config.lockerIncentive) / INCENTIVE_BASIS);
- IERC20(AURA).safeTransfer(msg.sender, amounts[1]);
+ IERC20(BAL).safeTransfer(_config.lockerRewards, fee);
+ IERC20(BAL).safeTransfer(msg.sender, amount);
} else {
// after INFLATION_PROTECTION_TIME
IERC20(AURA).safeTransfer(_config.lockerRewards, IERC20(AURA).balanceOf(address(this)));
}
emit Claimed(msg.sender, amounts[0], amounts[1], amountIn);
}
Assessed type
Error
amarcu (LoopFi) acknowledged and commented via duplicate issue #206:
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
The code transfers the locker incentive to the locker but then transfers the full reward amount to the caller without subtracting that incentive.
Impact
The contract may revert due to insufficient rewards, causing a denial of service, or it may successfully send extra rewards to the caller, effectively stealing rewards from others.
What the attacker needed
User can call claim with reward amounts; contract holds reward tokens
The fix
The amount sent to the locker should be deducted from the amount sent to the caller, as shown in the recommended mitigation.
How it was found
- Alice calls AuraVault::claim with reward amounts and a max WETH amount.
- The contract calls getReward on the reward pool to pull in BAL and AURA rewards.
- The contract sends a percentage of the BAL and AURA rewards to the locker rewards address.
- The contract then tries to send the full original reward amounts to Alice, which can revert if the contract no longer holds enough tokens.
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.
When someone claims rewards, the contract first takes a small cut for the vault's locker and then should send the rest to the user. Instead, it sends the full amount to the user as well, so the contract pays out more than it has. This can make the claim fail or let someone take rewards that should have gone to others.
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.