What Happened
This exploit drained $13.4M from Abracadabra’s GMX V2 Cauldron through an accounting bug that created “phantom collateral” - allowing the same tokens to be borrowed against multiple times. The Core Bug: TheGmxV2CauldronRouterOrder contract had two critical functions:
sendValueInCollateral()- Extracted real tokens during liquidationsorderValueInCollateral()- Reported collateral value for borrowing calculations
sendValueInCollateral() removed tokens, it failed to update internal accounting variables (inputAmount, minOut, minOutLong). This meant orderValueInCollateral() continued reporting the original collateral value even after tokens were extracted.
Exploitation Steps:
- Setup: Attacker creates a failed GMX deposit, leaving tokens in the RouterOrder contract
- Exploit Loop:
- Borrow MIM against the reported collateral value
- Self-liquidate to extract real tokens via
sendValueInCollateral() - Internal accounting remains unchanged - same collateral value still reported
- Borrow again against the “phantom” collateral
- Repeat until all real tokens are drained
Assertion Pattern
Reported collateral must not exceed the value of extractable assets. This assertion compares those values:How the Assertion Would Have Prevented It
The assertion comparesorderValueInCollateral() with the value of tokens held by RouterOrder.
If the contract reports 1,000 USDC and holds 1,000 USDC, the check passes. If liquidation removes 500 USDC without updating the reported value, it fails.
