Skip to content
Business logic Audit finding Intermediate

Missing Complication check in takeMultipleOneOrders

The takeMultipleOneOrders function did not check the Complication rules that define who may take an order. An attacker could take a private-sale order that was meant only for a specific taker.

shenwilly Follow

Originally disclosed on Code4rena

Submitted by shenwilly

An order’s type and it’s rules are defined in it’s Complication. Not checking it would allow anyone to take any orders regardless of their Complication’s rule, causing unexpected execution for order makers.

takeMultipleOneOrders assumes that all makerOrders are simple orderbook orders and the Complication check is missing here.

Proof of Concept

  • Alice signs a makerOrder with PrivateSaleComplication, allowing only Bob to take the private sale order.
  • A malicious trader calls takeMultipleOneOrders to take Alice’s order, despite the Complication only allowing Bob to take it.

Recommended Mitigation Steps

Add canExecTakeOneOrder function in IComplication.sol and implement it in InfinityOrderBookComplication (and future Complications) to support takeMultipleOneOrders operation, then modify takeMultipleOneOrders to use the check:

function takeMultipleOneOrders() {
    ...
    for (uint256 i = 0; i < numMakerOrders; ) {
        bytes32 makerOrderHash = _hash(makerOrders[i]);
        bool makerOrderValid = isOrderValid(makerOrders[i], makerOrderHash);
        bool executionValid = IComplication(makerOrders[i].execParams[0]).canExecTakeOneOrder(makerOrders[i]);

        require(makerOrderValid && executionValid, 'order not verified');

        require(currency == makerOrders[i].execParams[1], 'cannot mix currencies');
        require(isMakerSeller == makerOrders[i].isSellOrder, 'cannot mix order sides');
        uint256 execPrice = _getCurrentPrice(makerOrders[i]);
        totalPrice += execPrice; // @audit-issue missing complication check
        _execTakeOneOrder(makerOrderHash, makerOrders[i], isMakerSeller, execPrice);
        unchecked {
            ++i;
        }
    }
    ...
}

nneverlander (Infinity) confirmed and resolved:

fixed in https://github.com/infinitydotxyz/exchange-contracts-v2/commit/0b7608a2c9efc71d902a9c90f4731ef434b42c31.

HardlyDifficult (judge) commented:

takeMultipleOneOrders does not check restrictions set via the Complication. Agree with the High risk assessment here.


The original report as published on Code4rena, by shenwilly. 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 batch-taking function omitted the Complication validation that the single-order path performs, so it treated every order as a plain orderbook order.

Impact

A restricted order could be taken by anyone, causing unexpected execution for the order maker.

What the attacker needed

A signed maker order with a Complication; attacker can call takeMultipleOneOrders

The fix

The project added a canExecTakeOneOrder check to the Complication interface and called it inside takeMultipleOneOrders; the report says it was fixed.

How it was found

  1. Alice signs a maker order with a PrivateSaleComplication that allows only Bob to take it.
  2. A malicious trader calls takeMultipleOneOrders with Alice's order.
  3. The order is taken even though the Complication allowed only Bob.

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.

An order can have rules attached, such as 'only Bob may take this'. The function that takes several orders at once skipped checking those rules. So anyone could take an order that was meant to be restricted.

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 shenwilly

View all

12 more disclosed reports, best first.

More from Infinity NFT Marketplace 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.