The checkLiquidatableAccounts function in the contract does not handle the lower bound properly when it is not zero. This can result in accounts not being liquidated when they should be, due to an array out-of-bounds error in the function's loop.
The checkLiquidatableAccounts function is designed to return a list of liquidatable accounts within a specified range (lowerBound to upperBound). However, when the lower bound is not zero, the function miscalculates the size of the liquidatableAccountsIds array and can lead to an out-of-bounds error. This issue stems from the array initialization and the subsequent indexing logic within the for loop.
The function initializes the liquidatableAccountsIds array with the size upperBound - lowerBound. However, within the for loop, the array is indexed directly using i, which starts from lowerBound. This causes incorrect indexing and potential array out-of-bounds errors, preventing the function from correctly identifying and returning liquidatable accounts.
Consider a scenario where lowerBound is 10 and upperBound is 20. The array liquidatableAccountsIds is initialized with a size of 10 (20 - 10). When the for loop starts with i = 10, it tries to assign to liquidatableAccountsIds[10], causing an out-of-bounds error since the array only has indices from 0 to 9.
The vulnerability allows accounts that should be liquidated to bypass liquidation checks, potentially leading to significant financial risk on the platform. If liquidatable accounts are not identified correctly, they might continue operating with insufficient margin, exacerbating losses and undermining the integrity of the platform's liquidation mechanism.
Additionally, if users do not get liquidated when they should, they could potentially bypass liquidation if the price moves in their favor within the period they ought to be liquidated. This could result in users avoiding liquidation and the protocol incurring bad debt, thereby jeopardizing the financial stability of the entire system.
Manual review
Bounds Checking: Ensure that the function correctly checks and processes the bounds to prevent out-of-bounds errors.
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.