# MevBot: unauthenticated pancakeCall drains token balances

MEV bot's unauthenticated pancakeCall callback let anyone spoof a PancakeSwap pair and drain all USDT, WBNB, BUSD and USDC held by the contract.

- Payout: Real-world hack
- Severity: high
- Program: MevBot private tx
- Analysis by: DeFiHackLabs
- Disclosed: 2022-09-13
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-09/BNB48MEVBot_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20220913-bnb48mevbot
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:access-control vuln:business-logic

**Target:** BSC MEV bot contract with public pancakeCall callback
**Root cause:** The bot's pancakeCall callback trusted the caller and the token0()/token1() return values without verifying msg.sender is a real PancakeSwap pair, so an attacker contract could invoke it directly and have the bot transfer its own token balances out.
**Steps:**
1. Deploy attacker contract implementing token0()/token1() returning the target token address and a no-op swap().
2. Read the bot's USDT/WBNB/BUSD/USDC balances.
3. Call `Bot.pancakeCall(address(this), USDTAmount, 0, abi.encodePacked(bytes12(0), bytes20(address(this)), bytes32(0), bytes32(0)))` with token0/token1 set to USDT.
4. Repeat the same call for WBNB, BUSD and USDC balances.
**Exploitation:** Attacker contract impersonates a PancakeSwap pair by exposing token0()/token1() and swap(); the bot's pancakeCall then pays out the requested amount of the token it holds to the attacker, repeated per token to drain the contract.
**Insight:** MEV/sniper bots expose public swap callbacks (pancakeCall/uniswapV2Call) that assume msg.sender is a legitimate pair; check whether the callback validates the caller and derives token addresses from msg.sender rather than from attacker-controlled token0()/token1().

