minTokenAmounts_ is useless in new configuration and doesn't provide any real slippage protection
The withdraw function in BLVaultLido skims extra stETH from the user based on an oracle price, but the minTokenAmounts_ parameter only checks the liquidity pool withdrawal, not the final amount the user receives. Thus, users cannot protect themselves from unfavourable oracle price movements or skimming.
Source: https://github.com/sherlock-audit/2023-03-olympus-judging/issues/3
Found by
0x52
Summary
BLVaultLido#withdraw skims off extra stETH from the user that results from oracle arb. The problem with this is that minTokenAmounts_ no longer provides any slippage protection because it only ensures that enough is received from the liquidity pool but never enforces how much is received by the user.
Vulnerability Detail
_exitBalancerPool(lpAmount_, minTokenAmounts_);
// Calculate OHM and wstETH amounts received
uint256 ohmAmountOut = ohm.balanceOf(address(this)) - ohmBefore;
uint256 wstethAmountOut = wsteth.balanceOf(address(this)) - wstethBefore;
// Calculate oracle expected wstETH received amount
// getTknOhmPrice returns the amount of wstETH per 1 OHM based on the oracle price
uint256 wstethOhmPrice = manager.getTknOhmPrice();
uint256 expectedWstethAmountOut = (ohmAmountOut * wstethOhmPrice) / _OHM_DECIMALS;
// Take any arbs relative to the oracle price for the Treasury and return the rest to the owner
uint256 wstethToReturn = wstethAmountOut > expectedWstethAmountOut
? expectedWstethAmountOut
: wstethAmountOut;
if (wstethAmountOut > wstethToReturn)
wsteth.safeTransfer(TRSRY(), wstethAmountOut - wstethToReturn);
// Burn OHM
ohm.increaseAllowance(MINTR(), ohmAmountOut);
manager.burnOhmFromVault(ohmAmountOut);
// Return wstETH to owner
wsteth.safeTransfer(msg.sender, wstethToReturn);
minTokenAmounts_ only applies to the removal of liquidity. Since wstETH is skimmed off to the treasury the user no longer has any way to protect themselves from slippage. As shown in my other submission, oracle slop can lead to loss of funds due to this skimming.
Impact
Users cannot protect themselves from oracle slop/wstETH skimming
Code Snippet
Tool used
Manual Review
Recommendation
Allow the user to specify the amount of wstETH they receive AFTER the arb is skimmed.
Discussion
0xLienid
This is true, I'm not sure it would matter much in practice since there's no real economic incentive for anyone but the Treasury to do this. That said, it's a relatively easy fix so I think it's worth including anyways.
0xLienid
Fix Implementation: https://github.com/0xLienid/sherlock-olympus/pull/11/files
cducrest
Escalate for 10 USDC
Disagree with severity, probably medium or even low. The main reason slippage protection is needed in exchange is because of sandwich attacks that directly and instantly impact the price on the pool. Here the issue points to a lack of slippage protection with regards to the oracle price which cannot be impacted by an outsider.
Since there is slippage protection on the pool withdraw, the vault withdraw tx cannot be sandwiched for profit (or grief). It is just a nice to have.
sherlock-admin
Escalate for 10 USDC
Disagree with severity, probably medium or even low. The main reason slippage protection is needed in exchange is because of sandwich attacks that directly and instantly impact the price on the pool. Here the issue points to a lack of slippage protection with regards to the oracle price which cannot be impacted by an outsider.
Since there is slippage protection on the pool withdraw, the vault withdraw tx cannot be sandwiched for profit (or grief). It is just a nice to have.
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
IAm0x52
Escalate for 10 USDC
Disagree with the above comment. Since skimming of arb happens AFTER pool slippage checks the user would still lose funds.
sherlock-admin
Escalate for 10 USDC
Disagree with the above comment. Since skimming of arb happens AFTER pool slippage checks the user would still lose funds.
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
cducrest
The user may lose funds, if the arbs relative to the oracle price are to his disfavour. I agree with that. But whether it is to his disfavour or not cannot be impacted by an outsider. Additionally, the user can know in advance that he will be subjected to arbs by checking the oracle/real life asset price. This is not analogous to a dex swap using a pool of which the state can be influenced by a previous transaction (front-run / sandwich attack).
I.e. the reason we protect pool swaps with slippage parameters is not present in the arb relative to the oracle price.
Discussion
0xLienid
This is true, I'm not sure it would matter much in practice since there's no real economic incentive for anyone but the Treasury to do this. That said, it's a relatively easy fix so I think it's worth including anyways.
0xLienid
Fix Implementation: https://github.com/0xLienid/sherlock-olympus/pull/11/files
cducrest
Escalate for 10 USDC
Disagree with severity, probably medium or even low. The main reason slippage protection is needed in exchange is because of sandwich attacks that directly and instantly impact the price on the pool. Here the issue points to a lack of slippage protection with regards to the oracle price which cannot be impacted by an outsider.
Since there is slippage protection on the pool withdraw, the vault withdraw tx cannot be sandwiched for profit (or grief). It is just a nice to have.
sherlock-admin
Escalate for 10 USDC
Disagree with severity, probably medium or even low. The main reason slippage protection is needed in exchange is because of sandwich attacks that directly and instantly impact the price on the pool. Here the issue points to a lack of slippage protection with regards to the oracle price which cannot be impacted by an outsider.
Since there is slippage protection on the pool withdraw, the vault withdraw tx cannot be sandwiched for profit (or grief). It is just a nice to have.
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
IAm0x52
Escalate for 10 USDC
Disagree with the above comment. Since skimming of arb happens AFTER pool slippage checks the user would still lose funds.
sherlock-admin
Escalate for 10 USDC
Disagree with the above comment. Since skimming of arb happens AFTER pool slippage checks the user would still lose funds.
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
cducrest
The user may lose funds, if the arbs relative to the oracle price are to his disfavour. I agree with that. But whether it is to his disfavour or not cannot be impacted by an outsider. Additionally, the user can know in advance that he will be subjected to arbs by checking the oracle/real life asset price. This is not analogous to a dex swap using a pool of which the state can be influenced by a previous transaction (front-run / sandwich attack).
I.e. the reason we protect pool swaps with slippage parameters is not present in the arb relative to the oracle price.
hrishibhat
Escalation accepted
Considering this issue as a valid high Accepting the 2nd escalation. After further internal discussion considering the issue as is because there can loss due to a mismatch in oracle and pool price, there should be slippage protections on the final amount to protect the user.
sherlock-admin
Escalation accepted
Considering this issue as a valid high Accepting the 2nd escalation. After further internal discussion considering the issue as is because there can loss due to a mismatch in oracle and pool price, there should be slippage protections on the final amount to protect the user.
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
IAm0x52
Fix looks good. Added a secondary input to allow user to specify minimum wstETH
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 slippage protection parameter only applies to the liquidity pool withdrawal, not to the final amount after the oracle-based skimming.
Impact
Users could lose funds due to unfavourable oracle price movements or skimming, as they cannot set a minimum final amount; however, the loss cannot be directly caused by an outsider and depends on oracle versus pool price differences.
What the attacker needed
User withdraws from BLVaultLido; oracle price differs from pool price
The fix
The fix added a secondary input allowing the user to specify a minimum wstETH amount to receive after the arb is skimmed.
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 withdraw funds from a vault, you can set a minimum amount you expect to receive to protect against price changes. Here, the vault also takes some extra funds based on an oracle price, but the minimum check only applies to the first step, not the final amount you get. So you might receive less than you expected and have no way to prevent it.
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.