Description:
Whenever the following functions are called, they make sub-function calls that iterate over the pendingStakes
array: LiquidationPool::increasePosition()
, LiquidationPool::decreasePosition()
, LiquidationPool::distributeAssets()
, LiquidationPoolManager::distributeFees()
, LiquidationPoolManager::runLiquidation()
, and LiquidationPool::distributeFees()
. These sub-functions, in turn, loop through the pendingStake
array to find the user's position before taking action.
Impact:
If the pendingStakes
array becomes excessively long, leading to an unresponsive state due to an Out of Gas error, users' funds are at severe risk. The consequences range from loss of funds to the death of the protocol.
Proof of Concept:
A malicious actor could disrupt the network by creating numerous addresses and spamming the network with transactions. This could result in the pendingStakes
array becoming too long to iterate over efficiently, effectively preventing withdrawals.
Proof of Code:
The provided test suite demonstrates the vulnerability's validity and severity.
Due to the file size required to run this PoC, the suite is hosted on Github.
To run the PoC, clone the repository.
Minor changes, such as modifying function visibility, were made to enable successful test runs.
All changes and additional files made to the original code are documented in the README and the respective files where the changes are made.
Requirements:
Install Foundry.
Clone the project codebase into your local workspace.
Run the following commands to install dependencies:
Run the following command to execute the PoC:
Tools Used:
Manual review
Foundry
Recommended Mitigation Steps:
Consider alternative design structures that are more gas-efficient. For example, explore the use of mappings instead of arrays or incorporate the EnumerableMap library by OpenZeppelin.
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.