# Any attacker will steal accumulated ZRC20 tokens from `GatewayTransferNative` contract

Missing msg.value check in withdrawToNativeChain lets attacker pass _ETH_ADDRESS_ to skip transferFrom while message targets real ZRC20, draining accumulated tokens.

- 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/219
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-05-dodo-cross-chain-dex%3AH-2
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:access-control vuln:business-logic

**Target:** GatewayTransferNative.withdrawToNativeChain on ZetaChain
**Root cause:** When zrc20 == _ETH_ADDRESS_, the function skips transferFrom but never validates msg.value >= amount, so the claimed amount is processed against the contract's accumulated balance. The decoded message's targetZRC20 can point to a real ZRC20 token, so downstream withdrawGasFeeWithGasLimit succeeds.
**Steps:**
1. Identify accumulated ZRC20 (e.g. token1Z) held by GatewayTransferNative
2. Craft message via encodeMessage with targetZRC20 = real token1Z address, receiver = attacker
3. Call `withdrawToNativeChain{value: 0}(_ETH_ADDRESS_, stolenAmount, maliciousMessage)`
4. transferFrom skipped due to _ETH_ADDRESS_ branch; no msg.value check
5. Withdrawal processes claimed amount from contract balance, burns ZRC20, sends native token to attacker receiver
**How found:** Code review of withdrawToNativeChain noticed the conditional transferFrom only runs for non-native tokens, and that the amount parameter is trusted without a msg.value check; realized the message's targetZRC20 is decoded independently and can be a real token, decoupling the bypass from the actual withdrawal asset.
**Exploitation:** Attacker sends zero native value, uses _ETH_ADDRESS_ as input token to bypass transferFrom, but encodes a real ZRC20 as targetZRC20 in the message so the gas-fee/withdraw path executes against the contract's own token balance. Contract's ZRC20 is burned and equivalent native tokens are delivered cross-chain to attacker's address; cost is only gas.
**Insight:** When a function branches on a sentinel address (like _ETH_ADDRESS_) to skip a payment check, verify the downstream logic uses the same asset the check was skipped for — if a separate decoded field selects the real asset, the bypass becomes a drain of contract-held balances.

