OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
Submission Details
Impact: medium
Likelihood: medium
Invalid

[I-01] Sellers can indefinitely extend their order deadlines by repeatedly amending

Author Revealed upon completion

Root + Impact

Description

Normal Behavior:
The amendSellOrder() function allows sellers to update their order’s amount, price, and deadline. Each amendment resets the deadline to a new timestamp (block.timestamp + duration) provided it’s within the MAX_DEADLINE_DURATION of 3 days.

Specific Issue:
There is no restriction on total lifetime of an order. Sellers can continually call amendSellOrder() just before the order expires to extend the deadline indefinitely, keeping stale orders on-chain forever. This creates a denial-of-cleanup problem and allows the on-chain order book to be filled with near-permanent spam.

function amendSellOrder(...) public {
...
@> uint256 newDeadlineTimestamp = block.timestamp + _newDeadlineDuration;
...
@> order.deadlineTimestamp = newDeadlineTimestamp;
}

Risk

Likelihood:

This behavior occurs every time a seller chooses to keep extending their order, which is common in slow markets.

There is no built-in limit, cooldown, or lifetime cap, so repeated amendments are trivial and expected over long durations.

Impact:

Stale or low-quality orders can linger forever in the order book, impacting UX and indexing tools.

Attackers can spam orders that never expire, bloating the contract state and potentially increasing storage/gas costs over time.

Proof of Concept

This creates a pseudo-permanent order that never expires, defeating the purpose of a deadline system.

uint256 orderId = orderBook.createSellOrder(wETH, 1e18, 10e6, 3 days);
// Extend it every few blocks to keep it alive forever
for (uint i = 0; i < 100; i++) {
orderBook.amendSellOrder(orderId, 1e18, 10e6, 3 days);
// now deadline is pushed again and again: block.timestamp + 3 days
}

Recommended Mitigation

- uint256 newDeadlineTimestamp = block.timestamp + _newDeadlineDuration;
- order.deadlineTimestamp = newDeadlineTimestamp;
+ uint256 creationTime = orderCreationTimestamps[_orderId];
+ require(
+ block.timestamp + _newDeadlineDuration <= creationTime + MAX_TOTAL_LIFETIME,
+ "Exceeds max order lifetime"
+ );
+ order.deadlineTimestamp = block.timestamp + _newDeadlineDuration;
de

Additional changes

+ orderCreationTimestamps[orderId] = block.timestamp;
Updates

Lead Judging Commences

yeahchibyke Lead Judge
5 days ago
yeahchibyke Lead Judge about 13 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.