In the OrderBook.sol::amendSellOrder function, sellers are allowed to amend their existing sell orders, including updating the deadline. However, the function currently lacks a mechanism to prevent sellers from repeatedly extending the deadline. By calling this function multiple times, a seller can continuously increase the order's deadline without restriction, effectively bypassing the intended maximum deadline constraint.
Because there's no upper bound on the cumulative deadline over multiple amendments, sellers can perpetually delay the expiration of their orders. This undermines the deadline enforcement mechanism intended by the contract.
This issue can be triggered every time a seller invokes the amendSellOrder function and provides a new duration close to the MAX_DEADLINE_DURATION, effectively resetting the deadline over and over.
The seller can extend the order's deadline indefinitely by repeatedly amending the order with durations just under the maximum allowed. This violates the MAX_DEADLINE_DURATION invariant and allows sell orders to remain active indefinitely, which may have implications for market fairness and gas efficiency.
Add the following test case to TestOrderBook.t.sol, and run it using the command:
forge test --mt test_amendSellOrderWithInfiniteDeadline -vvv
Introduce an additional check in the amendSellOrder function to ensure that the new cumulative deadline does not exceed the MAX_DEADLINE_DURATION from the order’s original creation time or block timestamp.
Example mitigation:
This ensures that regardless of how many times the deadline is amended, the total duration never exceeds the predefined maximum.
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.