A malicious user can take on a loan using an existing borrower’s collateral in refinanceFromLoanExecutionData()
The refinanceFromLoanExecutionData function did not verify that the new loan's borrower matched the existing loan's borrower, nor that the NFT token ID was the same. A malicious borrower could use another borrower's collateral to obtain a new loan, potentially locking the victim's collateral.
Submitted by oakcobalt
In MultiSourceLoan.sol, refinanceFromLoanExecutionData() doesn’t check whether _loan.borrower == _loanExecutionData.borrower, which is open rooms for exploits.
BorrowerB (malicious) can sign a _loanExecutionData offer and initiate a refinanceFromLoanExecutionData() call with Borrower A’s loan. Borrower B will use Borrower A’s collateral for his loan.
There are (2) vulnerabilities here:
_validateExecutionDatawill not check whether_loan.borrower == _executionData.borrower. In addition, it will directly bypass the check onexecutionData’s borrower signature as long asmsg.sender!=_loan.borrower.refinanceFromLoanExecutionData()doesn’t check whether the new loanExecutiondata (_loanExecutionData) has the same nft tokenId(executionData.tokenId) as the existing loan(_loan.nftCollateralTokenId).
As a result, if _loanExecutionData.borrower (Borrower B) initiates refinanceFromLoanExecutionData() call, the following would happen:
msg.sender != _loan.borrower(Borrwer A), this bypass_validateExecutionData’s signature check. Also, it will not revert because no checks on address _borrower(loan.borrower==_loanExecutionData.borrower;.- There is no check on
_loanExecutionData.tokenId. As long as_loanand_loanExecutionDatahas the sameprincipalAddressand the samenftCollateralAddress,_processOffersFromExecutionData()will succeed in transferring principal loans to Borrower B. - As long as the
_loan.borrower(Borrower A) has the funds for repayment. (Note: Borrower A might have approvedMultiSourceLoan.solfor asset transfer if they are ready for repayments.), the tx will succeed and Borrower A’s collateral will continually be locked for Borrower B’s new loan.
The above steps can also happen in a front-running scenario, where Borrower B sees that Borrower A approves MultiSourceLoan.sol for loan repayments and front-run Borrower A’s repayment with a new loan.
Recommended Mitigation Steps
In _validateExecutionData, consider adding checks to ensure address _borrower == _executionData.borrower.
Note: For full discussion, see here.
Checking signature from the existing borrower.
Status: Mitigation confirmed. Full details in reports from oakcobalt, minhquanym and bin2chen.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the function lacked checks to ensure the new loan's borrower and NFT token ID matched the existing loan's, and the signature validation was bypassed when the caller was not the original borrower.
Impact
A malicious borrower could obtain a loan using another borrower's collateral, and if the victim has approved the contract for repayment, the victim's collateral could remain locked for the attacker's loan; this could also be exploited via front-running.
What the attacker needed
Victim has an existing loan with collateral; Victim has approved the contract for repayment; Attacker can call refinanceFromLoanExecutionData
The fix
The mitigation was to check the signature from the existing borrower.
How it was found
- Borrower B signs a loan execution data offer.
- Borrower B calls refinanceFromLoanExecutionData with Borrower A's existing loan.
- The function does not check that the new borrower matches the existing borrower, nor that the token ID matches.
- The principal is transferred to Borrower B, using Borrower A's collateral.
- If Borrower A has approved the contract for repayment, the transaction succeeds and Borrower A's collateral remains locked for Borrower B's loan.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a lending system, a borrower puts up collateral (like an NFT) to get a loan. The refinance function lets someone replace an existing loan with a new one, but it failed to check that the new loan belongs to the same person and uses the same collateral. So an attacker could create a new loan in their own name but backed by someone else's collateral, effectively stealing the use of that collateral.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.