DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: high
Valid

checkLiquidatableAccounts won't work for lowerBound bigger than 0

Summary

This function works only for first batch of users, and it would be reverted if called for any other

Vulnerability Details

The size of the output array is calculated based on the parameters provided. While the iteration ends at UpperBound, if the lower bound is greater than 0, you may end up trying to access the array beyond its bounds

liquidatableAccountsIds = new uint128[](upperBound - lowerBound);
...
for (uint256 i = lowerBound; i < upperBound; i++) {
...
liquidatableAccountsIds[i] = tradingAccountId;

For following parameters this function would fail

lowerBound = 20

upperBound = 30


because the function may try to access the element at position 20 while the array size is only 10.

Impact

Administrator would be able to get only first batch of account for liqudations.

Tools Used

Manual Review

Recommendations

This loop should start iterating from 0 and stop and the length of the array, while tradingAccountIndex should be lowerBound + i

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

`LiquidationBranch::checkLiquidatableAccounts()` executes `for` loop where `liquidatableAccountsIds[i] = tradingAccountId;` gives out of bounds if `lowerBound != 0`

Support

FAQs

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

Give us feedback!