Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: high
Invalid

Users Can Exploit `WithdrawalPool::_finalizeWithdrawals` to Receive More Tokens Than Supposed

Summary

When WithdrawalPool::_finalizeWithdrawals is called, if sharesRemaining exceeds sharesToWithdraw, the user's withdrawal is partially filled and recorded in the withdrawalBatches. However, if a user's withdrawal is divided into multiple parts and they delay withdrawing any of the parts, their partiallyWithdrawableAmount accumulates. This allows the user to selectively choose a withdrawalBatch with the most favorable Stake to Shares rate, resulting in the user receiving more tokens than they are supposed to, thereby profiting at the expense of the protocol.

Vulnerability Details

The code responsible for handling partial withdrawals looks like this:

if (sharesRemaining > sharesToWithdraw) {
// partially finalize withdrawal
queuedWithdrawals[i] = Withdrawal(
uint128(sharesRemaining - sharesToWithdraw),
uint128(
queuedWithdrawals[i].partiallyWithdrawableAmount +
_getStakeByShares(sharesToWithdraw)
)
);
indexOfNextWithdrawal = i;
withdrawalBatches.push(
WithdrawalBatch(uint128(i - 1), uint128(_getStakeByShares(1 ether)))
);
}

In the withdrawalBatches structure, each batch records the indexOfLastWithdrawal and stakePerShares—the Stake to Shares exchange rate at the time of withdrawal. When a user's withdrawal is split into several parts, and they do not withdraw any of the parts before the next batch is created, their partiallyWithdrawableAmount accumulates across all queued withdrawals.

The issue arises when the user eventually chooses to withdraw their accumulated tokens, as they can opt to use the withdrawalBatch with the most favorable Stake to Shares rate, allowing them to receive more tokens than they are entitled to. This creates an opportunity for users to make a risk-free profit at the expense of the protocol.

Impact

Users can exploit this vulnerability to withdraw more tokens than they should, leading to risk-free profit at the expense of the protocol and causing potential financial losses.

Tools Used

Manual

Recommendations

Enforce that each partial withdrawal uses the stakePerShares rate pegged to it at the time the withdrawal was initially queued, preventing users from profiting by selecting more favorable rates.

Updates

Lead Judging Commences

inallhonesty Lead Judge
11 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

krisrenzo Submitter
10 months ago
inallhonesty Lead Judge
10 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.