The removeCollateralFromLiquidationPriority
function is vulnerable to a gas exhaustion attack due to its inefficient iteration over the entire collateralLiquidationPriority set. This can prevent the removal of collateral types when the set is large, potentially leading to a denial of service.
The removeCollateralFromLiquidationPriority
function iterates over the entire collateralLiquidationPriority
set to remove a specific collateral type. It removes and re-adds each collateral except the one to be removed, which is necessary to maintain the order of the set.
However, this approach is inefficient and can lead to gas exhaustion if the set contains a large number of collateral types. An attacker could exploit this by populating the set with many collateral types, causing the transaction to exceed the block gas limit and fail. This breaks the security guarantee of efficient and reliable collateral management, as it allows an attacker to prevent the removal of any collateral from the liquidation priority.
Medium because it can lead to a denial of service. By exploiting the gas exhaustion vulnerability, an attacker can prevent the removal of collateral types from the liquidation priority, disrupting the system's ability to manage collateral effectively. This can lead to operational inefficiencies and potential financial losses.
Likelihood
Medium/Low: While it requires an attacker to populate the set with a large number of collateral types, the absence of a mechanism to limit the set's size makes it feasible. The risk is higher in systems where the number of collateral types is not actively managed or limited.
An attacker adds a large number of collateral types to the collateralLiquidationPriority set. When the removeCollateralFromLiquidationPriority function is called, the transaction will fail due to gas exhaustion, preventing the removal of any collateral.
Optimize the function to avoid iterating over the entire set or implement a mechanism to limit the number of collaterals that can be added to the set. Consider using a more efficient data structure or algorithm to manage the collateral liquidation priority.
Could be two options:
Limit the Number of Collaterals: Implement a mechanism to limit the number of collaterals that can be added to the set, reducing the risk of gas exhaustion.
Optimize the Removal Process: Consider using a more efficient data structure or algorithm to manage the collateral liquidation priority, such as maintaining a separate mapping for quick access and removal.
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.