# User can brick the `Bracket` contract by inputing malicious `txData`

Malicious txData in performUpkeep leaves 1 wei residual allowance, causing safeApprove to revert and bricking swaps for that token in Bracket/OracleLess.

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

**Target:** Bracket/OracleLess swap contracts (performUpkeep/execute)
**Root cause:** execute() uses legacy safeApprove which reverts when existing allowance is non-zero; attacker-controlled txData can consume amountIn-1 leaving 1 wei allowance.
**Steps:**
1. Create an order so it becomes fulfillable via performUpkeep.
2. Call `performUpkeep(performData)` with crafted txData targeting a swap router that pulls `amountIn - 1` of tokenIn.
3. execute() calls `tokenIn.safeApprove(target, amountIn)` then `target.call(txData)`; router spends amountIn-1, leaving 1 wei allowance.
4. Subsequent swaps with same tokenIn revert at `safeApprove` because allowance != 0 and value != 0.
**How found:** Code review of execute()'s use of legacy safeApprove combined with caller-controlled txData in performUpkeep; noticed residual allowance breaks subsequent approvals.
**Exploitation:** Attacker (any upkeep caller) supplies malicious txData to a swap target that consumes amountIn-1 tokens, leaving 1 wei residual approval; all future swaps of that tokenIn revert, locking user funds in the contract.
**Escalation:** Repeat per token to brick swapping functionality for every ERC20 supported, locking all users' funds.
**Insight:** When a contract passes caller-supplied calldata to an arbitrary target after approving it, check whether the target can leave residual allowance; legacy safeApprove reverts on non-zero-to-non-zero, so 1 wei leftover is a permanent DoS per token.

