# CFC: skim() reserve manipulation drains PancakeSwap pair

CFC token on BSC was drained via repeated skim() calls on its PancakeSwap pair, exploiting a balance/reserve mismatch to steal ~$16k.

- Payout: Real-world hack
- Severity: high
- Program: CFC
- Analysis by: DeFiHackLabs
- Disclosed: 2023-06-15
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2023-06/CFC_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20230615-cfc
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity technique:chained vuln:accounting-error vuln:business-logic

**Target:** PancakeSwap LP pair for CFC/SAFE token
**Root cause:** The CFC token's transfer logic or the pair's skim() function allowed an attacker to repeatedly extract value by manipulating the pair's token balance relative to reserves, likely due to a fee-on-transfer or rebasing mechanism that desynchronized balances.
**Steps:**
1. Take a flash loan of BEP20USDT from DPPOracle1, then chain flash loans from DPPOracle2, DPPOracle3, DPP, and DPPAdvanced.
2. Swap 13,000 USDT for SAFE tokens via PancakeRouter.
3. Call CakeLP.swap(1, amountOut - (amountOut/250) - 1, address(this), hex"307831323334") to borrow CFC tokens (flash swap).
4. Transfer all CFC balance to CakeLP, then call CakeLP.skim(address(this)) to extract excess tokens.
5. Repeat 18 times: transfer CFC to CakeLP leaving 1 wei, then skim.
6. Swap a portion of CFC for SAFE, then add liquidity to CakeLP via mint.
7. Swap remaining SAFE for USDT and repay flash loans.
**Exploitation:** Attacker used nested flash loans to obtain capital, performed a flash swap to borrow CFC, then repeatedly called skim() after transferring CFC to the pair, exploiting the difference between the pair's balance and reserves to extract CFC tokens. The extracted CFC was swapped for SAFE and then USDT, netting ~$16k.
**Insight:** When a token has fee-on-transfer or rebasing mechanics, the pair's skim() can be abused to extract tokens if the balance exceeds reserves; repeated skim calls after tiny transfers can drain value.

