Case Study: BNB Bridge Token Hub Proof Verification Bypass¶
Fidelity Level: L2 (Fork-State Reproduction, BSC) Date: October 6, 2022 Loss: ~$570M in BNB Chain: BSC (Binance Smart Chain)
Overview¶
The BNB Bridge (also known as the BSC Token Hub) was exploited on October 6, 2022 when an attacker exploited an IAVL Merkle proof verification bypass in the BSC CrossChain system contract. The vulnerability allowed an attacker to forge arbitrary cross-chain messages from the BNB Beacon Chain to BSC, minting unbacked BNB.
The exploit was detected and halted by the BSC community validators approximately $570M into the attack ΓÇö the actual loss could have been much higher.
Technical Details¶
Contracts¶
| Contract | Address | Role |
|---|---|---|
| CrossChain | 0x0000000000000000000000000000000000002000 |
Cross-chain message handler (precompile-like system contract) |
| TokenHub | 0x0000000000000000000000000000000000001004 |
Token bridge handler (precompile-like system contract) |
Note: Both CrossChain and TokenHub are BSC system contracts ΓÇö they are hard-coded into the BSC client binary, not deployable EVM contracts. This means
eth_getCodereturns"0x"for them, even though they exist and are operational. Crucible's attack plugin handles this internally with graceful fallback.
Vulnerability¶
The handlePackage() function on the CrossChain contract processes cross-chain messages from the BNB Beacon Chain. It expects an IAVL Merkle proof to verify the message originated on the Beacon Chain:
function handlePackage(
bytes memory payload,
bytes memory proof,
uint64 height,
uint64 packageSequence,
uint8 channelId
) external returns (bool) {
// Verify the IAVL Merkle proof
require(verifyIAVLProof(proof, height), "invalid proof");
// ... process the cross-chain message
}
The vulnerability is in the IAVL proof verification logic:
1. The proof parser accepts malformed proofs with height=0 (leaf proof) and empty siblings
2. This bypasses the Merkle path validation entirely
3. Any key/value pair can be proven without a valid path from root to leaf
With a forged proof, the attacker could craft a handlePackage() call that the contract accepts, instructing it to mint BNB to an attacker-controlled address.
Function Selector¶
0x84013b6a ΓÇö keccak256("handlePackage(bytes,bytes,uint64,uint64,uint8)")[:4]
Fork Point¶
Block 22,166,659 ΓÇö the block immediately before the first exploit transaction.
Exploit Transaction¶
0xebf283515720d2d3a33f431f9d659ccf919163273e5f299166f2878d655f4625
Reproduction Approach¶
This reproduction models the IAVL proof verification bypass:
- Forks BSC at block 22,166,659 (requires BSC archive RPC)
- Verifies CrossChain and TokenHub system contracts exist (via RPC behavior, not
eth_getCode) - Constructs
handlePackage()calldata with a malformed IAVL proof (amino-like encoding with height=0, empty siblings) - Attempts the call to demonstrate the proof verification accepts malformed input
def execute(self, context, phase=None):
# Verify CrossChain contract exists (behavioral check)
# ABI-encode handlePackage(bytes,bytes,uint64,uint64,uint8)
calldata = build_malformed_handle_package_calldata()
# Send eth_call ΓÇö if it doesn't revert, proof bypass is confirmed
result = client.call("eth_call", [{
"to": CROSS_CHAIN_ADDRESS,
"data": calldata,
}, "latest"])
Important Note¶
The malformed IAVL proof (amino-like encoding) reverts on eth_call on a fresh BSC fork ΓÇö this is expected behavior because:
- The proof format doesn't match BSC's real amino encoding (which requires specific serialization)
- A fresh fork doesn't have the exact Beacon Chain state root the real exploit targeted
What the reproduction does prove:
- The CrossChain contract exists and the function is callable
- The vulnerability mechanism (insufficient IAVL proof validation) is correctly documented
- The function selector 0x84013b6a matches the actual contract interface
Reproduction Steps¶
Prerequisites¶
- Crucible installed
- BSC archive RPC endpoint (requires paid provider ΓÇö GetBlock $39/mo or similar)
Steps¶
# 1. Configure environment
cp .env.example .env
# Edit .env: set BSC_RPC_URL
# 2. Fork BSC
crucible fork --topology single_bsc
# 3. Run the experiment
crucible experiment run experiments/bnb_token_hub_replay.yaml --no-baseline
# 4. Verify determinism
crucible experiment run experiments/bnb_token_hub_replay.yaml --name run-a
crucible experiment run experiments/bnb_token_hub_replay.yaml --name run-b
crucible diff <run-a-id> <run-b-id>
Expected Results¶
| Assertion | Expected | Description |
|---|---|---|
handle_package_selector_computed |
✅ Pass | Selector 0x84013b6a is correct |
| Attack execution | success=False |
Expected ΓÇö modeled reproduction, proof format doesn't match on fresh fork |
Limitations¶
- BSC system contracts are precompile-like ΓÇö
eth_getCodereturns"0x"for them, preventing standard contract existence verification - Proof format mismatch ΓÇö the malformed IAVL proof (amino-like encoding) doesn't match BSC's real amino serialization on a fresh fork
- BSC archive RPC at block 22M ΓÇö BSC block 22,166,659 exceeds free archive RPC tier limits
- Beacon Chain state not available ΓÇö cross-chain messages originate from the non-EVM BNB Beacon Chain, which cannot be forked by Anvil