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

Token Mismatch when buying loan

Summary

In Lender.sol,the buyLoan() function does not check if the buyer has similar loan and collateral tokens as the previous pool.

Vulnerability Details

When the loan borrower tries to repay the loan after it has been bought, the following won't work as expected since the new loan owner might have different loan and collateral tokens.

function repay(uint256[] calldata loanIds) public {
for (uint256 i = 0; i < loanIds.length; i++) {
//..
// transfer the loan tokens from the borrower to the pool
IERC20(loan.loanToken).transferFrom(
msg.sender,
address(this),
loan.debt + lenderInterest
);
// transfer the collateral tokens from the contract to the borrower
IERC20(loan.collateralToken).transfer(
loan.borrower,
loan.collateral
);
//..
}
}

Impact

The loan borrow can't get his collateral back

Tools Used

Manual review

Recommendations

Consider reverting if the new pool does not have similar loan and collateral token as previous pool.

Support

FAQs

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

Give us feedback!