A Denial of Service (DoS) vulnerability exists in the WithdrawalPool.sol contract within the _finalizeWithdrawals function. By queuing an excessive number of withdrawal requests, an attacker can cause the function to exceed the block gas limit during execution. This results in failed transactions, preventing the processing of withdrawals and effectively halting the withdrawal functionality of the staking platform.
Explanation:
The attacker repeatedly invokes the queueWithdrawal function to add a substantial number of withdrawal requests to the queuedWithdrawals array. This dramatically increases the length of the array, setting the stage for gas exhaustion when the contract attempts to process these withdrawals.
Explanation:
When performUpkeep is called, it internally invokes _finalizeWithdrawals. Due to the inflated size of the queuedWithdrawals array, the for-loop within _finalizeWithdrawals consumes an excessive amount of gas. This exceeds the block gas limit, causing the transaction to revert and preventing any withdrawals from being processed.
Explanation:
Even attempts to process individual withdrawals using the withdraw function can fail if the underlying loop in _finalizeWithdrawals is already gas-exhausted. This ensures that the withdrawal functionality remains unusable until the queue is reduced to a manageable size.
Service Disruption: Legitimate users are unable to process their withdrawal requests, leading to inaccessibility of funds.
Operational Halting: Core functionalities of the staking platform are compromised, affecting user trust and platform reliability.
Financial Loss: Users may experience delays in accessing their staked funds, potentially leading to financial losses if liquidity is urgently needed.
Manual Code Review
Implementation:
Modify the _finalizeWithdrawals function to handle a fixed number of withdrawals per transaction, thereby preventing gas exhaustion.
Explanation:
By introducing a _maxIterations parameter, the function limits the number of withdrawals processed in a single transaction. This ensures that the function remains within the gas limits, even when a large number of withdrawals are queued.
Implementation:
Set a cap on the number of withdrawal requests that can be queued at any given time.
Explanation:
By enforcing a maximum limit on the queuedWithdrawals array, the contract prevents the queue from growing indefinitely. This mitigates the risk of gas exhaustion during the withdrawal finalization process.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.