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

Cancelled orders in Oku Bracket/OracleLess/StopLimit could still be modified, letting users withdraw the same tokens twice and drain contracts.

- Payout: Audit contest
- Severity: high
- Program: Oku
- Found by: 0x37
- Disclosed: 2024-11-22
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-11-oku-judging/issues/542
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-11-oku%3AH-4
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** Oku automatedTrigger contracts (Bracket, OracleLess, StopLimit)
**Root cause:** modifyOrder lacks a check that the order was already cancelled, so a cancelled order's amountIn can be reduced and re-withdrawn.
**Steps:**
1. Create order with `amountIn = 1e18`.
2. Cancel the order, withdrawing 1e18 tokens.
3. Call `modifyOrder` reducing `amountIn` to 1, withdrawing 1e18 - 1 of already-withdrawn tokens.
4. Repeat to drain contract balance.
**How found:** Code review of modifyOrder in OracleLess/Bracket/StopLimit noting absence of cancelled-state validation.
**Exploitation:** User cancels order to withdraw full amountIn, then modifies the cancelled order to a tiny amountIn, triggering a second withdrawal of the difference; repeated until contract tokens drained.
**Insight:** Check state-transition guards on modify paths for terminal states (cancelled/filled) — refund logic that trusts amountIn can be re-triggered after cancellation.

