Staked assets can be locked in Lido, due to vulnerable check in YieldEthStakingLido::protocolDeposit
The protocolDeposit function only checks that each individual stake amount is within Lido's withdrawal limits, but multiple stakes can accumulate to exceed the maximum. This locks the staked assets because the contract cannot split withdrawal requests.
Submitted by oakcobalt
Code reference: YieldEthStakingLido.sol#L85
Finding description and impact
In Lido’s WithdrawRequest(WithdrawalQueue.sol) implementation, only a withdraw request with stETH amount within MIN_STETH_WITHDRAWAL_AMOUNT, MAX_STETH_WITHDRAWAL_AMOUNT ( [100, 1000ether]) can be processed.
If the yieldAmount exceeds 1000ether, the withdrawal request has to be split into several requests.
The problem is YiedEthstaingLido::protocolDeposit has a vulnerable check on MAX_STETH_WITHDRAWAL_AMOUNT, and will still allow a position to stake more than MAX_STETH_WITHDRAWAL_AMOUNT overtime.
Since YieldEthStakingLido.sol doesn’t allow splitting withdrawal of a staking position(yieldStakeData), any staking position exceeding MAX_STETH_WITHDRAWAL_AMOUNT cannot be unstaked. Funds will be locked in Lido.
Proof of Concept
Vulnerability: protocolDeposit can be called multiple times through stake(), allowing a user to incrementally stake more asset associated the same staked NFT. The check on the max cap through protocolDeposit is invalid because it only check any single stake amount is below the max cap. Multiple stakes can still exceed the max cap.
//src/yield/lido/YieldEthStakingLido.sol
function protocolDeposit(YieldStakeData storage sd, uint256 amount) internal virtual override returns (uint256) {
require(amount >= MIN_STETH_WITHDRAWAL_AMOUNT, Errors.YIELD_ETH_LT_MIN_AMOUNT);
|> require(amount <= MAX_STETH_WITHDRAWAL_AMOUNT, Errors.YIELD_ETH_GT_MAX_AMOUNT);
...
//src/yield/YieldStakingBase.sol
function _stake(uint32 poolId, address nft, uint256 tokenId, uint256 borrowAmount) internal virtual {
...
// stake in protocol and got the yield
vars.totalYieldBeforeDeposit = getAccountTotalUnstakedYield(address(vars.yieldAccout));
|> vars.yieldAmount = protocolDeposit(sd, borrowAmount);
vars.yieldShare = _convertToYieldSharesWithTotalYield(
address(vars.yieldAccout),
vars.yieldAmount,
vars.totalYieldBeforeDeposit
);
// update nft shares
sd.debtShare += vars.debtShare;
|> sd.yieldShare += vars.yieldShare; //@audit-info note: multiple stakes, increment total yieldShare
...
Impact
Unable to unstake, NFT locked and ETH locked in Lido.
Recommended mitigation steps
Consider moving the max cap check (total yield amount + borrow) into YieldStakingBase::_stake. The actual check parameter can be pulled from YieldEthStakingLido.sol. For example,
//src/yield/YieldStakingBase.sol
function _stake(uint32 poolId, address nft, uint256 tokenId, uint256 borrowAmount) internal virtual {
...
vars.totalYieldBeforeDeposit = getAccountTotalUnstakedYield(address(vars.yieldAccout));
+ checkMaxStakingCap(vars.totalYieldBeforeDeposit + borrowAmount);
vars.yieldAmount = protocolDeposit(sd, borrowAmount);
...
//src/yield/lido/YieldEthStakingLido.sol
function checkMaxStakingCap(uint256 amount ) public pure override{
require(amount >= MIN_STETH_WITHDRAWAL_AMOUNT, Errors.YIELD_ETH_LT_MIN_AMOUNT);
require(amount <= MAX_STETH_WITHDRAWAL_AMOUNT, Errors.YIELD_ETH_GT_MAX_AMOUNT);
...
thorseldon (BendDAO) acknowledged and commented:
As we implement the new
YieldWUSDStakingcontract, we already know the increment stake issues which should not be supported in any yield contract.But the fix is pending as our frontend only support only 1 stake per NFT for now.
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 maximum withdrawal amount check is applied per deposit instead of to the cumulative staked amount for a position.
Impact
Funds can be locked in Lido and the NFT cannot be unstaked, though the frontend currently only supports one stake per NFT, limiting exposure.
What the attacker needed
Ability to call stake() multiple times; each stake amount below the maximum
The fix
The check should be moved to the base staking function and applied to the total yield amount plus the new borrow amount, rather than to each deposit individually.
How it was found
- Call stake() multiple times with amounts each below the maximum.
- Each call adds to the same staked NFT's yieldShare.
- The total staked amount exceeds Lido's maximum withdrawal amount.
- Attempt to unstake the position, but the contract cannot split the withdrawal request.
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.
Lido, a service for staking cryptocurrency, only allows withdrawal requests between 100 and 1000 ether. The contract checks each deposit separately, so if someone deposits many times, the total can go over 1000 ether. Then the contract cannot withdraw the whole amount because it does not split requests, so the funds get 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.