triggerFee is stolen from other auctions during settleWithBuyout()
The settleWithBuyout function pays the trigger fee from the contract's balance instead of from the buyer, so the fee is taken from funds belonging to other auctions. This can cause other auctions to fail to settle or lose principal.
minhquanym Follow with bin2chen
Originally disclosed on Code4rena
Submitted by minhquanym, also found by bin2chen
The function settleWithBuyout() is used to settle an auction with a buyout from the main lender. This lender needs to repay all other lenders and will receive the NFT collateral. Near the end of the function, the triggerFee is also paid to the auction originator. However, the funds used to pay this fee are taken directly from the contract balance, even though the main lender doesn’t transfer these funds into the contract.
function settleWithBuyout(
...
) external nonReentrant {
...
// @note Repay other lenders
ERC20 asset = ERC20(_auction.asset);
uint256 totalOwed;
for (uint256 i; i < _loan.tranche.length;) {
...
}
IMultiSourceLoan(_auction.loanAddress).loanLiquidated(_auction.loanId, _loan);
// @audit There is no fund in this contract to pay triggerFee
asset.safeTransfer(_auction.originator, totalOwed.mulDivDown(_auction.triggerFee, _BPS));
...
}
As a result, if the auction contract balance is insufficient to cover the fee, the function will simply revert and prevent the main lender from buying out. In other cases where multiple auctions are running in parallel, the triggerFee will be deducted from the other auctions. This could lead to the last auctions being unable to settle due to insufficient balance.
Proof of Concept
The function settleWithBuyout() is called before any placeBid() so the funds is only from main lender. In the settleWithBuyout(), there are 2 transfers asset. One is to pay other lenders and one is to pay the triggerFee. As you can see in the code snippet, there is no triggerFee transfer from sender to originator.
Recommended Mitigation Steps
Consider using safeTransferFrom() to pay the triggerFee from the sender’s address, rather than using safeTransfer() to pay the triggerFee from the contract balance.
Sustaining high severity because this is going to cause a loss of principal to other auctions.
Change to
safeTransferFrombuyer.
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
The function uses safeTransfer to pay the trigger fee from the contract's balance instead of using safeTransferFrom to collect it from the buyer.
Impact
Other auctions may lose their principal or be unable to settle, as the fee is deducted from their funds.
What the attacker needed
Multiple auctions running in parallel; buyer calls settleWithBuyout
The fix
The trigger fee should be paid by the buyer using safeTransferFrom instead of from the contract balance.
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.
When a buyer settles an auction early, they must pay a small fee to the person who started the auction. The code mistakenly takes this fee from the shared pool of money that belongs to other auctions, not from the buyer. This means other auctions can lose money or fail to complete.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.