Skip to content
Business logic Audit finding Intermediate

Claim liquidation escrow

A liquidator could create a second account and execute a trade between their own accounts with large slippage, then claim the liquidation escrow for that slippage. This allowed them to get reimbursed for slippage they caused themselves.

gpersoon Follow

Originally disclosed on Code4rena

Submitted by gpersoon

A liquidator can always claim the liquidation escrow in the following way:

  • create a second account
  • setup a complimentary trade in that second account, which will result in a large slippage when executed
  • call executeTrade (which everyone can call), to execute a trade between his own two accounts with a large slippage
  • the slippage doesn’t hurt because the liquidator owns both accounts
  • call claimReceipt with the receiptId of the executed order, within the required period (e.g. 15 minutes)

L67

function executeTrade(Types.SignedLimitOrder[] memory makers, Types.SignedLimitOrder[] memory takers) external override {

L394

function claimReceipt( uint256 receiptId, Perpetuals.Order[] memory orders, address traderContract) external override {

Recommend to perhaps limit who can call executeTrade.

raymogg (Tracer) acknowledged and confirmed:

Valid issue which would allow someone to get reimbursed for slippage against themselves.

The Trader contract will have whitelisted relayers added to prevent issues like this (similar to #119)

The original report as published on Code4rena, by gpersoon. 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 executeTrade function was callable by anyone, allowing a liquidator to trade between their own accounts and then claim slippage reimbursement.

Impact

A liquidator could get reimbursed for slippage against themselves, potentially draining the liquidation escrow.

What the attacker needed

A liquidator account; ability to create a second account; call executeTrade and claimReceipt

The fix

The Trader contract should have whitelisted relayers to prevent unauthorised calls to executeTrade.

How it was found

  1. Create a second account.
  2. Set up a complimentary trade in that second account that will result in large slippage when executed.
  3. Call executeTrade to execute a trade between the two accounts with large slippage.
  4. Call claimReceipt with the receiptId of the executed order within the required period.

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.

When a trade happens at a worse price than expected, the difference is called slippage. Normally, a liquidator who suffers slippage can claim compensation from an escrow. Here, a liquidator could trade with themselves, create fake slippage, and then claim that compensation, effectively taking money from the escrow.

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 gpersoon

View all

47 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.