Malicious user can spam orders that expire immediately or cancel them immediately to wipe out legit orders from a book with orders only on one side
The order book allows limit orders with a cancel timestamp only one second in the future, and when a side of the book is full the worst-priced order is evicted to make room for a new one. An attacker can therefore place many higher-priced orders that expire almost immediately, evicting legitimate orders from a one-sided book, and then let the orders expire or cancel them to recover funds.
Submitted by gesha17
clob/CLOB.sol #L592
When creating an order, there are no restrictions on a minimum time the order can be valid, meaning a user can create an order with a cancelTimestamp that is the very next second.
Also, there is an upper bound on how many limits each side of a book can have - maxNumLimitsPerSide. This is enforced during limit creation - if the book is full, the worst limit will be removed:
https://github.com/code-423n4/2025-07-gte-clob/blob/main/contracts/clob/CLOB.sol#L592
/// @dev Performs the core matching and placement of a bid limit order into the book
function _executeBidLimitOrder(Book storage ds, Order memory newOrder, LimitOrderType limitOrderType)
internal
returns (uint256 postAmount, uint256 quoteTokenAmountSent, uint256 baseTokenAmountReceived)
{
if (limitOrderType == LimitOrderType.POST_ONLY && ds.getBestAskPrice() <= newOrder.price) {
revert PostOnlyOrderWouldFill();
}
// Attempt to fill any of the incoming limit order that's overlapping into asks
(uint256 totalQuoteSent, uint256 totalBaseReceived) = _matchIncomingBid(ds, newOrder, true);
// NOOP, there is no more size left after filling to create a limit order
if (newOrder.amount < ds.settings().minLimitOrderAmountInBase) {
newOrder.amount = 0;
return (postAmount, totalQuoteSent, totalBaseReceived);
}
// The book is full, pop the least competitive order (or revert if incoming is the least competitive)
> if (ds.bidTree.size() == maxNumLimitsPerSide) {
uint256 minBidPrice = ds.getWorstBidPrice();
if (newOrder.price <= minBidPrice) revert MaxOrdersInBookPostNotCompetitive();
_removeNonCompetitiveOrder(ds, ds.orders[ds.bidLimits[minBidPrice].tailOrder]);
}
// After filling, the order still has sufficient size and can be placed as a limit
ds.addOrderToBook(newOrder);
postAmount = ds.getQuoteTokenAmount(newOrder.price, newOrder.amount);
return (postAmount, totalQuoteSent, totalBaseReceived);
}
As a result, this opens an attack vector where a malicious user can wipe out all legit orders from a book by submitting many orders of higher prices that expire immediately. The attacker can get around the maximum number of limits per transaction by using separate accounts. There is little risk to the attacker, because unless the orders are fulfilled immediately - within the very next second, they will expire and can just be refunded.
An alternative attack to this one would be one where the attacker immediately cancels the orders via cancel() in the very next transaction.
Note that this attack is only feasible on order books that have active orders only on one side of the book. As orders of higher prices on the other side would naturally be filled by the attacker’s orders.
Recommended Mitigation Steps
Enforce a minimum order liveness time - e.g. 10 minutes. This will significantly increase the risk of the attacker having their orders fulfilled and essentially selling a lot of tokens at a higher than market price. Also, make sure the orders cannot be canceled via cancel() during this minimum liveness period.
View detailed Proof of Concept
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the absence of a minimum order liveness period combined with eviction of the worst-priced order when the book is full, allowing cheap, short-lived orders to displace legitimate ones.
Impact
Legitimate orders on a one-sided book could be wiped out, and the attacker risks little because unfilled orders expire and are refunded; the attack is not feasible where the other side of the book has orders that would fill the attacker's orders.
What the attacker needed
A one-sided order book; multiple accounts to bypass per-tx limit; funds to place the orders
The fix
A minimum order liveness time (for example ten minutes) should be enforced, and orders should not be cancellable during that period.
How it was found
- Identify an order book that has active orders on only one side.
- Submit many limit orders at higher prices with a cancel timestamp one second ahead, using separate accounts to bypass the per-transaction limit.
- Each new order evicts the worst-priced existing order once the book is full.
- Let the attacker's orders expire (or cancel them in the next transaction) so the funds are refunded.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A limit order is an instruction to buy or sell at a chosen price, and it stays in a list (the order book) until it is filled or expires. The book only holds a fixed number of orders per side, so when it is full the least competitive order is pushed out. Because an order can be set to expire in one second, someone can flood the book with slightly better-priced orders that push out real orders, then let their own orders expire and get their money back.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.