Skip to content
Business logic Audit finding Intermediate

The _executeNonAtomicOrders function in SeaportProxy.sol may fail unexpectedly

The _executeNonAtomicOrders function batches fee transfers until the end, so if the total fee cannot be paid, all orders in the batch fail instead of only the last one. An attacker could cause a denial of service by making the fee payment fail, but the report's scenario is about price increases, not malicious intent.

KingNFT Follow

Originally disclosed on Code4rena

Submitted by KingNFT

The \_executeNonAtomicOrders function in SeaportProxy.sol tries to send fees by batch. This may break the NonAtomic feature.

Proof of Concept

Let’s say the user wants to buy 3 NFTs with the following order parameters:

NFT_1: price = 100 USDT, fee = 5%
NFT_2: price = 200 USDT, fee = 5%
NFT_3: price = 300 USDT, fee = 5%

Given the user only sends 600 USDT, the expected result should be

NFT_1: success
NFT_2: success
NFT_3: failed

But as the fees are batched and sent at last, cause all 3 orders failed.

function _executeNonAtomicOrders(
    BasicOrder[] calldata orders,
    bytes[] calldata ordersExtraData,
    address recipient,
    uint256 feeBp,
    address feeRecipient
) private {
    uint256 fee;
    address lastOrderCurrency;
    for (uint256 i; i < orders.length; ) {
        OrderExtraData memory orderExtraData = abi.decode(ordersExtraData[i], (OrderExtraData));
        AdvancedOrder memory advancedOrder;
        advancedOrder.parameters = _populateParameters(orders[i], orderExtraData);
        advancedOrder.numerator = orderExtraData.numerator;
        advancedOrder.denominator = orderExtraData.denominator;
        advancedOrder.signature = orders[i].signature;

        address currency = orders[i].currency;
        uint256 price = orders[i].price;

        try
            marketplace.fulfillAdvancedOrder{value: currency == address(0) ? price : 0}(
                advancedOrder,
                new CriteriaResolver[](0),
                bytes32(0),
                recipient
            )
        {
            if (feeRecipient != address(0)) {
                uint256 orderFee = (price * feeBp) / 10000;
                if (currency == lastOrderCurrency) {
                    fee += orderFee;
                } else {
                    if (fee > 0) _transferFee(fee, lastOrderCurrency, feeRecipient);

                    lastOrderCurrency = currency;
                    fee = orderFee;
                }
            }
        } catch {}

        unchecked {
            ++i;
        }
    }

    if (fee > 0) _transferFee(fee, lastOrderCurrency, feeRecipient);
}

Tools Used

VS Code

Recommended Mitigation Steps

Don’t batch up fees.

0xhiroshi (LooksRare) disputed and commented:

I would treat this as a malicious user trying to buy NFTs without paying for fees as he should be paying 600 x 1.05 = 630 instead of 600. So I think it’s ok to just let it revert.

KingNFT (warden) commented:

Sorry for not indicating clearly. The reason I think this may happen is that the NFT price may increase during submitting of tx, not due to a malicious user.

0xhiroshi (LooksRare) acknowledged and commented:

Even if the seller submits a new listing with a higher price, the current transaction should still be valid. When there are two listings for the same NFT, they are both valid unless the seller explicitly cancels the original order on-chain, usually through the cancellation of an order nonce.


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

Impact

All orders in a non-atomic batch could fail if the total fee cannot be paid, even though some individual orders would have succeeded.

What the attacker needed

User submits a batch of orders; insufficient funds to cover total fees

The fix

The fees should not be batched; each order's fee should be transferred immediately after that order succeeds.

How it was found

  1. User submits a batch of three orders with prices 100, 200, and 300 USDT and a 5% fee.
  2. User sends only 600 USDT, which is enough for the NFT prices but not for the fees.
  3. The function processes each order and accumulates the fee.
  4. After the loop, the function attempts to transfer the total fee, which fails due to insufficient funds.
  5. The entire transaction reverts, causing all three orders to fail.

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.

This is a smart contract bug where a function tries to buy several NFTs at once and collect fees at the end. If the buyer does not send enough money to cover all fees, the whole batch fails, even the orders that could have succeeded. The expected behaviour is that earlier orders succeed and only the last one fails.

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 KingNFT

View all

25 more disclosed reports, best first.

More from LooksRare Aggregator contest

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.