Skip to content
Business logic Audit finding Intermediate

_processOffersFromExecutionData() lack of check executionData.duration<=offer.duration

The loan emission function only checked that the offer duration was non-zero, but did not verify that the duration supplied in the execution data was less than or equal to the offer's duration. An attacker could therefore create a loan whose actual borrowing period far exceeds the agreed offer duration, and if the lender is a LoanManager this could also exceed the maximum pending queues and cause accounting problems.

bin2chen Follow

Originally disclosed on Code4rena

Submitted by bin2chen

emitLoan() only limits offer.duration != 0. There’s no limit in executionData.duration<=offer.duration.

emitLoan() -> _processOffersFromExecutionData() -> _validateOfferExecution()

    function _validateOfferExecution(
        OfferExecution calldata _offerExecution,
        uint256 _tokenId,
        address _lender,
        address _offerer,
        bytes calldata _lenderOfferSignature,
        uint256 _feeFraction,
        uint256 _totalAmount
    ) private {
...

@>      if (offer.duration == 0) {
            revert ZeroDurationError();
        }
        if (offer.aprBps == 0) {
            revert ZeroInterestError();
        }
        if ((offer.capacity > 0) && (_used[_offerer][offer.offerId] + _offerExecution.amount > offer.capacity)) {
            revert MaxCapacityExceededError();
        }

        _checkValidators(_offerExecution.offer, _tokenId);
    }

If the executionData.duration time is not limited, it can lead to far exceeding the borrowing time offer.duration. If the lender is a LoanManager, when repayLoan() it can also exceed the maximum pendingQueues, leading to accounting issues.

Impact

Far exceeding the borrowing time than offer.duration. If lender is LoanManager also exceeds max pendingQueues, causing bookkeeping issues.

Recommended Mitigation

Check executionData.duration<=offer[n].duration.

Assessed type

Context

0xend (Gondi) confirmed

0xA5DF (judge) commented:

Sustaining high due to accounting issues.

Gondi mitigated:

Added duration check.

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


The original report as published on Code4rena, by bin2chen. 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 validation function only checked that the offer duration was non-zero and never compared the execution data duration against the offer duration.

Impact

A borrower could obtain a loan lasting far longer than the offer duration, and when the lender is a LoanManager this could also exceed the maximum pending queues and cause bookkeeping issues.

What the attacker needed

Ability to call emitLoan with crafted execution data

The fix

The project added a check that the execution data duration is less than or equal to the offer duration, and the mitigation was confirmed.

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 smart contract lets people lend and borrow tokens. The offer says how long a loan should last, but the code that creates the loan never checked that the requested loan length matched or was shorter than the offer. So someone could borrow for much longer than agreed, which messes up the lender's records.

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 bin2chen

View all

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