Skip to content
Business logic Audit finding Intermediate

Trader orders can be front-run and users can be denied from trading

The Trader contract allows an attacker to front-run a user's trade by matching the user's counter order with their own order, preventing the user's trade from being filled. This griefing attack can deny trading, especially to liquidators trying to avoid liquidation.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by gpersoon and tensors

The Trader contract accepts two signed orders and tries to match them. Once they are matched and become filled, they can therefore not be matched against other orders anymore.

This allows for a griefing attack where an attacker can deny any other user from trading by observing the mempool and front-running their trades by creating their own order and match it against the counter order instead.

In this way, a trader can be denied from trading. The cost of the griefing attack is that the trader has to match the order themselves, however depending on the liquidity of the order book and the spread, they might be able to do the counter-trade again afterwards, basically just paying the fees.

It could be useful if the attacker is a liquidator and is stopping a user who is close to liquidation from becoming liquid again.

This seems hard to circumvent in the current design. If the order book is also off-chain, the executeTrade could also be a bot-only function.

raymogg (Tracer) disputed (in duplicate)

Marked as a dispute as this is not really an issue. Tracer will initially maintain an off chain order book that is the entry point for users to make orders (and for market makers to interact with).

Orders only get propagated on chain once they have been matched, and they will only be propagated on chain by whitelisted relayers. As such nobody can arbitrarily frontrun the orders with their own.

cemozerr (Judge) commented:

Currently not seeing a whitelisted relayer functionality, so marking this a valid medium risk issue.

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

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 order matching process allows any user to match orders without restriction, so an attacker can front-run and fill a counter order before the intended trader.

Impact

A trader can be denied from trading, which could be used by a liquidator to prevent a user close to liquidation from becoming liquid again.

What the attacker needed

Attacker can observe mempool; attacker can submit orders; victim's order is visible in mempool

The fix

The project disputed the issue, stating that an off-chain order book and whitelisted relayers would prevent front-running, but the judge noted that whitelisted relayer functionality was not yet implemented.

How it was found

  1. Attacker observes a victim's pending trade in the mempool.
  2. Attacker creates their own order that matches the victim's counter order.
  3. Attacker submits the matching order with a higher gas price to front-run the victim.
  4. The attacker's order gets matched first, filling the counter order.
  5. The victim's trade fails because the counter order is already filled.

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.

In a trading system, orders are matched in pairs. If someone else matches one of the orders first, the original trader cannot complete their trade. An attacker can watch pending transactions and quickly submit their own matching order to block the victim's trade.

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 cmichel

View all

196 more disclosed reports, best first.

More from Tracer contest

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.