Malicious lender could withdraw more loan tokens than they are entitled too
In Lender.sol, setPool() allows the lender to change the pool balance, even if the outstanding loans have not changed. This could be exploited by a malicious lender to withdraw more loan tokens than they are entitled to. https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L130-L176
For example, let's say that the lender has deposited 100 loan tokens in the pool and there are currently 50 outstanding loans. This means that the pool balance is 100 - 50 = 50.
A malicious lender could exploit this vulnerability by calling the setPool function with a new pool balance of 150. This would increase the pool balance by 100, even though the outstanding loans have not changed. This would allow the lender to withdraw 100 additional loan tokens, which they are not entitled to.
Manual Review
To mitigate this vulnerability, the function setPool should only allow the lender to change the pool balance if the outstanding loans have also changed. This could be done by checking the outstandingLoans field before updating the poolBalance field.
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.