OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Deadline enforcement uses manipulatable `block.timestamp`

Root + Impact:

Description

  • In normal protocol behavior, a user should not be able to fill an expired order. The buyOrder function includes a deadlineTimestamp check to prevent this.

  • Because the contract relies on block.timestamp, miners can shift the time slightly (up to ~15 seconds). This lets them fill orders that should have already expired, breaking the expected behavior of the protocol.

function buyOrder(uint256 _orderId) public {
Order storage order = orders[_orderId];
// Validation checks
if (order.seller == address(0)) revert OrderNotFound();
if (!order.isActive) revert OrderNotActive();
// @audit-low miners could manipulate block.timestamp to 15secs extra just to place an order even tho time has passed
// deadline timestamp could be 1:00 but miners could manipulate the block backwards 15sec, just so they can place the order.
@> if (block.timestamp >= order.deadlineTimestamp) revert OrderExpired();
order.isActive = false;

Risk

Likelihood:

  • Miners can adjust block.timestamp slightly to favor their own or selected transactions.

  • This becomes especially relevant when orders are filled close to the expiration boundary, which is common in tight trading scenarios or sniping attempts.

Impact:

  • Orders may be filled even though they have technically expired.

  • This breaks time-based guarantees and can be exploited in race conditions.

Proof of Concept:

No PoC required, as the vulnerability is due to protocol-level miner behavior affecting block.timestamp.

Recommended Mitigation

Use Chainlink Automation (or other off-chain services) to flag expired orders based on timestamp and mark them inactive, removing reliance on block.timestamp within user transactions.

Updates

Lead Judging Commences

yeahchibyke Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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