The function findManagerIndex in the StabilityPool contract lacks a mechanism to limit the number of managers added, which can lead to an Out of Gas (OOG) error during execution. This vulnerability arises from the potential for an unbounded loop that iterates through the managerList, which can grow indefinitely if not properly managed. This would lead to the DoS of removeManager()
The findManagerIndex function is designed to locate the index of a specified manager within the managerList. The implementation is as follows:
In this function, the loop iterates through the managerList array, which can grow as managers are added. If the number of managers becomes excessively large, the loop may consume all available gas, leading to a transaction failure. This is particularly concerning in a decentralized environment where the number of managers could potentially be unbounded.
The primary impact of this vulnerability is the risk of denial of service (DoS) for the contract. If a user attempts to find a manager's index (during operations such as removeManager() ) when the managerList has grown too large, the transaction will fail due to running out of gas. This could prevent legitimate operations from being executed, such as updating allocations or removing managers, thereby affecting the overall functionality and reliability of the StabilityPool contract.
Manual Review
To mitigate the risk of an OOG error in the findManagerIndex function, the following recommendations are proposed:
Limit the Number of Managers: Introduce a maximum cap on the number of managers that can be added to the managerList. This can be enforced in the addManager function:
Use a Mapping for Manager Indices: Instead of iterating through an array, maintain a mapping that directly associates manager addresses with their indices. This allows for O(1) access time:
Implement Proper Error Handling: Ensure that the contract gracefully handles cases where the maximum number of managers is reached, providing clear feedback to users.
By implementing these recommendations, the StabilityPool contract can enhance its robustness and prevent potential denial of service attacks due to gas exhaustion.
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.