The OrderBook contract does not automatically handle expired orders, which could lead to tokens being locked in the contract indefinitely if sellers forget to cancel their expired orders. This creates a potential asset freeze vulnerability.
When a sell order is created, the seller's tokens are transferred to the contract and locked until the order is filled, cancelled, or expired. However, when an order expires, the tokens remain locked in the contract until the seller explicitly calls the cancelSellOrder function. This creates a scenario where sellers may forget to cancel their expired orders, resulting in their tokens being locked in the contract indefinitely. For large token amounts or in cases where many users forget to cancel their orders, significant value could be unnecessarily locked in the contract.
A seller creates a sell order by calling createSellOrder, transferring their tokens to the contract.
The order has a deadline (maximum 3 days from creation).
If the order is not filled before the deadline, it expires.
The contract correctly prevents buyers from purchasing expired orders.
However, the tokens remain locked in the contract until the seller explicitly calls cancelSellOrder.
If the seller forgets to cancel the expired order, their tokens remain locked indefinitely.
Impact: Medium - Tokens can be locked in the contract indefinitely, but the original owner can still recover them by cancelling the order.
Likelihood: High - It is common for users to forget to cancel expired orders, especially in a decentralised environment where users may not be actively monitoring all their transactions.
OrderBook.sol
Implement a function to allow anyone to cancel expired orders, which will return the tokens to the original seller. This will prevent tokens from being locked indefinitely and will improve the user experience.
The proposed fix allows anyone to cancel an order that has passed its deadline, returning the tokens to the original seller. This ensures that tokens do not remain locked in the contract indefinitely if sellers forget to cancel their expired orders.
By design only `seller` can call `cancelSellOrder()` on their `order`. But when an `order` expires, and the `seller` doesn't have access to the protocol, the expired `order `should be be able to be cancelled by an `admin`.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.