The borrow() function in Lender.sol can be reentered by a potential borrower to steal funds and drain the entire pool of its tokens.
The borrow() function creates a loan but does not add it to the array of loans before sending the borrower the funds they requested. The funds used for collateral are also not taken from the borrower until AFTER the borrower receives the funds. Without proper reentrancy protection, this leads to a malicious borrower to be able to drain the entire pool of a lender while posting little as collateral.
A malicious borrower can drain entire pools since the loan is only added to the array of existing loans at the end of the call, a user can post very little as collateral and drain entire pools.
manual review
Use reentrancy protection, push the loan into the loans array before transferring funds, transfer the user funds only after the Lender receives collateral.
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.