Skip to content
Business logic Audit finding Intermediate

Normal users could be inadvertently grieved by the withdrawn ratios check

The contract's withdrawal check compares withdrawn token ratios to the oracle price and treats any imbalance as a fee, so a user who deposits and immediately withdraws from an already imbalanced pool loses part of their wstETH to the treasury. An attacker could exploit this to cause grief to normal users, though the loss is small.

RaymondFam Follow

Originally disclosed on Sherlock

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

Found by

RaymondFam

Summary

The contract check on the withdrawn ratios of OHM and wstETH against the current oracle price could run into grieving naive users by taking any wstETH shifted imbalance as a fee to the treasury even though these users have not gamed the system.

Vulnerability Detail

Here is a typical scenario, assuming the pool has been initiated with total LP equal to sqrt(100_000 * 1_000) = 10_000. (Note: OHM: $15, wstETH: $1500 with the pool pricing match up with manager.getOhmTknPrice() or manager.getTknOhmPrice(), i.e. 100 OHM to 1 wstETH or 0.01 wstETH to 1 OHM. The pool token balances in each step below may be calculated via the Constant Product Simulation after each swap and stake.)

OHM token balance: 100_000
wstETH token balance: 1_000
Total LP: 10_000
  1. A series of swap activities results in the pool shifted more of the LP into wstETH.

    OHM token balance: 90_909.1 wstETH token balance: 1_100 Total LP: 10_000

  2. Bob calls deposit() by providing 11 wstETH where 1100 OHM is minted with 1100 - 90909.1 * 0.01 = 190.91 unused OHM burned. (Note: Bob successfully stakes with 909.09 OHM and 11 wstETH and proportionately receives 100 LP.)

    OHM token balance: 91_818.19 wstETH token balance: 1_111 Total LP: 10_100 User's LP: 100

  3. Bob changes his mind instantly and proceeds to call withdraw() to remove all of his LP. He receives the originally staked 909.09 OHM and 11 wstETH. All OHM is burned but he is only entitled to receive 909.09 / 100 = 9.09 wstETH since the system takes any arbs relative to the oracle price for the Treasury and returns the rest to the owner.

    OHM token balance: 90_909.1 wstETH token balance: 1_100 Total LP: 10_000 User's LP: 0

Impact

Bob suffers a loss of 11 - 9.09 = 1.91 wstETH (~ 17.36% loss), and the system is ready to trap the next user given the currently imbalanced pool still shifted more of the LP into wstETH.

Code Snippet

File: BLVaultLido.sol#L143-L200

File: BLVaultLido.sol#L203-L256

Tool used

Manual Review

Recommendation

Consider implementing a snapshot of the entry record of OHM and wstETH and compare that with the proportionate exit record. Slash only the differential for treasury solely on dissuading large attempts to shift the pool around, and in this case it should be 0 wstETH since the originally staked wstETH is no greater than expectedWstethAmountOut.

Discussion

0xLienid

True, but this will be very very minor in practice. It relies on assuming no arbitrage is ever taken, it will also be helped (but not eliminated) by the solution to #003

Discussion

0xLienid

True, but this will be very very minor in practice. It relies on assuming no arbitrage is ever taken, it will also be helped (but not eliminated) by the solution to #003

IAm0x52

Sponsor has acknowledged and accepted this risk

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

A user could lose a portion of their deposited wstETH (about 17% in the example) even without malicious intent, and the imbalanced pool remains ready to trap the next user.

What the attacker needed

Pool is imbalanced from normal trading; user deposits and withdraws quickly; no arbitrage occurs to rebalance

The fix

The contract should record the user's entry token amounts and compare them to the exit amounts, slashing only the difference to discourage large pool manipulation; in the example the fee should be zero.

How it was found

  1. A series of swaps leaves the pool with more wstETH than the oracle price implies.
  2. Bob deposits 11 wstETH and receives LP tokens.
  3. Bob immediately withdraws all his LP.
  4. The contract returns only 9.09 wstETH to Bob and sends the rest to the treasury.

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 for a liquidity pool where users can deposit two types of tokens and later withdraw them. The contract tries to stop people from cheating by taking a fee if the pool's token balance doesn't match the official price. But if the pool is already unbalanced because of normal trading, an honest user who deposits and quickly withdraws can lose some of their tokens as that fee, even though they did nothing wrong.

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 RaymondFam

View all

18 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.