Root Cause
MAYAChain's node software (v0.104.x) contained an exploitable interaction between three subsystems: the trade-account module, the slash/theft-detection logic, and the liquidity-pool math. The attacker discovered that a legitimate outgoing transfer could be misclassified as stolen funds, which triggered MAYAChain's slash-subsidy compensation mechanism — permanently crediting the attacker's trade account with CACAO that was never actually lost.
// Pseudo-code of the flawed slash-subsidy interaction
func HandleOutbound(ctx Context, msg MsgOutboundTx) error {
if isMissing(ctx, msg.TxID) { // BUG: legitimate outbounds can be flagged missing
compensate(msg.ObservedPool, msg.Amount) // mints CACAO credit
record(ctx, msg.TxID, StatusCompensated) // balance persists regardless
}
// ... rest of outbound handling
}
// Pool share calculation did not guard against >99% single-LP ownership
func calcPoolUnits(pool Pool, addAmt sdk.Uint) sdk.Uint {
// inflated balance from step above feeds directly into LP share math
return addAmt.MulUint64(pool.TotalUnits).Quo(pool.BalanceCacao)
// BUG: with artificially inflated BalanceCacao, return is near-total units
}
Six distinct flaws were activated in sequence by a single transaction containing 23 packed messages:
- Misclassification of a legitimate outbound as a missing/stolen transfer
- Slash-subsidy credit minted to trade account without verification
- Permanent persistence of the inflated balance in the ledger
- Pool-share math allowing >99% ownership from a minimal deposit
- Asgard vault withdrawal accepting the oversized trade-account credit
- Outbound transaction handling that cleared no invariant check on total CACAO issuance
Attack Steps
| # | Action | Module |
|---|---|---|
| 1 | Submit a single transaction containing 23 packed Msg objects | MsgSend |
| 2 | Specific outbound sub-messages are misclassified as missing/stolen | slash-detection |
| 3 | Slash subsidy mints inflated CACAO credit to attacker's trade account | trade-account |
| 4 | Inflated balance recorded permanently — bookkeeping error persists | trade-account |
| 5 | Deposit minimal real liquidity; receive >99% of pool shares due to skewed accounting | liquidity-pool |
| 6 | Withdraw 48.87M CACAO from Asgard vault against inflated pool shares | Asgard |
| 7 | Swap 48.87M CACAO for 20.83 BTC via MAYAChain's native cross-chain swaps | swap-module |
| 8 | 20.83 BTC (~$1.34M) swept to external Bitcoin address; CACAO crashes 89% | Bitcoin / MAYAChain |
Impact
- Confirmed extracted: 20.83 BTC ≈ $1,340,000 sent to a single Bitcoin address
- Total attacker value (including remaining on-chain positions): ~$1.7M
- Secondary impact: CACAO token price collapsed from $0.115 → $0.013 (~89%) in under 240 blocks, destroying ~$11M in market cap
- Network status: MAYAChain halted since August 19, 2026; all BTC swaps and cross-chain operations suspended
- Recovery efforts: Team offered white-hat bounty to attacker; planned CACAO burn for inflated minted supply; six bug patches in progress
Lessons for Auditors
- Slash and compensation logic must verify loss before minting credit. Any mechanism that creates new tokens or credits as "compensation" must source the loss proof from a quorum of trusted observers — never from the transaction sender's implicit state.
- Multi-message batching opens combinatorial attack surfaces. A single transaction with N messages can activate N state transitions whose interactions were never co-tested. Fuzz multi-message sequences (including reordering) as a first-class test primitive for any message-based chain.
- Pool-share math must guard extreme ownership concentration. If a single LP can reach >99% ownership through normal deposit logic, the pool is effectively under their unilateral control. Apply a minimum liquidity reserve or ownership cap that cannot be bypassed through synthetic credit.
- Monitor native token issuance rate as an invariant. Minting 48.87M CACAO in one transaction should be an immediate on-chain alarm. Automated invariant checks (total supply vs. expected ceiling, per-block issuance rate) are a last line of defense when access controls fail.