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

buyLoan not check loanRatio > pool.maxLoanRatio

Summary

buyLoan only check interestRate > currentAuctionRate, not check loanRatio > pool.maxLoanRatio, which will cause the pool to lose money.
And caller can designate any pool, even if they don't own it, which gives caller enormous power to manipulate the pool, causing it to go into debt.

Vulnerability Details

// get the loan info
Loan memory loan = loans[loanId];
// validate the loan
if (loan.auctionStartTimestamp == type(uint256).max)
revert AuctionNotStarted();
if (block.timestamp > loan.auctionStartTimestamp + loan.auctionLength)
revert AuctionEnded();
// calculate the current interest rate
uint256 timeElapsed = block.timestamp - loan.auctionStartTimestamp;
uint256 currentAuctionRate = (MAX_INTEREST_RATE * timeElapsed) /
loan.auctionLength;
// validate the rate
if (pools[poolId].interestRate > currentAuctionRate) revert RateTooHigh();
// calculate the interest
(uint256 lenderInterest, uint256 protocolInterest) = _calculateInterest(
loan
);

The two problems mentioned above can be clearly seen in the code, no further details

Impact

The caller can specify any poolId. If maxLoanRatio is not met, the pool will lose money.

Tools Used

Manual review

Recommendations

require loanRatio <= pool.maxLoanRatio

Support

FAQs

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