When a user calls buyLoan
, they specify a specific loanId
and poolId
. poolId
can specify any pool which has an interestRate
less than the currentAuctionRate
(msg.sender
does not need to be the lender for this pool). The logic of this contract first has the pool specified by poolId
pay off the current debt owed by the user. The intention is to then update the loan specified by loanId
to indicate that the borrower of that loan now needs to pay future interest to that pool. However, instead, the logic specifies that the the borrower needs to pay off that debt/interest to whatever pool is owned by msg.sender
. Since there is no check that enforces that the pool specified by poolId
is owned by msg.sender
, this means msg.sender
can effectively cheat the owner of poolId
out of funds.
Let's walk through the main logic of the buyLoan
function, which takes in a loanId
(loan to refinance) and poolId
(pool to refinance into). When a pool whose interestRate
is less than the currentAuctionRate
is specified, there's the following logic:
With the _updatePoolBalance
call, the specified poolId
pool is required to pay down the debt of the user of the loanId
loan.
Then, later in this function call, the loan is updated with the intention to have the borrower then pay off the future interest payments + debt to the pool which was used to refinance the loan:
Instead of that, the loan specifies the pool owned by msg.sender
to be the recipient of the future interest payments + debt. This means that the actual owner of the poolId
pool will be cheated out of funds.
The caller of buyLoan
can force another pool to pay off a user's debt, while also ensuring that they will never get paid back, meaning potentially significant losses for those pool owners.
Manual review
Either the lender for the loan should be updated as follows in the buyLoan
function:
or there should be a check that msg.sender
is the lender for the specified pool.
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.