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

LiquidationBranch.sol can DOS due to an underflow issue

Summary

The contract LiquidationBranch handles the logic for checking if accounts are liquidatable and then potentially applies a liquidation process on those accounts.

In checkLiquidatableAccounts, two input parameters lowerBound and upperBound are expected to establish boundaries for the set of accounts to be checked for liquidation.

Vulnerability Details

// prepare output array size
liquidatableAccountsIds = new uint128[](upperBound - lowerBound);

This line of code could lead to an underflow issue. If the user provides lowerBound greater than upperBound, the subtraction will result in a large positive integer due to underflow mechanics in Solidity, which could lead to a Denial of Service attack as the contract attempts to allocate an overly large amount of memory.

/// @param lowerBound The lower bound of the accounts to check
/// @param upperBound The upper bound of the accounts to check
function checkLiquidatableAccounts(
uint256 lowerBound,
uint256 upperBound
)
external
view
returns (uint128[] memory liquidatableAccountsIds)
{
// prepare output array size
liquidatableAccountsIds = new uint128[](upperBound - lowerBound);
// ... other code ...
}

Impact

DOS attack

Tools Used

Recommendations

To mitigate this issue, it is recommended to perform an explicit check before initializing the liquidatableAccountsIds array:

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

This will ensure that upperBound always be equal to or greater than lowerBound and prevent the potential underflow issue. Utilizing tools such as SafeMath can also be helpful to prevent such underflows or overflows in other mathematical operations.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 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.