Settlement contract is mistakenly used for the handler contract when assigning ReceivedCrossChainTx struct
The settlement contract's receive_cross_chain_msg function stores the settlement contract's own address in the to_handler field of the ReceivedCrossChainTx struct instead of the intended handler address. This means the recorded cross-chain transaction data is wrong, though the text does not show a concrete exploit beyond the incorrect record.
ABAIKUNANBAEV Follow with AllTooWell, rbserver and 4 others
Originally disclosed on Code4rena
Submitted by ABAIKUNANBAEV, also found by AllTooWell, rbserver, said, Abdessamed, Draiakoo, and 0xNirix
Impact
receive_cross_chain_msg() is located in the Settlement contract and is called after the Chakra network signature verification process. However, when creating ReceivedCrossChainTx struct for the new receive_cross_txs[txid], the contract mistakenly uses address(this) instead of to_handler address.
Proof of Concept
Currently receive_cross_txs[txId] is assigned this way:
receive_cross_txs[txid] = ReceivedCrossChainTx(
txid,
from_chain,
contract_chain_name,
from_address,
from_handler,
address(this),
payload,
CrossChainMsgStatus.Pending
);
However, address(this) should be replaced by to_handler:
struct ReceivedCrossChainTx {
uint256 txid;
string from_chain;
string to_chain;
uint256 from_address;
uint256 from_handler;
address to_handler;
bytes payload;
CrossChainMsgStatus status;
}
As you can see here, after from_handler, there is to_handler address but it’s mistakenly set as address(this) which is an address of the settlement contract in reality.
Therefore, receive_cross_txs[txid] has incorrect parameters when creating a new received transaction struct.
Recommended Mitigation Steps
Change address(this) on to_handler address in a receive_cross_txs[txid] mapping.
The Warden has identified that the
ChakraSettlement::receive_cross_chain_msgfunction will improperly store a cross-chain message and will specifically store theto_handleraddress incorrectly.The impact of this particular submission is not able to be identified properly and, given that the function appears to be invoked as the last step in a cross-chain process, a severity of medium is considered appropriate as it should not impact the actual processing of the cross-chain transaction.
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
Likely a copy-paste or argument-order mistake: the struct field for the destination handler was filled with the settlement contract's own address rather than the to_handler parameter.
Impact
The stored cross-chain transaction has an incorrect to_handler value; the judge notes the real impact could not be determined and rated it medium because the function runs as the last step of the process.
What the attacker needed
Cross-chain message reaches settlement contract
The fix
The mapping assignment should use the to_handler address instead of address(this).
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.
A smart contract keeps a record of each cross-chain message it receives. When filling in that record, the code put its own address where the address of the receiving handler should go. So the saved record points at the wrong contract, which could confuse anything that later reads it.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.