repay function in Lender.sol file, doesn't follow the CEI pattern and updates loans after an external call.
The implementation does not strictly follow the Checks-Effects-Interactions (CEI) pattern.
Malicious attackers and unsuspecting ecosystem participants can borrow a loan with ERC-777 tokens (which have a callback that can take control) as collateral and repay a loan and exploit this vulnerability.
A malicious user can drain a contract from loan.collateralToken with the following steps.
A user borrow a loan.
repay a loan
contract transfer collateral to loan.borrower
as the loans isn't updated.
A user reenter again and get collateral again
drain a contract and steel all loan.collateralToken from the contract
change Pool outstanding deb
change PoolBalance
manual review
follow CEI pattern and update state changes before external call.
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.