The increasePosition function enables users to join the liquidation pool, expanding the holders array with each new participation, such that all functions that depends on iteration over holders will run out of gas error and resulting into DOS
The increasePosition()
function adds users to the holders
array:
https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L134
Any user can increase position by staking and address of user will be added to holder's array
https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L112
As the number of stakers increases , holder's array will increase. There is only one instance where this length decreases when user's unstake completely
https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L149
https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L144
As Malicious user can always left 1wei stakes and their position won't be deleted i.e length won't decrease.
Further During liquidation distributeAssets()
iterates through all the holders and doing state change for every holders wand hence a long list of holder's will run out of gas, breaking liquidations completely
Even distributeFees()
iterates through all the holders and does write to storage variables leading to very high gas cost function
Critical functions like distributeAssets()
and distributeFees()
are susceptible to running out of gas due to prolonged holders array lengths, causing the breakdown of essential protocol functionalities reliant on these functions
same problem arises in the case of pendingStakes, if all the current active holder's staked within 1 day of window period consolidatePendingStakes()
will revert due to gas error
https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L119C14-L119C38
Manual
Seeing the current implementation I don't see any feasible solution.
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.