# BabyDogeCoin: unprotected fee-swap sandwich drains 441 BNB

BabyDogeCoin's fee-to-liquidity swap lacked slippage protection, letting an attacker sandwich it via flash-loaned Venus collateral to drain ~441 BNB.

- Payout: Real-world hack
- Severity: high
- Program: BabyDogeCoin02
- Analysis by: DeFiHackLabs
- Disclosed: 2023-06-21
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2023-06/BabyDogeCoin02_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20230621-babydogecoin02
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:business-logic vuln:flash-loan vuln:oracle-manipulation

**Target:** BEP-20 token fee-to-liquidity swap mechanism on BSC
**Root cause:** The token's automatic numTokensSellToAddToLiquidity swap executes on the AMM with zero slippage protection (amountOutMin=0), so an attacker who controls pool state at trigger time can sandwich it.
**Steps:**
1. Flash-loan USDT and BUSD from PancakeSwap V3 pool `0x4f3126d5DE26413AbDCF6948943FB9D0847d9818`.
2. Supply USDT/BUSD to Venus (vUSDT/vBUSD mint), enter markets, borrow WBNB against collateral via `vBNB.borrow`.
3. Swap WBNB to BabyDogeCoin on BabyDogeRouter and add liquidity via FeeFreeRouter to seed position.
4. Trigger the token's fee-swap by transferring BabyDogeCoin to the token contract: `BabyDogeCoin.transfer(address(BabyDogeCoin), transferAmount)` then `BabyDogeCoin.transfer(address(this), 1)`.
5. Sandwich the unprotected swap: buy BabyDogeCoin before, let the contract's `numTokensSellToAddToLiquidity` swap execute at manipulated price, then sell back for WBNB.
6. Repay flash loan and keep profit (~441 BNB).
**How found:** Researcher (Hexagate) observed the token's `numTokensSellToAddToLiquidity` swap path lacked an amountOutMin, making it sandwichable whenever the threshold is crossed.
**Exploitation:** Attacker flash-loaned USDT/BUSD, supplied to Venus to borrow WBNB, used WBNB to acquire BabyDogeCoin and seed liquidity, then triggered the token's internal fee-to-liquidity swap while holding a sandwich position around it. Because the contract's swap had no slippage limit, the attacker extracted value from the pool and repaid the flash loan, netting ~441 BNB.
**Escalation:** Chained flash loan + Venus collateralized borrow to amplify capital, then sandwiched the victim's unprotected internal swap.
**Insight:** Look for tokens whose internal fee/liquidity swap calls AMM swap with amountOutMin=0; any transfer that crosses the threshold is a sandwichable event, and flash loans + lending collateral let you scale the position.

