# IT token: transfer-to-pool mint logic drains USDT pair

IT token's transfer-to-pool logic mints back to the pool, letting an attacker flash-loan USDT and repeatedly swap to drain ~13k USDT from the IT/USDT PancakeSwap pair.

- Payout: Real-world hack
- Severity: medium
- Program: IT
- Analysis by: DeFiHackLabs
- Disclosed: 2024-03-13
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-03/IT_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20240313-it
- Tags: domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:medium tech:evm technique:chained vuln:accounting-error vuln:business-logic vuln:flash-loan

**Target:** BEP-20 token IT and its PancakeSwap V2 IT/USDT pair
**Root cause:** The IT token's transfer logic mints tokens to the pool when tokens are sent to it, so a swap that sends IT to the pair increases reserves in a way that lets the attacker extract more USDT than the constant-product formula should allow.
**Steps:**
1. Flash-borrow 2000 USDT from PancakeSwap V3 pool `0x92b7...3121`.
2. Deploy `Money` via CREATE2, pre-funding it with USDT so its constructor can call back into the test contract.
3. In `hack()`, loop 9 times: `USDT.transferFrom(attacker, IT_USDT, 2000e18)` then compute `mintToPoolIfNeeded(_reserve0 - 1)` to determine the IT amount to swap.
4. Call `IT_USDT.swap(_reserve0 - 1, amountout - 1, attacker, "")` to extract USDT.
5. Repay the 2000 USDT flash loan plus fee to the V3 pool; keep the ~13k USDT profit.
**How found:** Attacker likely noticed the IT token's transfer hook mints to the recipient pool, breaking the constant-product invariant used by the PancakeSwap pair, and modeled the reserve math to find a profitable swap size.
**Exploitation:** Attacker flash-borrows 2000 USDT, then repeatedly transfers USDT into the IT/USDT pair and swaps IT out. Because the IT token mints to the pool on transfer, the pair's reserves are manipulated so each swap yields more USDT than fair, netting ~13k USDT after repaying the flash loan.
**Escalation:** Looping the swap 9 times compounds the mispricing to maximize extraction.
**Insight:** When a token mints/burns on transfer to a specific address (like its own LP pair), the AMM's reserve accounting diverges from the constant-product formula; simulate reserve deltas per swap to find a size where output exceeds fair value.
