All orders which use expirationTime == 0 to support oracle cancellation are not executable
A code refactoring removed the special handling that treated an order expiration time of zero as 'no expiry', so every order signed with that value can no longer be matched. An attacker gains nothing directly, but traders relying on oracle cancellation lose the ability to have their orders executed.
Submitted by Trust, also found by cccz
The Blur Exchange supplied docs state:
Off-chain methods “Oracle cancellations - if the order is signed with an expirationTime of 0, a user can request an oracle to stop producing authorization signatures; without a recent signature, the order will not be able to be matched”
From the docs, we can expect that when expirationTime is 0 , trader wishes to enable dynamic oracle cancellations. However, the recent code refactoring broke not only this functionality but all orders with expirationTime = 0.
Previous _validateOrderParameters:
function _validateOrderParameters(Order calldata order, bytes32 orderHash)
internal
view
returns (bool)
{
return (
/* Order must have a trader. */
(order.trader != address(0)) &&
/* Order must not be cancelled or filled. */
(cancelledOrFilled[orderHash] == false) &&
/* Order must be settleable. */
_canSettleOrder(order.listingTime, order.expirationTime)
);
}
/**
* @dev Check if the order can be settled at the current timestamp
* @param listingTime order listing time
* @param expirationTime order expiration time
*/
function _canSettleOrder(uint256 listingTime, uint256 expirationTime)
view
internal
returns (bool)
{
return (listingTime < block.timestamp) && (expirationTime == 0 || block.timestamp < expirationTime);
New _validateOrderParameters:
function _validateOrderParameters(Order calldata order, bytes32 orderHash)
internal
view
returns (bool)
{
return (
/* Order must have a trader. */
(order.trader != address(0)) &&
/* Order must not be cancelled or filled. */
(!cancelledOrFilled[orderHash]) &&
/* Order must be settleable. */
(order.listingTime < block.timestamp) &&
(block.timestamp < order.expirationTime)
);
}
Note the requirements on expirationTime in _canSettleOrder (old) and _validateOrderParameters (new).
If expirationTime == 0, the condition was satisfied without looking at block.timestamp < expirationTime.
In the new code, block.timestamp < expirationTime is always required in order for the order to be valid. Clearly, block.timestamp < 0 will always be false, so all orders that wish to make use of off-chain cancellation will never execute.
Impact
All orders which use expirationTime == 0 to support oracle cancellation are not executable.
Tools Used
Manual audit, diffing tool
Recommended Mitigation Steps
Implement the checks the same way as they were in the previous version of Exchange.
nonfungible47 (Blur) acknowledged and commented:
This is correct, however, as the maintainers of the main orderbook, we can ensure that no current orders have been created with expirationTime of 0.
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 refactor inlined the settleability check and dropped the explicit 'expirationTime == 0' exception that previously bypassed the timestamp comparison.
Impact
All orders using an expiration time of zero for oracle cancellation become unexecutable, though the maintainers state no live orders currently use that value.
What the attacker needed
Order signed with expirationTime of 0
The fix
The check should be restored to its previous form so that a zero expiration time skips the timestamp comparison.
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.
Orders on this marketplace carry an expiry time. A value of zero was meant to mean 'no fixed expiry, the oracle decides when to stop signing it'. After a code change, the contract compares the current time against that zero and the check always fails, so those orders can never be completed.
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.