LPC Token Hack
What happened
LPC, a BEP20 token traded on PancakeSwap, was exploited on 25 July 2022. A flaw in the token's _transfer logic let an address send tokens to itself and end up with more than it started with. The attacker flash-borrowed almost the entire LPC reserve of the PancakeSwap LPC/USDT pool, self-transferred it repeatedly to inflate the balance, repaid the loan and sold the surplus. PANews, citing Chengdu Lianan (Beosin) monitoring, put the attacker's profit at about 178 BNB (roughly $45,715); the figure shown here is $45,304. The dump crushed the LPC price.
Attacker: 0xd9936EA91a461aA4B727a7e3661bcD6cD257481c
Exploit transaction: 0x0e970ed84424d8ea51f6460ce6105ab68441d4450a80bc8d749fdf01e504ed8c
A second attacker transaction is also listed: 0xbd7ecaf0ce2ea7755d16deb0658fe0570d7e6e45fe3ce5b34f49d1e5f50ddb8b.
How it happened
- The attacker borrowed LPC from the PancakeSwap LPC/USDT pair through a flash swap (PANews reports 1,353,900 LPC; the public PoC borrows the whole reserve minus one unit).
- Inside the callback, the attacker called
transferwith its own address as both sender and recipient._transferworked from a cachedrecipientBalancethat was not refreshed after the sender side was debited, so the write-back credited the full amount on top of the old balance. - Each self-transfer therefore increased the balance instead of leaving it unchanged; the PoC repeats it ten times.
- The attacker repaid the flash swap with part of the inflated LPC, sending about 10% extra to cover the fee on the transfer back, so that 90% of what it sent matched the borrowed amount (per the PoC).
- The remaining LPC was sold for stablecoins (BUSD per PANews) and then swapped to BNB, about 178 BNB in total according to PANews.
Protocol details
Evidence
- report @CertiKAlert incident report twitter.com
- transaction bscscan.com transaction 0x0e97…ed8c bscscan.com
- transaction bscscan.com transaction 0xbd7e…db8b bscscan.com
- address bscscan.com address 0xd993…481c bscscan.com
- code DeFiHackLabs 2022 incident index: 20220725 LPC github.com
- analysis DeFiLlama defillama.com
- analysis PANews: LPC flash loan attack analysis (Chinese) panewslab.com
- analysis DeFiHackLabs LPC_exp.sol proof of concept raw.githubusercontent.com
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.