Skip to content
Business logic Audit finding Intermediate

AuraSpell#closePositionFarm will take reward fees on underlying tokens when borrow token is also a reward

The closePositionFarm function in AuraSpell burns the BLP (liquidity provider) tokens before deducting the reward fee. If the borrow token is also a reward token, the fee is taken from the underlying liquidity, causing the user to lose more funds than intended.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-07-blueberry-judging/issues/103

Found by

0x52

AuraSpell#AuraSpell#closePositionFarm will take reward fees on underlying tokens when borrow token is also a reward. This is because the BLP is burned before taking the reward cut.

Vulnerability Detail

AuraSpell.sol#L227-L247

            wAuraPools.getVault(lpToken).exitPool(
                IBalancerPool(lpToken).getPoolId(),
                address(this),
                address(this),
                IBalancerVault.ExitPoolRequest(
                    tokens,
                    minAmountsOut,
                    abi.encode(0, amountPosRemove, borrowTokenIndex),
                    false
                )
            );
        }
    }

    /// 4. Swap each reward token for the debt token
    uint256 rewardTokensLength = rewardTokens.length;
    for (uint256 i; i != rewardTokensLength; ) {
        address sellToken = rewardTokens[i];
        if (sellToken == STASH_AURA) sellToken = AURA;

        _doCutRewardsFee(sellToken);

We can see above that closePositionFarm redeems the BLP before it takes the reward cut. This can cause serious issues. If there is any overlap between the reward tokens and the borrow token then _doCutRewardsFee will take a cut of the underlying liquidity. This causes loss to the user as too many fees are taken from them.

Impact

User will lose funds due to incorrect fees

Code Snippet

AuraSpell.sol#L184-L265

Tool used

Manual Review

Recommendation

Use the same order as ConvexSpell and sell rewards BEFORE burning BLP

The original report as published on Sherlock, by 0x52. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 contract burns the BLP tokens before deducting the reward fee, so the fee is applied to the underlying liquidity when the borrow token is also a reward token.

Impact

Users could lose funds because the fee is taken from their underlying liquidity instead of only from rewards.

What the attacker needed

Borrow token is also a reward token

The fix

The reward fee should be taken before burning the BLP tokens, following the same order as ConvexSpell.

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 you close a leveraged position, the contract first returns your liquidity pool tokens and then takes a fee from the reward tokens. If the token you borrowed is also a reward token, the fee is incorrectly taken from your own deposited funds, so you get less back than you should.

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.

More by 0x52

View all

211 more disclosed reports, best first.

More from Blueberry Update #3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.