code4rena-2022-11-blur-exchange-m03
[M-03] All orders which use expirationTime == 0 to support oracle cancellation are not executable
Summary
Oracle 모드를 사용하는 거래를 의미하는 expirationTime == 0 조건을 체크하지 않아 모든 Oracle 모드 거래가 작동하지 않는다.
Keyword
bug, logic flaw
Vulnerability
Blur Exchange는 Oracle 모드가 있다. 이를 이용하면 거래 취소를 오프체인에서 할 수 있다. 기존에는 거래의 expirationTime 데이터를 0으로 셋팅하면 Oracle 모드를 이용한다는 의미였다. 하지만 리팩토링을 하며 expirationTime이 0인 거래를 처리하지 않는 가드가 추가되었다.
기존의 expirationTime 확인 로직은 다음과 같다. _canSettleOrder 에서 expirationTime == 0 || block.timestamp < expirationTime로 expirationTime가 0일 때를 예외적으로 처리하고 있다.
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)
);
}
function _canSettleOrder(uint256 listingTime, uint256 expirationTime)
view
internal
returns (bool)
{
return (listingTime < block.timestamp) && (expirationTime == 0 || block.timestamp < expirationTime);
}
리팩토링된 _validateOrderParameters를 살펴보자. (order.listingTime < block.timestamp) && (block.timestamp < order.expirationTime) 가 추가되었다. 여기서 기존의 expirationTime == 0 || 조건이 빠졌다.
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)
);
}이로 인해 Oracle을 사용하는 거래가 더이상 작동하지 않는다.
Impact
Oracle 모드를 사용하는 모든 거래가 작동하지 않는다.
Mitigation
기존과 동일하게 expirationTime == 0일 때를 예외적으로 허용한다.
tags: bughunting, blur exchange, smart contract, solidity, nft marketplace, logic flaw, severity medium