# ZongZi: reward manipulation via burnToHolder drains WBNB pair

ZongZi token's burnToHolder/receiveRewards reward logic was manipulated via flash-loan-funded swap cycles on PancakeSwap, draining ~$223K in WBNB.

- Payout: Real-world hack
- Severity: high
- Program: ZongZi
- Analysis by: DeFiHackLabs
- Disclosed: 2024-03-25
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-03/ZongZi_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20240325-zongzi
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:accounting-error vuln:flash-loan vuln:oracle-manipulation vuln:reward-distribution

**Target:** BEP-20 token reward/burn mechanism on PancakeSwap V2 pair
**Root cause:** burnToHolder and receiveRewards reward accounting can be gamed by cycling swaps to inflate the caller's token balance/rewards before burning, letting the attacker extract more WBNB than deposited.
**Steps:**
1. Flash-swap WBNB from BUSDT_WBNB pair via `swap(0, amount1Out, this, ...)`
2. In pancakeCall, fund Helper with borrowed WBNB
3. Helper: swap 1e17 WBNB->ZongZi, then all ZongZi->WBNB, then remaining WBNB->ZongZi to build ZongZi balance
4. Compute amounts[0] via `Router.getAmountsIn(amountOut, [ZongZi,WBNB])` where amountOut = ZongZi.balance - 1e9
5. Call `ZZF.burnToHolder(amounts[0], msg.sender)` then `ZZF.receiveRewards(address(this))`
6. Swap all ZongZi->WBNB, wrap BNB, return WBNB to caller
7. Repay BUSDT_WBNB with `_amount1 * 10026/10000`
**Exploitation:** Attacker flash-borrows WBNB, uses Helper to perform repeated WBNB<->ZongZi swaps to inflate ZongZi holdings, then calls burnToHolder with a computed amount and receiveRewards to harvest rewards, swaps back to WBNB, repays flash loan with 0.26% fee, keeps profit.
**Insight:** Reward/burn functions that read live pair balances or caller token balances are manipulable within a single tx via swap cycles; check whether burnToHolder's amount argument and receiveRewards payout depend on state an attacker can inflate with flash-loan-funded swaps.
