Skip to content
Business logic Audit finding Intermediate

`OwnerMsg::ForceCancelOrders` is unusable due to the DEX contract lacking a `receive` function to accept refunds from cancelled passive liquidity orders

The DEX contract cannot receive coin transfers because it lacks a receive function, so cancelling passive liquidity orders triggers a refund transfer to the contract itself that fails. This makes the emergency ForceCancelOrders message revert, preventing administrators from cancelling all orders.

berndartmueller Follow with blockace, globalace and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-09-dango-dex-judging/issues/414

Found by

berndartmueller, blockace, globalace, haxagon, klaus

Summary

The OwnerMsg::ForceCancelOrders message execution will revert if any passive liquidity orders are present, preventing administrators from cancelling all orders in an emergency, because the DEX contract itself cannot receive the order refund due to a missing receive function.

Root Cause

In dango/dex/src/execute/order_cancellation.rs:18-31, the cancel_all_orders function iterates through all orders to cancel them. For passive liquidity orders, the designated user is the DEX contract itself. When cancel_order is called for a passive order, it generates a refund transfer to the DEX contract's address. However, the DEX contract lacks a receive entry point to accept incoming coin transfers, resulting in the entire transaction failing.

Internal Pre-conditions

  1. At least one passive liquidity order exists in the DEX.
  2. An administrator sends the OwnerMsg::ForceCancelOrders message to cancel all orders forcefully.

External Pre-conditions

  1. The protocol is in an emergency state where some orders need to be cancelled to protect user funds.

Attack Path

  1. In an emergency situation, an administrator uses OwnerMsg::ForceCancelOrders to forcefully cancel all orders.
  2. The function begins iterating through orders. When it processes the passive liquidity order, it attempts to execute a transfer of the order's funds back to the order.user (the DEX contract).
  3. The underlying framework attempts to call the receive function on the DEX contract to deliver the funds.
  4. The call fails because the receive function is not implemented on the DEX contract.
  5. This failure causes the entire cancel_all_orders transaction to revert, leaving all orders, including potentially malicious or vulnerable ones, active on the book.

Impact

The OwnerMsg::ForceCancelOrders message, a critical safety mechanism, is rendered unusable.

PoC

N/A

Mitigation

Consider implementing a receive function on the DEX contract to allow it to accept coin transfers. A more direct mitigation would be to modify cancel_order or the loop in cancel_all_orders to detect when the refund recipient is the DEX contract itself and skip the transfer logic, as the funds are already in the contract's possession.

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 DEX contract lacks a receive function to accept refunds for passive liquidity orders whose user is the contract itself, causing the refund transfer to revert.

Impact

The ForceCancelOrders safety mechanism is unusable, so in an emergency all orders remain active on the book.

What the attacker needed

At least one passive liquidity order exists; administrator sends ForceCancelOrders; emergency state requiring cancellation

The fix

The DEX contract should implement a receive function, or cancel_order should skip the refund transfer when the recipient is the DEX contract itself.

How it was found

  1. An administrator sends the ForceCancelOrders message to cancel all orders.
  2. The cancellation loop reaches a passive liquidity order whose user is the DEX contract.
  3. A refund transfer is attempted to the DEX contract address.
  4. The framework tries to call the receive function on the DEX contract.
  5. The call fails because no receive function exists, reverting the whole transaction.

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 smart contract can hold funds, but to accept a direct transfer it often needs a special function called receive. Here the exchange contract does not have that function, so when the emergency cancel tries to send a refund back to the exchange itself, the transfer fails and the whole cancellation stops.

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.

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.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.