refinanceFull / addNewTranche reusing a lender’s signature leads to unintended behavior
The refinanceFull and addNewTranche functions accept the same lender signature, so a malicious user can front-run a refinanceFull call with addNewTranche using the same signature. This causes the loan amount to approximately double and increases the lender's risk dramatically.
Submitted by bin2chen
Vulnerability details
In MultiSourceLoan, refinanceFull() and addNewTranche() use the same signature.
function refinanceFull(
RenegotiationOffer calldata _renegotiationOffer,
Loan memory _loan,
bytes calldata _renegotiationOfferSignature
) external nonReentrant returns (uint256, Loan memory) {
...
if (lenderInitiated) {
if (_isLoanLocked(_loan.startTime, _loan.startTime + _loan.duration)) {
revert LoanLockedError();
}
_checkStrictlyBetter(
_renegotiationOffer.principalAmount,
_loan.principalAmount,
_renegotiationOffer.duration + block.timestamp,
_loan.duration + _loan.startTime,
_renegotiationOffer.aprBps,
totalAnnualInterest / _loan.principalAmount,
_renegotiationOffer.fee
);
} else if (msg.sender != _loan.borrower) {
revert InvalidCallerError();
} else {
/// @notice Borrowers clears interest
@> _checkSignature(_renegotiationOffer.lender, _renegotiationOffer.hash(), _renegotiationOfferSignature);
netNewLender -= totalAccruedInterest;
totalAccruedInterest = 0;
}
function addNewTranche(
RenegotiationOffer calldata _renegotiationOffer,
Loan memory _loan,
bytes calldata _renegotiationOfferSignature
) external nonReentrant returns (uint256, Loan memory) {
...
uint256 loanId = _renegotiationOffer.loanId;
_baseLoanChecks(loanId, _loan);
_baseRenegotiationChecks(_renegotiationOffer, _loan);
@> _checkSignature(_renegotiationOffer.lender, _renegotiationOffer.hash(), _renegotiationOfferSignature);
if (_loan.tranche.length == getMaxTranches) {
revert TooManyTranchesError();
}
So when lender signs RenegotiationOffer, it is meant to replace tranche, i.e. execute refinanceFull(). But a malicious user can use this sign and front-run execute addNewTranche().
addNewTranche() doesn’t limit the RenegotiationOffer too much. The newly generated Loan will be approximately twice the total amount borrowed, and the risk of borrowing against the lender will increase dramatically.
Impact
Maliciously using the signature of refinanceFull() to execute addNewTranche() will result in approximately double the borrowed amount, and the risk of borrowing will increase dramatically.
Recommended Mitigation
In RenegotiationOffer, add a type field to differentiate between signatures.
Assessed type
Context
Check
trancheIndexto differentiate betweenrefiFull/addNewTranche.
Status: Unmitigated. Full details in reports from minhquanym, bin2chen and oakcobalt, and also included in the Mitigation Review section below.
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 signed offer does not include a field that distinguishes between the refinanceFull and addNewTranche operations, so the same signature is valid for both.
Impact
The borrowed amount could approximately double and the risk of borrowing against the lender could increase dramatically.
What the attacker needed
Lender signs a RenegotiationOffer; attacker can front-run the transaction
The fix
A type field should be added to RenegotiationOffer to differentiate between signatures, or the trancheIndex should be checked to distinguish refiFull from addNewTranche.
How it was found
- A lender signs a RenegotiationOffer intended for refinanceFull.
- A malicious user obtains that signature.
- The malicious user front-runs and calls addNewTranche with the same offer and signature.
- The loan is modified by adding a new tranche instead of replacing the existing one.
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.
A lender signs a message to approve replacing an existing loan with a new one. Because another function that adds an extra loan part accepts the same signed message, an attacker can use that signature to add a new loan part instead. This makes the total borrowed amount roughly twice as large, which the lender did not intend.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.