Skip to content
Business logic Audit finding Intermediate

Users can modify a cancelled order, withdrawing the same tokens twice

A cancelled order could still be modified, allowing a user to withdraw the same tokens twice. An attacker could repeatedly cancel and modify orders to drain all tokens from the contracts.

0x37 Follow with 0x486776, 0xaxaxa and 43 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-oku-judging/issues/542

Found by

0x37, 0x486776, 0xaxaxa, 0xc0ffEE, 62616279727564696e, Bigsam, Breaker, BugPull, Cayde-6, Contest-Squad, DenTonylifer, ExtraCaterpillar, IvanFitro, JinxSalamV2, John44, KiroBrejka, NoOneWinner, NoWinner, PNS, Pablo, Ragnarok, Tri-pathi, Uddercover, WildSniper, c-n-o-t-e, etherhood, gajiknownnothing, hals, lanrebayode77, moray5554, mxteem, newspacexyz, onthehunt, oualidpro, phoenixv110, rudhra1749, s0x0mtee, safdie, silver_eth, t.aksoy, t0x1c, vinica_boy, xiaoming90, zhigang, zhoo, zxriptor

Summary

In Bracket, OracleLess and StopLimit a user can modify a canceled order, allowing them to withdraw the order tokens twice.

Root Cause

In Bracket, OracleLess and StopLimit there is no validation on whether an order has already been canceled before modifying it: https://github.com/sherlock-audit/2024-11-oku/blob/ee3f781a73d65e33fb452c9a44eb1337c5cfdbd6/oku-custom-order-types/contracts/automatedTrigger/OracleLess.sol#L171-L225

This allows users to cancel an order, withdrawing all of the tokens, and after that modifying it by reducing the amountIn to 1, withdrawing the rest of the tokens for a second time.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

  1. User creates an order with amountIn set to 1e18.
  2. The user cancels the order, withdrawing 1e18 of the tokens.
  3. Finally, they modify the order, decreasing amountIn to 1, withdrawing 1e18 - 1 of the already withdrawn tokens.
  4. The attack can be performed several times until all of the contract's tokens are drained.

Impact

Bracket, OracleLess and StopLimit can be drained.

PoC

No response

Mitigation

Make sure that a canceled order cannot be modified,

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/gfx-labs/oku-custom-order-types/pull/1

The original report as published on Sherlock, by 0x37. 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

Likely, the contracts lack a check to prevent modification of orders that have already been cancelled.

Impact

The contracts could be completely drained of tokens.

What the attacker needed

A user account; ability to create and cancel orders

The fix

The contracts should be fixed to prevent modification of cancelled orders.

How it was found

  1. Create an order with a certain amount of tokens.
  2. Cancel the order, withdrawing the tokens.
  3. Modify the cancelled order, reducing the amount to 1, and withdraw the remaining tokens.
  4. Repeat to drain all tokens from the contract.

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 you cancel an order, you should get your tokens back and the order should be closed. But here, the system still let you change the cancelled order, so you could pretend it had a tiny amount and get more tokens back. By doing this over and over, you could take all the tokens from the contract.

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 0x37

View all

79 more disclosed reports, best first.

More from Oku's New Order Types Contract 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.