Hard-coded slippage may freeze user funds during market turbulence
The vault contracts use a hard-coded 99% slippage tolerance when swapping yield tokens for the withdrawal asset, so if the market price of the yield token drops by more than 1% the swap reverts and users cannot withdraw. An attacker cannot directly exploit this, but during market turbulence users' funds may become temporarily locked.
Submitted by jonah1005, also found by berndartmueller, Picodes, IllIllI, sorrynotsorry, and WatchPug
GeneralVault.sol#L125 GeneralVault set a hardcoded slippage control of 99%. However, the underlying yield tokens price may go down. If Luna/UST things happen again, users’ funds may get locked.
LidoVault.sol#L130-L137 Moreover, the withdrawal of the lidoVault takes a swap from the curve pool. 1 stEth worth 0.98 ETH at the time of writing. The vault can not withdraw at the current market.
Given that users’ funds would be locked in the lidoVault, I consider this a high-risk issue.
Proof of Concept
Recommended Mitigation Steps
There are different ways to set the slippage.
The first one is to let users determine the maximum slippage they’re willing to take. The protocol front-end should set the recommended value for them.
function withdrawCollateral(
address _asset,
uint256 _amount,
address _to,
uint256 _minReceiveAmount
) external virtual {
// ...
require(withdrawAmount >= _minReceiveAmount, Errors.VT_WITHDRAW_AMOUNT_MISMATCH);
}
The second one is have a slippage control parameters that’s set by the operator.
// Exchange stETH -> ETH via Curve
uint256 receivedETHAmount = CurveswapAdapter.swapExactTokensForTokens(
_addressesProvider,
_addressesProvider.getAddress('STETH_ETH_POOL'),
LIDO,
ETH,
yieldStETH,
maxSlippage
);
function setMaxSlippage(uint256 _slippage) external onlyOperator {
maxSlippage = _slippage;
//@audit This action usually emit an event.
emit SetMaxSlippage(msg.sender, slippage);
}
These are two common ways to deal with this issue. I prefer the first one. The market may corrupt really fast before the operator takes action. It’s nothing fun watching the number go down while having no option.
sforman2000 (Sturdy) confirmed
Fix the issue of require 99% of withdrawAmount sturdyfi/code4rena-may-2022#11
I realise there are 2 issues discussed here:
- The high-risk severity relates to
GeneralVault’s tight 1% slippage. Because it is inherited by vaults, it can cause withdrawals to fail and for user funds to be stuck.- However, in the context of the LIDO vault specifically, #69’s first low-severity issue rightly points out that users can choose to withdraw their funds in stETH, then do conversion to ETH separately afterwards. Hence, funds won’t actually be stuck. I would’ve therefore classified this a medium-severity issue. Nevertheless, it is expected that users will attempt to withdraw to ETH instead of stETH in times of market volatility.
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 tolerance for the swap performed during withdrawal was hard-coded to 99% of the expected output, leaving no room for normal market price movement.
Impact
During market turbulence, withdrawals that require a swap may revert, temporarily locking user funds in the vault; however, users can still withdraw in the yield token itself, so funds are not permanently stuck.
What the attacker needed
Market price of yield token drops >1%; user withdraws to ETH rather than yield token
The fix
The issue was fixed by allowing a configurable minimum receive amount or operator-set slippage parameter instead of the hard-coded 99% check.
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' money and invests it. When a user withdraws, the vault sometimes has to swap one token for another, and it checks that it receives at least a minimum amount back. Here that minimum was set too close to the expected price, so a small drop in the market makes the swap fail and the withdrawal gets 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.