Skip to content
Business logic Audit finding Intermediate

isolateRedeem() revert in case Revert-on-zero-value-transfers tokens

When the auction fine parameters are set to zero, redeeming a loan in auction state attempts a zero-value token transfer to the first bidder. For tokens that revert on zero-value transfers, this makes redemption impossible for the borrower.

Ch_301 Follow

Originally disclosed on Code4rena

Submitted by Ch_301

One of the features of this protocol is that the borrower can redeem his loan (under the Isolate Lending) after his loan goes into auction state (before the end of the auction) by simply invoking IsolateLiquidation.sol#isolateRedeem(). However, in order to keep the liquidators incentivized to launch the auction for any bad debt, the borrower could get forced to pay them some fee (called bidFine).

The bidFine is defined by two factors bidFineFactor and minBidFineFactor, both of them are updatable from Configurator.sol#setAssetAuctionParams(),

In case admin set them to zero, when the borrower tries to redeem his loan this logic from IsolateLogic.sol#executeIsolateRedeem():

File: IsolateLogic.sol#executeIsolateRedeem()

328:       (, vars.bidFines[vars.nidx]) = GenericLogic.calculateNftLoanBidFine(
329:         debtAssetData,
330:         debtGroupData,
331:         nftAssetData,
332:         loanData,
333:         vars.priceOracle
334:       );

will set the value of vars.bidFines[vars.nidx] to zero. After that, the flow will enter this IF block to transfer the bidFine to the liquidator who launched the auction.

File: IsolateLogic.sol#executeIsolateRedeem()

346:       if (loanData.firstBidder != address(0)) {
347:         // transfer bid fine from borrower to the first bidder
348:         VaultLogic.erc20TransferBetweenWallets(
349:           params.asset,
350:           params.msgSender,
351:           loanData.firstBidder,
352:           vars.bidFines[vars.nidx]
353:         );
354:       }

In case params.asset is one of Revert-on-Zero-Value-Transfers tokens (in scope), the transaction will revert because it is trying to transfer zero value vars.bidFines[vars.nidx] == 0.

Impact

The borrower will never be able to redeem his loan after his loan goes into auction state.

Recommended Mitigation Steps

File: IsolateLogic.sol#executeIsolateRedeem()

- 346:       if (loanData.firstBidder != address(0)) {
+ 346:       if (loanData.firstBidder != address(0) && vars.bidFines[vars.nidx] > 0) {
347:         // transfer bid fine from borrower to the first bidder
348:         VaultLogic.erc20TransferBetweenWallets(
349:           params.asset,
350:           params.msgSender,
351:           loanData.firstBidder,
352:           vars.bidFines[vars.nidx]
353:         );
354:       }

Assessed type

ERC20

thorseldon (BendDAO) confirmed and commented:

Fixed here.


The original report as published on Code4rena, by Ch_301. 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 code transfers the bid fine unconditionally whenever a first bidder exists, without checking that the fine amount is greater than zero.

Impact

The borrower can never redeem their loan once it is in auction state, but only when the asset is a token that reverts on zero-value transfers and the fine factors are zero.

What the attacker needed

Bid fine factors set to zero by admin; asset is a revert-on-zero-transfer token; loan is in auction state with a first bidder

The fix

The transfer should be skipped when the bid fine is zero; the project confirmed and fixed it.

How it was found

  1. The admin sets the bid fine factors to zero through the configurator.
  2. A borrower's loan enters auction state and a first bidder places a bid.
  3. The borrower calls isolateRedeem to buy the loan back.
  4. The fine calculation returns zero, and the code still tries to transfer that zero amount to the first bidder.
  5. With a token that reverts on zero-value transfers, the whole redemption transaction reverts.

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.

Some tokens refuse to process a transfer of zero tokens and cancel the whole transaction. Here the code always tried to pay the auction's first bidder a fine, even when that fine worked out to zero, so with such a token the borrower's attempt to buy back their loan always failed.

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 Ch_301

View all

39 more disclosed reports, best first.

More from BendDAO 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.