Skip to content
Business logic Audit finding Intermediate

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.

0xend (Gondi) confirmed

0xA5DF (judge) commented:

Sustaining high severity because this is going to cause a loss of principal to other auctions.

Gondi mitigated:

Change to safeTransferFrom buyer.

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


The original report as published on Code4rena, by minhquanym. 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

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.

More by minhquanym

View all

28 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.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.