Skip to content
Business logic Audit finding Advanced

Adversary can economically exploit wstETHLiquidityVault

The SingleSidedLiquidityVault contract allows a user to deposit wstETH, which causes the vault to mint OHM and provide liquidity to a Balancer pool. An attacker can manipulate the pool price within the allowed threshold, then withdraw and sell the acquired OHM for a profit, draining the vault.

Bahurum Follow with Bobface, KingNFT and 3 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-olympus-judging/issues/110

Found by

Bahurum, Bobface, KingNFT, cducrest-brainbot, 0x52, immeas

Summary

Adversary can profit off of the single sided liquidity vault by depositing, buying OHM, withdrawing then dumping the profited OHM. This attack remains profitable regardless of the value of THRESHOLD.

Vulnerability Detail

SingleSidedLiquidityVault#deposit allows a user to specify the amount of wstETH they wish to deposit into the vault. The vault then mints the proper amount of OHM to match this, then deposits both into the wstETH/OHM liquidity pool on Balancer. If the price of OHM changes between deposit and withdrawal, the vault will effectively eat the IL caused by the movement. If the price decreases then the vault will burn more OHM than minted. If the price increases then the vault will burn less OHM than minted. This discrepancy can be exploited by malicious users to profit at the expense of the vault.

First we will outline the flow of the attack then run through the numbers:

  1. Deposit wstETH, which causes the vault to mint OHM as a counter-asset
  2. Buy OHM from the liquidity pool making sure to not go outside the price threshold to trigger the isPoolSafe check
  3. Withdraw wstETH
  4. Sell acquired OHM for a profit

Now we can crunch the numbers to prove that this is profitable:

The only assumption we need to make is the price of OHM/wstETH which for simplicity we will assume is 1:1.

Balances before attack: Liquidity: 80 OHM 80 wstETH Adversary: 20 wstETH

Balances after adversary has deposited to the pool: Liquidity: 100 OHM 100 wstETH Adversary: 0 wstETH

Balances after adversary sells wstETH for OHM (1% movement in price): Liquidity: 99.503 OHM 100.498 wstETH Adversary: 0.496 OHM -0.498 wstETH

Balances after adversary removes their liquidity: Liquidity: 79.602 OHM 80.399 wstETH Adversary: 0.496 OHM 19.7 wstETH

Balances after selling profited OHM: Liquidity: 80.099 OHM 79.9 wstETH Adversary: 20.099 wstETH

We can see that the adversary will gain wstETH for each time they loop this through attack. The profit being made i For simplicity I have only walked through a single direction attack but the adversary could easily drop the price to the lower threshold then start the attack to gain a larger amount of wstETH.

No matter how tight the threshold is set it is impossible to make this kind of attack unprofitable. Tighter thresholds just increases the amount of capital required to make it profitable. Another issue is that the THRESHOLD value can only get so small before the it starts causing random reverts for legitimate users.

For additional context, the fee charged by the pool only slightly impacts the profitability of this attack. Since the attacker only needs to manipulate the price within the threshold, fees scale linearly with THRESHOLD and therefore don't change the profitability of the attack.

Impact

Vault can be exploited for a nearly unlimited amount of OHM

Code Snippet

https://github.com/sherlock-audit/2023-02-olympus/blob/main/src/policies/lending/abstracts/SingleSidedLiquidityVault.sol#L187-L244

Tool used

ChatGPT

Recommendation

The only mechanism I can think of to prevent this is to add a withdraw/deposit fee to the vault

Discussion

unbanksy

The auditor incorrectly assumes that the user receives OHM on withdraw:

Balances after adversary sells wstETH for OHM (1% movement in price):
Liquidity: 99.503 OHM 100.498 wstETH
Adversary: 0.496 OHM -0.498 wstETH

That is not the case as the OHM is burned by the protocol. @0xLienid right?

0xLienid

@unbanksy I don't think that's the assumption the auditor is making. Based on their math it seems they recognize that the user only gets the wstETH portion back based on these steps:

Balances after adversary sells wstETH for OHM (1% movement in price):
Liquidity: 99.503 OHM 100.498 wstETH
Adversary: 0.496 OHM -0.498 wstETH

Balances after adversary removes their liquidity:
Liquidity: 79.602 OHM 80.399 wstETH
Adversary: 0.496 OHM 19.7 wstETH

I think the "Balances after adversary removes their liquidity" step might be wrong and the adversary should end up with 19.6016 wstETH which would make this not really profitable.

IAm0x52

@0xLienid The 19.7 is a typo. When they withdraw they get 20.0996 which makes their net 19.6016. So it should read 19.6 at that step not 19.7. When the user sells their OHM they net 0.499 stETH so the final balance is correct at 20.099 (19.6+0.499) and the attack is profitable.

The original report as published on Sherlock, by Bahurum. 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 does not account for impermanent loss when users deposit and withdraw, allowing price manipulation within the threshold to be profitable.

Impact

Vault can be exploited for a nearly unlimited amount of OHM.

What the attacker needed

Ability to trade in the wstETH/OHM pool; sufficient capital to move price within threshold

The fix

The only mechanism suggested is to add a withdraw/deposit fee to the vault.

How it was found

  1. Deposit wstETH, which causes the vault to mint OHM as a counter-asset
  2. Buy OHM from the liquidity pool making sure to not go outside the price threshold to trigger the isPoolSafe check
  3. Withdraw wstETH
  4. Sell acquired OHM for a profit

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 lets people deposit one token (wstETH) and it automatically adds a matching amount of another token (OHM) to a trading pool. If someone can change the price of OHM in that pool, they can deposit, trade to shift the price, withdraw, and sell the extra OHM for more wstETH than they started with, taking value from the vault.

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 Bahurum

View all

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