buyLoan function does not check if pools[poolId] and loans[loanId] have the same loanToken and collateralToken. Because of this a lender can buy a loan with a pool that uses different loanToken and collateralToken. This results in the borrower of the loan not being able to pay his debt, which means the borrower will lose his collateral. The lender that purchased the loan with the mismatched token pool can end up getting that borrower's collateral (The process of claiming the collateral here is not very straightforward since the lender would have to start an auction, wait for it to end, then in one transaction create a pool with the correct tokens and seizeLoan() the user). If a legitimate pool buys the loan from the mismatched token pool during the auction the borrower would be able to repay the loan.
Below is a proof of concept illustrating the vulnerability. This is coded within the test suite of the protocol with the following code written to create another set of loanTokens and collateralTokens.
POC:
Lenders, maliciously or accidentally, can cause borrowers to lose their collateral since they are not able to repay their debt or call the refinance function.
Lenders have motivation to act maliciously here since they could end up gaining the lost collateral.
Since loans will most definitely be required to be over-collateralized this will cause a big loss for the borrowers.
Foundry & Manual Review.
add the following code to buyLoan function, in order to check that the tokens on the loan match the tokens on the pool.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.