# Missing swap-withdrawal validation enables accumulated token drainage

GatewayCrossChain.onCall swaps to params.toToken but withdraws decoded.targetZRC20 without matching them, letting attackers drain accumulated token balances.

- Payout: Audit contest
- Severity: high
- Program: Dodo Cross Chain Dex
- Found by: 0xEkko
- Disclosed: 2025-05-29
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2025-05-dodo-cross-chain-dex-judging/issues/158
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-05-dodo-cross-chain-dex%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** GatewayCrossChain.sol onCall cross-chain swap/withdraw handler
**Root cause:** onCall performs _doMixSwap producing params.toToken output but then withdraws decoded.targetZRC20 without validating the two token addresses match, so the contract pays out a different (accumulated) token than the swap produced.
**Steps:**
1. Monitor GatewayCrossChain balance for accumulated high-value ZRC20 (e.g. ETH.ZRC20).
2. Craft payload: swapDataZ swaps cheap input (BTC.ZRC20) to USDC.ZRC20, but set targetZRC20 to the accumulated ETH.ZRC20.
3. Call `gatewaySendA.depositAndCall(targetContract, attackAmount, btc, dstChainId, payload)` with encoded message.
4. ZetaChain swaps to USDC but withdraws targetZRC20=ETH.ZRC20 using accumulated balance, sending ETH to attacker receiver on dest chain.
5. Repeat for each accumulated token type.
**How found:** Code review of onCall: noticed swap uses params.toToken while withdraw functions use decoded.targetZRC20 with no equality check between them.
**Exploitation:** Attacker supplies a small cheap input token (0.02 BTC ~$1000), configures swap output to a low-value token but sets targetZRC20 to a high-value accumulated token; the contract's existing balance of targetZRC20 funds the withdrawal, netting ~$2.5M per cycle with >99% drainage.
**Escalation:** Repeat across multiple accumulated token types to drain entire contract balance.
**Insight:** In cross-chain message handlers, always verify that the token produced by an internal swap equals the token used for the subsequent withdrawal/transfer; mismatched fields in user-supplied payloads let attackers spend the contract's own accumulated balances.

