Skip to content
Business logic Audit finding Intermediate

Adversary can stake LP directly for the vault then withdraw to break lp accounting in BLVaultManagerLido

The AuraRewardPool allows staking LP tokens on behalf of another address, so an attacker can stake LP directly for their vault and then withdraw it, causing the vault manager's total LP accounting to decrease incorrectly. This can permanently trap other users' funds because their withdrawals revert when the manager's total LP becomes too low.

0x52 Follow with carrot, cducrest-brainbot and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-03-olympus-judging/issues/4

Found by

0x52, carrot, cducrest-brainbot, hickuphh3, Bahurum

Summary

The AuraRewardPool allows users to stake directly for other users. In this case the malicious user could stake LP directly for their vault then call withdraw on their vault. This would cause the LP tracking to break on BLVaultManagerLido. The result is that some users would now be permanently trapped because their vault would revert when trying to withdraw.

Vulnerability Detail

BaseRewardPool.sol#L196-L207

function stakeFor(address _for, uint256 _amount)
    public
    returns(bool)
{
    _processStake(_amount, _for);

    //take away from sender
    stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
    emit Staked(_for, _amount);

    return true;
}

AuraRewardPool allows users to stake directly for another address with them receiving the staked tokens.

BLVaultLido.sol#L218-L224

    manager.decreaseTotalLp(lpAmount_);

    // Unstake from Aura
    auraRewardPool().withdrawAndUnwrap(lpAmount_, claim_);

    // Exit Balancer pool
    _exitBalancerPool(lpAmount_, minTokenAmounts_);

Once the LP has been stake the adversary can immediately withdraw it from their vault. This calls decreaseTotalLP on BLVaultManagerLido which now permanently break the LP account.

BLVaultManagerLido.sol#L277-L280

function decreaseTotalLp(uint256 amount_) external override onlyWhileActive onlyVault {
    if (amount_ > totalLp) revert BLManagerLido_InvalidLpAmount();
    totalLp -= amount_;
}

If the amount_ is ever greater than totalLP it will cause decreaseTotalLP to revert. By withdrawing LP that was never deposited to a vault, it permanently breaks other users from being able to withdraw.

Example: User A deposits wstETH to their vault which yields 50 LP. User B creates a vault then stake 50 LP and withdraws it from his vault. The manager now thinks there is 0 LP in vaults. When User A tries to withdraw their LP it will revert when it calls manger.decreaseTotalLp. User A is now permanently trapped in the vault.

Impact

LP accounting is broken and users are permanently trapped.

Code Snippet

BLVaultLido.sol#L203-L256

Tool used

Manual Review

Recommendation

Individual vaults should track how much they have deposited and shouldn't be allowed to withdraw more than deposited.

Discussion

0xLienid

Fix Implementation: https://github.com/0xLienid/sherlock-olympus/pull/5/files

Discussion

0xLienid

Fix Implementation: https://github.com/0xLienid/sherlock-olympus/pull/5/files

IAm0x52

Fix looks good. Optionally lpBalance could be removed

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

Likely the vault manager's total LP accounting can be manipulated because individual vaults do not track their own deposits and withdrawals, allowing a user to withdraw LP that was never deposited through the vault.

Impact

LP accounting is broken and users are permanently trapped, as their withdrawals revert.

What the attacker needed

Attacker has LP tokens; attacker can create a vault; victim has deposited LP

The fix

The fix was implemented by making individual vaults track their own deposits and preventing withdrawals greater than deposited.

How it was found

  1. Attacker stakes LP tokens directly for their vault using AuraRewardPool's stakeFor function.
  2. Attacker calls withdraw on their vault, which decreases the manager's total LP.
  3. The manager's total LP becomes lower than the sum of honest users' deposits.
  4. Honest users' withdrawals revert because decreaseTotalLp checks against the now-incorrect total.

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 is a smart contract that holds users' deposits. The manager keeps a running total of all LP tokens deposited across all vaults. An attacker can add LP tokens to the total without actually depositing them into their own vault, then withdraw them, making the total drop below what honest users have deposited. When honest users try to withdraw, the manager's check fails and their funds are stuck.

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 Olympus RBS 2.0

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.