Skip to content
Business logic Audit finding Intermediate

YieldEthStakingLido lacks a limit on the max stake amount, which may result in the unstake exceeding MAX_STETH_WITHDRAWAL_AMOUNT , resulting in the token not being retrieved

The YieldEthStakingLido contract does not limit the maximum stake amount, so a stake exceeding Lido's MAX_STETH_WITHDRAWAL_AMOUNT cannot be unstaked because the withdrawal request is made in a single call. This can lock the staked tokens in the contract.

bin2chen Follow with oakcobalt

Originally disclosed on Code4rena

Submitted by bin2chen, also found by oakcobalt

In YieldEthStakingLido, the main processes are as follows:

  1. stake() -> stEth balance increase
  2. unstake () -> unstETH.requestWithdrawals(allShares)
  3. repay() -> unstETH.claimWithdrawal()

The issue is the second step, unstETH is with a maximum withdrawal limit: MAX_STETH_WITHDRAWAL_AMOUNT

contract YieldEthStakingLido is YieldStakingBase {
...
  function protocolRequestWithdrawal(YieldStakeData storage sd) internal virtual override {
    IYieldAccount yieldAccount = IYieldAccount(yieldAccounts[msg.sender]);

    uint256[] memory requestAmounts = new uint256[](1);
    requestAmounts[0] = sd.withdrawAmount;
    bytes memory result = yieldAccount.execute(
      address(unstETH),
@>    abi.encodeWithSelector(IUnstETH.requestWithdrawals.selector, requestAmounts, address(yieldAccount))
    );
    uint256[] memory withdrawReqIds = abi.decode(result, (uint256[]));
    require(withdrawReqIds.length > 0 && withdrawReqIds[0] > 0, Errors.YIELD_ETH_WITHDRAW_FAILED);
    sd.withdrawReqId = withdrawReqIds[0];
  }

https://docs.lido.fi/contracts/withdrawal-queue-erc721/#requestwithdrawals

each amount in _amounts must be greater than or equal to MIN_STETH_WITHDRAWAL_AMOUNT and lower than or equal to MAX_STETH_WITHDRAWAL_AMOUNT.

Current configuration here.

    /// @notice maximum amount of stETH that is possible to withdraw by a single request
    /// Prevents accumulating too much funds per single request fulfillment in the future.
    /// @dev To withdraw larger amounts, it's recommended to split it to several requests
    uint256 public constant MAX_STETH_WITHDRAWAL_AMOUNT = 1000 * 1e18;

lido suggests that if it exceeds this value, it needs to be taken in batches, but YieldEthStakingLido.sol can only be taken at once. If the stake amount exceeds this value, it will not be possible to unstake() and the token will be locked in the contract.

Assumption: leverageFactor = 50000 , eth price = $2500

As long as the value of the nft is greater than 1000 * $2500 / 5 = $500,000 it will be possible to stake() more than MAX_STETH_WITHDRAWAL_AMOUNT. After that, when the user performs an unstake() it will fail, causing the token to be locked.

Impact

Excessive amount of stake will result in failure to unstake().

Recommended Mitigation

YieldStakingBase add method checkStakeAmount. Each sub contract override implements its own maximum amount limit, YieldEthStakingLido suggests a maximum of MAX_STETH_WITHDRAWAL_AMOUNT/2.

Assessed type

Context

0xTheC0der (judge) decreased severity to Medium and commented:

Downgrading to Medium due to reduced likelihood of such great stake amounts.

thorseldon (BendDAO) confirmed and commented:

Fixed here.


The original report as published on Code4rena, by bin2chen. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 contract does not enforce a maximum stake amount that matches the withdrawal limit of the underlying stETH withdrawal queue, and it always requests the full amount in a single withdrawal.

Impact

A user who stakes more than the withdrawal limit may be unable to unstake, leaving their tokens locked in the contract; the judge reduced severity because such large stakes are unlikely.

What the attacker needed

Stake amount above Lido's withdrawal limit

The fix

The project added a checkStakeAmount method in YieldStakingBase for each sub-contract to override with its own maximum, and the report was fixed.

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 stake tokens, you later ask for them back. This contract asks for all of them in one request, but the underlying service only allows requests up to a certain size. If your stake is larger than that limit, the request fails and your tokens stay 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.

More by bin2chen

View all

139 more disclosed reports, best first.

More from BendDAO Invitational

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.