By abusing the giveLoan function, a lender can steal the accumulated protocol interest.
The giveLoan method allows a lender to move a loan to another pool. First, the totalDebt is calculated, which consist of the borrowed amount plus pending interest:
Then, the totalDebt is moved into the new pool, by borrowing that amount:
And finally, the protocolInterest gets sent to the feeReceiver:
The issue is that the protocolInterest is included in totalDebt. A lender can abuse this behaviour by giving the loan to himself, after which he will be the recipient of the previously accumulated protocolInterest when the borrower repays, since it is treated as debt.
This behaviour has multiple impacts:
The lender can steal the accumulated protocolInterest
Since the contract also transfers the protocolInterest in giveLoan without owning it, these tokens are effectively transferred from the balance of other depositors. Should all (or enough) lenders close their pools, the contract becomes insolvent.
If the loanTokens from all pools are currently lent out, the function would always revert, as it would still try to transfer the loanTokens to the feeReceiver without having the balance.
Also note that the same faulty implementation is present in buyLoan.
None
The pending interest should not be treated as debt, but instead be tracked seperately. Additionally, the accumulated protocolInterest must not be transferred in giveLoan, as it has not been received yet. How exactly this is implemented is up to the developers to decide.
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.