Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Valid

Leaving unclaimed tokens in the WithdrawalPool will eventually lead to a DOS in the getFinalizedWithdrawalIdsByOwner function.

Summary

The getFinalizedWithdrawalIdsByOwner function calls getBatchIds, which iterates over the withdrawalBatches. The protocol uses withdrawalBatchIdCutoff to minimize the number of iterations. However, this approach may fail if someone, either intentionally or due to oversight, doesn't claim their tokens from the withdrawal pool.

Vulnerability Details

https://github.com/Cyfrin/2024-09-stakelink/blob/f5824f9ad67058b24a2c08494e51ddd7efdbb90b/contracts/core/priorityPool/WithdrawalPool.sol#L379

The updateWithdrawalBatchIdCutoff function allows updating the withdrawalBatchIdCutoff, but this will only happen if all withdrawals from a batch have been collected. If someone fails to withdraw their tokens, whether intentionally or unintentionally, the cutoff won't be updated.

function updateWithdrawalBatchIdCutoff() external {
...
// find the first withdrawal that has funds remaining
for (uint256 i = newWithdrawalIdCutoff; i < numWithdrawals; ++i) {
newWithdrawalIdCutoff = i;
Withdrawal memory withdrawal = queuedWithdrawals[i];
if (withdrawal.sharesRemaining != 0 || withdrawal.partiallyWithdrawableAmount != 0) {
break;
}
}
...
}

Impact

This function is used only within view functions. However, even off-chain processing might fail if there are too many batches.

It's also worth mentioning that the creation of new batches is not restricted by minTimeBetweenWithdrawals, as new batches can be created when there are items in the withdrawal queue and a user makes a deposit to the staking pool.

https://github.com/Cyfrin/2024-09-stakelink/blob/f5824f9ad67058b24a2c08494e51ddd7efdbb90b/contracts/core/priorityPool/WithdrawalPool.sol#L326C9-L326C29

Tools Used

Manula Review

Recommendations

It's not that easy to fix, but in can be fixed by paging batches. getFinalizedWithdrawalIdsByOwner might be accepting page number for batches as a parameter.

Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

M-1 Cyfrin not properly fixed - if someone forgets to withdraw the withdrawalBatches array is still ever increasing

Support

FAQs

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