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.
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
takeMultipleOneOrdersto 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:
HardlyDifficult (judge) commented:
takeMultipleOneOrdersdoes not check restrictions set via the Complication. Agree with the High risk assessment here.
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
- Alice signs a maker order with a PrivateSaleComplication that allows only Bob to take it.
- A malicious trader calls takeMultipleOneOrders with Alice's order.
- 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.