AuraSpell#openPositionFarm fails to return all rewards to user
When a user adds to an existing position on AuraSpell, the contract burns the old position and mints a new one, but only refunds Aura tokens to the user while other reward tokens sent to the contract are lost. An attacker could not directly exploit this, but the user loses all extra reward tokens from their original position.
0x52 Follow with nobody2018
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-05-blueberry-judging/issues/29
Found by
0x52, nobody2018
Summary
When a user adds to an existing position on AuraSpell, the contract burns their current position and remints them a new one. The issues is that WAuraPool will send all reward tokens to the contract but it only sends Aura back to the user, causing all other rewards to be lost.
Vulnerability Detail
for (uint i = 0; i < rewardTokens.length; i++) {
IERC20Upgradeable(rewardTokens[i]).safeTransfer(
msg.sender,
rewards[i]
);
}
Inside WAuraPools#burn reward tokens are sent to the user.
IBank.Position memory pos = bank.getCurrentPositionInfo();
if (pos.collateralSize > 0) {
(uint256 pid, ) = wAuraPools.decodeId(pos.collId);
if (param.farmingPoolId != pid)
revert Errors.INCORRECT_PID(param.farmingPoolId);
if (pos.collToken != address(wAuraPools))
revert Errors.INCORRECT_COLTOKEN(pos.collToken);
bank.takeCollateral(pos.collateralSize);
wAuraPools.burn(pos.collId, pos.collateralSize);
_doRefundRewards(AURA);
}
We see above that the contract only refunds Aura to the user causing all other extra reward tokens received by the contract to be lost to the user.
Impact
User will lose all extra reward tokens from their original position
Code Snippet
Tool used
Manual Review
Recommendation
WAuraPool returns the reward tokens it sends. Use this list to refund all tokens to the user
Discussion
sleepriverfish
Escalate for 10 USDC. The issue was excluded from #Blueberry Update, it appears to have been rewarded in #Blueberry Update 2. https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/42
sherlock-admin
Escalate for 10 USDC. The issue was excluded from #Blueberry Update, it appears to have been rewarded in #Blueberry Update 2. https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/42
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
securitygrid
Escalate for 10 USDC valid H. Nobody escalated it
sherlock-admin
Escalate for 10 USDC valid H. Nobody escalated it
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
IAm0x52
Agreed with second escalation
sleepriverfish
So, the issue https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/42 considered invalid? I believe it should be categorized and rewarded in some way.
hrishibhat
Escalation rejected
Valid high The issue mentioned above has been resolved accordingly in the respective contest.
sherlock-admin
Escalation rejected
Valid high The issue mentioned above has been resolved accordingly in the respective contest.
This issue's escalations have been rejected!
Watsons who escalated this issue will have their escalation amount deducted from their next payout.
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 contract only refunds the Aura token after burning the position, ignoring other reward tokens that were transferred to it.
Impact
User will lose all extra reward tokens from their original position.
What the attacker needed
User has an existing position on AuraSpell; user adds to that position
The fix
The contract should use the list of reward tokens returned by WAuraPool to refund all tokens to the user.
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.
This is a smart contract bug where a user's rewards are lost when they add to an existing farming position. The contract receives multiple types of reward tokens but only returns one type (Aura) to the user, keeping the rest stuck in the contract.
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.