20,000 USDC
View results
Submission Details
Severity: low
Valid

Check for length of both array is equal or not is not done

Summary

No equality check for the length of the provided parameters in the function giveLoan

Vulnerability Details

In giveLoan function, We have to provide two arrays as a parameter. And both of these arrays are used in the calculations parallelly. For example:

for (uint256 i = 0; i < loanIds.length; i++) {
uint256 loanId = loanIds[i];
bytes32 poolId = poolIds[i];

In the above provided code from giveLoan function, The loanIds[i] depends on poolIds[i] which is going to be the same index of the array. That means both array should have equal number of values. The check for that is not done in the beginnig. Also check for loanId and poolIds length != zero is also not done.

Impact

When passed the different length arrays as a value, the loop in going to work upto some index but after that it is going to revert as the checks are done in the function stating whether lender in pool is equal to lender in loan and some other checks.

Tools Used

Foundry test. Manual inspection

Recommendations

Try checking for the length of the array in the begging of the function like this:

if(loanIds.length != poolIds.length){
revert CustomError();
}

Check for length not equal to zero should also be done.

Support

FAQs

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