# Invalid token address used in ChakraSettlementHandler::cross_chain_erc20_settlement(...) leading to invalid transaction creation and event emission

ChakraSettlementHandler stored and emitted address(this) instead of the token address in cross-chain ERC20 settlements, corrupting bridge transaction data and events.

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

**Target:** ChakraSettlementHandler Solidity contract (cross_chain_erc20_settlement)
**Root cause:** The function passes address(this) (the handler contract) as from_token when building CreatedCrossChainTx and emitting CrossChainLocked, instead of the configured token state variable.
**Steps:**
1. Call `cross_chain_erc20_settlement(to_chain, to_handler, to_token, to, amount, mode)` on ChakraSettlementHandler
2. Observe `create_cross_txs[txid].from_token == address(handler)` rather than the token address
3. Observe emitted `CrossChainLocked.from_token == address(handler)`
4. Compare with Cairo implementation which uses `self.token_address.read()`
**How found:** Code review of the Solidity handler against the Cairo reference implementation, spotting address(this) where the token state variable was expected in both the struct construction and event emission.
**Exploitation:** Validators listening to CrossChainLocked events receive the handler contract address as the source token, so downstream settlement/minting on the destination chain references the wrong token, breaking or misdirecting cross-chain transfers.
**Insight:** When a protocol has parallel implementations in two languages (Solidity/Cairo), diff the equivalent functions field-by-field; mismatched state variables like address(this) vs token reveal copy-paste errors that break off-chain validator logic.

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

**CreatedCrossChainTx uses address(this) instead of token**

```
create_cross_txs[txid] = CreatedCrossChainTx(
                txid,
                chain,
                to_chain,
                msg.sender,
                to,
@>              address(this), // @audit - this should be the global variable `token`
                to_token,
                amount,
                CrossChainTxStatus.Pending
            );
```

