Skip to content
Access control Audit finding Intermediate

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.

oakcobalt Follow

Originally disclosed on Code4rena

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:

  1. _validateExecutionData will not check whether _loan.borrower == _executionData.borrower. In addition, it will directly bypass the check on executionData’s borrower signature as long as msg.sender!=_loan.borrower.
  2. 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 _loan and _loanExecutionData has the same principalAddress and the same nftCollateralAddress, _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 approved MultiSourceLoan.sol for 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.

0xend (Gondi) confirmed

Note: For full discussion, see here.

Gondi mitigated:

Checking signature from the existing borrower.

Status: Mitigation confirmed. Full details in reports from oakcobalt, minhquanym and bin2chen.


The original report as published on Code4rena, by oakcobalt. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. Borrower B signs a loan execution data offer.
  2. Borrower B calls refinanceFromLoanExecutionData with Borrower A's existing loan.
  3. The function does not check that the new borrower matches the existing borrower, nor that the token ID matches.
  4. The principal is transferred to Borrower B, using Borrower A's collateral.
  5. 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.

More by oakcobalt

View all

50 more disclosed reports, best first.

More from Gondi Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.