Skip to content
Business logic Audit finding Intermediate

Missing ERC20Method validation at destination allows non-transfer tx to be handled as transfers

The destination handler for cross-chain ERC20 transfers does not verify that the decoded operation is a transfer, so any other ERC20 method (such as approve) is processed as a transfer, potentially minting or unlocking tokens without a corresponding lock or burn on the source chain.

Tigerfrake Follow with said

Originally disclosed on Code4rena

Submitted by Tigerfrake, also found by said

Impact

In cross-chain transactions, the integrity and correctness of the transaction must be maintained across different blockchain environments, which might have varying security measures, protocols. However, the missing ERC20method validation at destination allows cross-chain tx with a different ERC20Method from Transfer to be handled as transfer transactions when they actually aren’t.

Proof of Concept

When sending a cross-chain tx, the sender locks/burns some amount of tokens at source chain. With this, the recipient then unlocks or gets minted same amount of tokens at the destination. Basically this is similar to Token Transfer from one address to another.

As such, handler_erc20::receive_cross_chain_msg() checks to ensure that ERC20Method is TRANSFER at destination before handling tokens:

    assert(transfer.method_id == ERC20Method::TRANSFER, 'ERC20Method must TRANSFER');

Checking for the ERC20Method at the destination is crucial due to the nature of cross-chain transactions and the need for validation and security on both ends of the transaction.

However ChakraSettlementHandler::receive_cross_chain_msg() only decodes the transfer payload and proceeds to handle tokens without actually verifying that the method is transfer.

        if (payload_type == PayloadType.ERC20) {
            // Cross chain transfer
            {
                // Decode transfer payload
                ERC20TransferPayload memory transfer_payload = codec
                    .deocde_transfer(msg_payload);
>>              // @audit-info Missing method validation
                if (mode == SettlementMode.MintBurn) {
                    _erc20_mint(
                        AddressCast.to_address(transfer_payload.to),
                        transfer_payload.amount
                    );
                    return true;
                }
                ---SNIP---
            }
            ---SNIP---
        }

Recommended Mitigation Steps

ERC20Method should be validated before handling tokens in receive_cross_chain_msg():

        if (payload_type == PayloadType.ERC20) {
            // Cross chain transfer
            {
                // Decode transfer payload
                ERC20TransferPayload memory transfer_payload = codec
                    .deocde_transfer(msg_payload);
+               require(transfer_payload.method_id == ERC20Method.Transfer, "ERC20Method must TRANSFER");

                if (mode == SettlementMode.MintBurn) {
                    _erc20_mint(
                        AddressCast.to_address(transfer_payload.to),
                        transfer_payload.amount
                    );
                    return true;
                }
                ---SNIP---
            }
            ---SNIP---
        }

0xsomeone (judge) commented:

The Solidity counterpart of the Chakra system does not validate that the decoded EIP-20 operation is an ERC20Method::Transfer and ignores its status.

As the Chakra node system is out of the scope of this audit, I am unable to properly deduce the likelihood as well as the feasibility of this variable being any different.

I consider this submission to be a correct medium-risk issue as a result given that operations other than transfers would be assumed to be transfers.


The original report as published on Code4rena, by Tigerfrake. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The destination handler decodes the ERC20 payload and processes it as a transfer without checking that the method ID equals TRANSFER.

Impact

A cross-chain message with a non-transfer ERC20 method could be handled as a transfer, potentially minting or unlocking tokens at the destination without a corresponding lock or burn at the source; the judge rated this medium risk because the likelihood depends on the out-of-scope Chakra node system.

What the attacker needed

Cross-chain message with non-transfer ERC20 method

The fix

The destination handler should require that the decoded method ID equals TRANSFER before processing tokens.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you send tokens across chains, the receiving side must check that the message is actually a transfer. Here, the receiving contract skips that check, so a message meant for a different action (like approving someone to spend tokens) is treated as a transfer, which could create tokens out of thin air.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Tigerfrake

View all

4 more disclosed reports, best first.

More from Chakra

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.