Submitted by 0xDjango
NFTLoanFacilitator.sol#L214-L221
NFTLoanFacilitator.sol#L230-L250
If borrower lends their own loan, they can repay and close the loan before ownership of the lend ticket is transferred to the new lender. The borrower will keep the NFT + loan amount + accrued interest.
This exploit requires that the loanAssetContractAddress token transfers control to the receiver.
The following code illustrates that the new lender sends funds to the original lender prior to receiving the lend ticket in return.
Finally, the new lender receives the lend ticket that has no utility at this point. The borrower now possesses the NFT, original loan amount, and accrued interest.
Move the line to transfer the lend ticket to the new lender above the line to transfer to funds to the original lender. Or, use reentrancyGuard from OpenZeppelin to remove the risk of reentrant calls completely.
If desired, also require that the lender cannot be the same account as the borrower of a loan.
wilsoncusack (Backed Protocol) confirmed and commented:
wilsoncusack (Backed Protocol) commented:
wilsoncusack (Backed Protocol) commented:
wilsoncusack (Backed Protocol) commented:
wilsoncusack (Backed Protocol) resolved
gzeon (judge) commented:
