XSD Token Hack
What happened
On September 26, 2023, an attacker used flash loans to drain about 56.9 WBNB (roughly $11,900 to $12,100) from XSDWETHpool, the XSD/WBNB pool contract on BNB Smart Chain. CertiK's monitoring flagged the attack the same day and reported that the stolen funds were still in the attacker's wallet.
The attacker borrowed WBNB from two DODO pools and sold XSD for BNB through the XSD router. When the router paid out BNB, the attack contract received control back and traded against the same pool again before the first swap had finished. It then made one final swap that withdrew more WBNB than it had put in. The public reproduction shows this sequence, but no project post-mortem explains which accounting check failed.
Attacker: 0x506eEBd8d6061202A8e8FC600bb3d5D41f475eE1
Attack contract: 0x202E059a16D29a2F6aE0307AE3D574746b2B6305
Malicious transaction: 0xbdf76f22c41fe212f07e24ca7266d436ef4517dc1395077fabf8125ebe304442
How it happened
- The attack contract took a flash loan of WBNB from a DODO pool, then a second, nested flash loan from another DODO pool.
- It called the router's
swapXSDForETHto sell XSD for BNB. - When the router paid out BNB, the attack contract's
fallbackran before the outer swap had finished. From there it sent WBNB intoXSDWETHpool, called the pool'sswapto take XSD out, calledPIDController.systemCalculations(), and made a smallswapETHForBankXcall. - After the router call returned, the contract transferred XSD into
XSDWETHpooland calledswapto withdraw more WBNB than it had deposited in step 3. - It repaid both flash loans and kept about 56.9 WBNB.
Protocol details
Evidence
- report CertiK Alert (@CertiKAlert) post on the XSDWETHpool flash loan, 2023-09-26 (read via FxTwitter mirror of x.com/CertiKAlert/status/1706765042916450781) twitter.com
- transaction bscscan.com transaction 0xbdf7…4442 bscscan.com
- address bscscan.com address 0x202E…6305 bscscan.com
- address bscscan.com address 0x506e…5eE1 bscscan.com
- code DeFiHackLabs XSDWETHpool_exp.sol github.com
- analysis SlowMist Hacked database, entry 'XSDWETHpool' (2023-09-26) hacked.slowmist.io
Understand the attack patterns
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.