XSD Token Hack

Reported loss $12K
Logic

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

  1. The attack contract took a flash loan of WBNB from a DODO pool, then a second, nested flash loan from another DODO pool.
  2. It called the router's swapXSDForETH to sell XSD for BNB.
  3. When the router paid out BNB, the attack contract's fallback ran before the outer swap had finished. From there it sent WBNB into XSDWETHpool, called the pool's swap to take XSD out, called PIDController.systemCalculations(), and made a small swapETHForBankX call.
  4. After the router call returned, the contract transferred XSD into XSDWETHpool and called swap to withdraw more WBNB than it had deposited in step 3.
  5. It repaid both flash loans and kept about 56.9 WBNB.

Protocol details

Classification Token
Protocol Type Exploit/Flash Loan Attack
Affected asset / contract XSD

Understand the attack patterns

Build your security review skills

Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.