Skip to content
DoS Audit finding Intermediate

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.

Rust
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::ImmediateOrCancel to affect the cron job or GTC orders to affect the owner-callable force cancel function.
  • Each order must have a minimal base amount and a very high, unrealistic price to remain unfilled, while still satisfying the min_order_size check in the quote currency.

External Pre-conditions

None

Attack Path

  1. An attacker identifies a trading pair and its min_order_size.
  2. The attacker creates a large number of ImmediateOrCancel ASK limit orders. For each order, they provide a minimal amount of the base asset (e.g., 1 wei) and a very high price, such that 1 wei * price is greater than min_order_size.
  3. During the cron auction, it requires an excessive amount of time to process and cancel all these IOC orders, potentially leading to block timeouts.
  4. The OwnerMsg::ForceCancelOrders function 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::ForceCancelOrders function.

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

The original report as published on Sherlock, by berndartmueller. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

  1. Identify a trading pair and its minimum order size.
  2. 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.
  3. During the cron auction, the system spends excessive time cancelling and refunding all these unfilled orders, potentially causing block timeouts.
  4. 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.

More by berndartmueller

View all

97 more disclosed reports, best first.

More from Dango DEX

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.