In the StakingPool contract, the internal _withdrawLiquidity() function withdraws liquidity from strategies by iterating over the strategies array in descending order. The function assumes that the provided _data array (containing withdrawal data for each strategy) is of the same length as the strategies array. However, there is no check to ensure this, which introduces a potential risk of an out-of-bounds error and contract reversion. This could lead to a denial of service (DoS) vulnerability during the withdrawal process, preventing users from withdrawing liquidity.
The vulnerability lies in the following snippet of the _withdrawLiquidity() function:
In this loop, the function assumes that the strategies array and _data array are the same length, and it directly accesses _data[i - 1] without verifying the lengths of these arrays. If _data is shorter than strategies, the access will result in an out-of-bounds array access, causing the transaction to revert.
Denial of Service (DoS): If the _data array is shorter than the strategies array, the contract will revert during the withdrawal process, causing a denial of service for users attempting to withdraw their liquidity. This can halt the normal operation of withdrawals within the protocol.
Manual code review
Check for Array Length Consistency: Before proceeding with the withdrawal logic, ensure that the lengths of the strategies array and _data array are equal. This can be done by adding a require() statement at the beginning of the _withdrawLiquidity() function:
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.