# The LockMint and BurnUnlock modes cannot be used

ChakraSettlementHandler's receive_cross_chain_msg uses wrong token action for LockMint and BurnUnlock modes, making those cross-chain configurations non-functional.

- Payout: Audit contest
- Severity: high
- Program: Chakra
- Found by: shaflow2
- Disclosed: 2025-02-20
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-08-chakra-findings/issues/30
- Library page: https://bugbountylibrary.com/r/c4%3A2024-08-chakra%3AH-13
- Tags: area:web3 domain:web3 impact:integrity kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:business-logic

**Target:** ChakraSettlementHandler.sol and handler_erc20.cairo receive_cross_chain_msg
**Root cause:** The handler serves both sending and receiving cross-chain messages with a single mode setting; on receive, LockMint mints instead of unlocking and BurnUnlock unlocks instead of minting, inverting the intended source-chain semantics.
**Steps:**
1. Deploy handler configured with SettlementMode.LockMint (source chain uses LockUnlock).
2. Send an ERC20 cross-chain message to this handler.
3. receive_cross_chain_msg decodes payload and, for LockMint, calls `_erc20_mint` instead of `_erc20_unlock`.
4. Observe tokens are minted rather than unlocked, breaking the LockMint flow; same inversion in Cairo handler_erc20.cairo.
**How found:** Code reading of receive_cross_chain_msg across Solidity and Cairo implementations, noticing the mode branches for LockMint/BurnUnlock call the opposite token operation relative to the source-chain mode semantics.
**Insight:** When a single contract handles both outbound and inbound cross-chain messages, check whether one mode enum is reused for both directions — receive-side branches often need the inverse operation of the send-side mode.

## Proof of concept (copied exactly from the original report)

**Solidity receive_cross_chain_msg LockMint/BurnUnlock branches**

```
if (mode == SettlementMode.MintBurn) {
                    ...
                } else if (mode == SettlementMode.LockUnlock) {
                    ...
                } else if (mode == SettlementMode.LockMint) {
                    _erc20_mint(
                        AddressCast.to_address(transfer_payload.to),
                        transfer_payload.amount
                    );
                    return true;
                } else if (mode == SettlementMode.BurnUnlock) {
                    _erc20_unlock(
                        AddressCast.to_address(transfer_payload.to),
                        transfer_payload.amount
                    );
                    return true;
                }
            }
        }
```

**Cairo receive_cross_chain_msg mode branches**

```
if self.mode.read() == SettlementMode::MintBurn{
                erc20.mint_to(u256_to_contract_address(transfer.to), transfer.amount);
            }else if self.mode.read() == SettlementMode::LockMint{
                erc20.mint_to(u256_to_contract_address(transfer.to), transfer.amount);
            }else if self.mode.read() == SettlementMode::BurnUnlock{
                token.transfer(u256_to_contract_address(transfer.to), transfer.amount);
            }
```

