Anyone can buy loan with other lender's pool by calling buyLoan() function in Lender.sol.
It will lead for malicious lender to steal money from Lender.sol contract.
Malicious lender will create pool with very big maxLoanRatio and maximum interestRate.
He will borrow all poolBalance from his own pool with very small collateral using new address as a new borrower.
After some time has passed, he will start auction as lender1, and he will find other pool with same loan token and collateral token and enough balance, (lets say its pool id is poolId1), and he will call buyLoan() function with that poolId1 as a new address(lender3). lender3 doesn't have any pool, but he can call buyLoan() function because there is no checking if msg.sender is same to pool's lender in buyLoan() function.
When calling buyLoan() function, his lenderInterest will be very much because he set maximum interest rate and his debit is very much as well, and so his poolBalance will increase tremendously.
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L498-L502
After that, he will call removeFromPool() function from his own pool.
He got loan.debt + lenderInterest more with very small collateral.
It will lead for malicious lender to steal money from Lender contract.
Foundry
Need to checking if msg.sender is same to pool's lender in buyLoan() function.
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.