DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: medium
Invalid

Insecure Array Initialization Size in LiquidationBranch::checkLiquidatableAccounts Function

Summary

The checkLiquidatableAccounts function initializes the liquidatableAccountsIds array without validating that upperBound is greater than lowerBound. This oversight can lead to logical errors and runtime exceptions due to incorrect array sizes.

Vulnerability Details

The function assigns the array size based on the difference between upperBound and lowerBound without ensuring upperBound is greater than lowerBound. This can result in zero or negative sizes, causing incorrect behavior during array operations.

Proof of Concept

In the current implementation, the array initialization is:

uint256 size = upperBound - lowerBound;
liquidatableAccountsIds = new uint128[](size);

If upperBound is less than or equal to lowerBound, the resulting size may be zero or negative, leading to:

  • Empty or erroneously sized arrays, causing disruptions during subsequent operations.

  • Possible runtime issues or logical errors that could halt the function or lead to unexpected results.

Consider a potential scenario:

// Assume upperBound = 10 and lowerBound = 20
uint256 size = upperBound - lowerBound; // size = 10 - 20 = -10 (or a very large unsigned integer)
liquidatableAccountsIds = new uint128[](size); // runtime error

This scenario can cause the function to fail at runtime, preventing further processing and causing contract malfunction.

Impact

Medium severity. Potential consequences include:

  • Logical errors that can prevent the function from operating correctly.

  • Denial of Service (DoS) if array operations fail due to incorrect sizes.

Tools Used

Manual code review.

Recommendations

Add validation checks to ensure upperBound is greater than lowerBound before initializing the array.
Example solution:

require(upperBound > lowerBound, "Invalid bounds");
uint256 size = upperBound - lowerBound;
liquidatableAccountsIds = new uint128[](size);

This validation ensures the array is correctly sized, preventing logical errors and runtime exceptions.

Updates

Lead Judging Commences

inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!