Skip to content
Business logic Audit finding Intermediate

`Vault::withdraw()` withdraws too much liquidity leading to idle capital and loss of fees

The Vault::withdraw function withdraws too many shares from the liquidity position when idle capital is insufficient, ignoring the idle capital already available. This leaves excess tokens idle, causing a loss of fees.

0x73696d616f Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-02-yieldoor-judging/issues/159

Found by

0x73696d616f

Summary

Vault::withdraw() withdraws from the lp position whenever the idle capital is not enough. However, it withdraws too much as it does not take into account that some of the idle capital is already available.

Root Cause

In Vault:98, it withdraws too many shares.

Internal Pre-conditions

None.

External Pre-conditions

None.

Attack Path

  1. User withdraws 1000 shares, worth 1000 tokens. There already are 500 tokens idle, but the code will still withdraw all 1000 tokens, keeping 500 tokens idle.

Impact

Loss of fees as the liquidity stays idle.

PoC

Solidity
function withdraw(uint256 shares, uint256 minAmount0, uint256 minAmount1)
    public
    returns (uint256 withdrawAmount0, uint256 withdrawAmount1)
{
    IStrategy(strategy).collectFees();

    (uint256 totalBalance0, uint256 totalBalance1) = IStrategy(strategy).balances();

    uint256 totalSupply = totalSupply();
    _burn(msg.sender, shares);

    withdrawAmount0 = totalBalance0 * shares / totalSupply;
    withdrawAmount1 = totalBalance1 * shares / totalSupply;

    (uint256 idle0, uint256 idle1) = IStrategy(strategy).idleBalances();

    if (idle0 < withdrawAmount0 || idle1 < withdrawAmount1) {
        // When withdrawing partial, there might be a few wei difference.
        (withdrawAmount0, withdrawAmount1) = IStrategy(strategy).withdrawPartial(shares, totalSupply);
    }

Mitigation

Reduce the shares to withdraw from the strategy by the liquidity already available (idle).

The original report as published on Sherlock, by 0x73696d616f. 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

Impact

Loss of fees as the liquidity stays idle.

What the attacker needed

None

The fix

Reduce the shares to withdraw from the strategy by the liquidity already available (idle).

How it was found

  1. A user withdraws 1000 shares worth 1000 tokens.
  2. There are already 500 tokens idle in the vault.
  3. The code still withdraws all 1000 tokens from the strategy, leaving 500 tokens idle.

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 take money out of a shared savings pool, the system should only sell the investments needed to cover your withdrawal. Here, it sells too many investments even though some cash was already sitting unused, so the pool misses out on earning fees from those investments.

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 0x73696d616f

View all

172 more disclosed reports, best first.

More from Yieldoor

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.