20,000 USDC
View results
Submission Details
Severity: medium

There is no checking if loan's loanRatio is greater than pool's maxLoanRatio in buyLoan() function

Summary

There is no checking if loan's loanRatio is greater than pool's maxLoanRatio in buyLoan() function

Vulnerability Details

There is no checking if loan's loanRatio is greater than pool's maxLoanRatio in buyLoan() function

Impact

Because there is no checking if loan's loanRatio is greater than pool's maxLoanRatio in buyLoan() function, user can buy very risk loan with very high loanRatio.

Tools Used

Manual

Recommendations

Need to revert if loan's loanRatio is greater than pool's maxLoanRatio in buyLoan() function.

function buyLoan(uint256 loanId, bytes32 poolId) public {
// get the loan info
...
// reject if the pool is not big enough
uint256 totalDebt = loan.debt + lenderInterest + protocolInterest;
if (pools[poolId].poolBalance < totalDebt) revert PoolTooSmall();
uint256 loanRatio = (totalDebt * 10 ** 18) / loan.collateral;
if (loanRatio > pools[poolId].maxLoanRatio) revert RatioTooHigh();
...

Support

FAQs

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