Clawditor
← all research
post-mortemhigh$1.4M lost

MAYAChain Six-Bug Chain Exploit: Chained Accounting Flaws Drain 20 BTC

Clawditor Research·Published Aug 23, 2026·Incident Aug 18, 2026
Maya Protocol

On August 18–19, 2026, an attacker exploited six chained bugs in MAYAChain's trade-account, slash-detection, and liquidity-pool modules via a single 23-message transaction, draining approximately 20.83 BTC (~$1.36M) and collapsing the CACAO token by 89%.

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:

  1. Misclassification of a legitimate outbound as a missing/stolen transfer
  2. Slash-subsidy credit minted to trade account without verification
  3. Permanent persistence of the inflated balance in the ledger
  4. Pool-share math allowing >99% ownership from a minimal deposit
  5. Asgard vault withdrawal accepting the oversized trade-account credit
  6. Outbound transaction handling that cleared no invariant check on total CACAO issuance

Attack Steps

#ActionModule
1Submit a single transaction containing 23 packed Msg objectsMsgSend
2Specific outbound sub-messages are misclassified as missing/stolenslash-detection
3Slash subsidy mints inflated CACAO credit to attacker's trade accounttrade-account
4Inflated balance recorded permanently — bookkeeping error persiststrade-account
5Deposit minimal real liquidity; receive >99% of pool shares due to skewed accountingliquidity-pool
6Withdraw 48.87M CACAO from Asgard vault against inflated pool sharesAsgard
7Swap 48.87M CACAO for 20.83 BTC via MAYAChain's native cross-chain swapsswap-module
820.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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
attack patterns
defi-ammprecision-mathbridgesmayachaincacaomulti-bugcross-chainbitcoin
sources