Ineffective minimum order size check for ASK limit orders can lead to Denial of Service
The minimum order size check for ASK limit orders compares the quote value (base amount times price) rather than the base amount, so an attacker can place many tiny orders at an absurdly high price and still pass the check. A large batch of such unfilled ImmediateOrCancel orders makes the cron auction spend excessive time cancelling and refunding them, which could cause block timeouts, and a large number of orders can also make the owner's force-cancel message run out of gas.
berndartmueller Follow with haxagon
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-09-dango-dex-judging/issues/416
Found by
berndartmueller, haxagon
Summary
The minimum order size check for ASK orders during order creation is ineffective, allowing the creation of a large number of economically insignificant ImmediateOrCancel (IOC) orders. During the cron-based auction, these orders are canceled and refunded, which can consume excessive execution time (and gas, but the cron is using an infinite gas meter, thus no OOG errors), causing block timeouts (e.g., when pairing with Tendermint/CometBFT).
Additionally, the owner-callable OwnerMsg::ForceCancelOrders message can run out of gas when attempting to forcefully cancel all orders (not limited to IOC orders!).
Root Cause
In order_creation.rs:103-110, the pre-configured pair.min_order_size is checked against amount_in_quote. For an ASK order, amount_in_quote is calculated as base * price. A malicious user can bypass this check by providing a minimal amount of the base asset (e.g., 1 wei) and an arbitrarily high price (limit order). This creates a valid limit order that is practically guaranteed not to be filled.
103: ensure!(
104: amount_in_quote >= pair.min_order_size,
105: "order size ({} {}) is less than the minimum ({} {})",
106: amount_in_quote,
107: order.quote_denom,
108: pair.min_order_size,
109: order.quote_denom
110: );
When the cron_execute function runs, all unfilled IOC orders are collected into memory and then processed for cancellation and refunds, potentially causing block timeouts due to the high execution time required to handle a large number of orders.
Additionally, a large number of such orders will cause the owner-callable OwnerMsg::ForceCancelOrders message to consume a significant amount of gas, potentially exceeding the block/transaction gas limit and preventing the cancellation of all orders. As this is not limited to IOC orders, the attacker has no rush to create a large number of orders quickly as GTC orders will remain open indefinitely.
Internal Pre-conditions
- An attacker needs to create a large number of ASK limit orders.
- The orders must be of type
TimeInForce::ImmediateOrCancelto affect the cron job or GTC orders to affect the owner-callable force cancel function. - Each order must have a minimal
baseamount and a very high, unrealisticpriceto remain unfilled, while still satisfying themin_order_sizecheck in thequotecurrency.
External Pre-conditions
None
Attack Path
- An attacker identifies a trading pair and its
min_order_size. - The attacker creates a large number of
ImmediateOrCancelASK limit orders. For each order, they provide a minimal amount of the base asset (e.g., 1 wei) and a very high price, such that1 wei * priceis greater thanmin_order_size. - During the cron auction, it requires an excessive amount of time to process and cancel all these IOC orders, potentially leading to block timeouts.
- The
OwnerMsg::ForceCancelOrdersfunction may run out of block/transaction gas when attempting to cancel all orders, preventing the owner from managing the order book effectively.
Impact
- Block production can be affected by a malicious actor who creates a large number of ASK IOC limit orders.
- The owner may be unable to cancel all orders due to gas limitations when using the
OwnerMsg::ForceCancelOrdersfunction.
PoC
Mitigation
For ASK orders, consider enforcing a minimum order size on the base asset amount in addition to the check on the quote asset value
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
The minimum order size check for ASK orders validates the quote-denominated value (base amount multiplied by price) instead of the base amount, so a minimal base amount with an arbitrarily high price passes the check.
Impact
Block production could be affected by the excessive processing time, and the owner may be unable to cancel all orders because the force-cancel message can exceed the gas limit; the text notes the cron uses an infinite gas meter so it does not hit out-of-gas errors itself.
What the attacker needed
Ability to create many orders; a trading pair with a minimum order size; minimal base amount per order
The fix
For ASK orders, the minimum order size should also be enforced on the base asset amount, not only on the quote value.
How it was found
- Identify a trading pair and its minimum order size.
- Create many ImmediateOrCancel ASK limit orders, each with a minimal base amount and a very high price so the quote value passes the minimum check.
- During the cron auction, the system spends excessive time cancelling and refunding all these unfilled orders, potentially causing block timeouts.
- The owner's force-cancel message may run out of gas when trying to cancel all orders.
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 trading platform has a rule that each order must be worth at least a certain minimum. For sell orders the platform worked out the order's value by multiplying the tiny amount being sold by the asking price, so someone could sell a near-zero amount at a huge price and still look like they met the minimum. By creating thousands of these pointless orders, the attacker makes the platform's automatic cleanup job do far too much work, which could slow or stall the system.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.