Submitted by 0xAsen, also found by Tigerfrake, pwnforce, b0g0, ABAIKUNANBAEV, and AllTooWell
When a cross-chain message is sent it can return a callback with status FAILED or SUCCESS. The problem is that even if the cross-chain message failed, the original message status on the source chain would be marked as SUCCESS.
Lets take a look at the receive_cross_chain_callback function on the settlement.cairo contract, and more specifically the part that updates the status:
The problem is that as long as the call to handler.receive_cross_chain_callback function was successful, the message as a whole will be marked in a SUCCESS state even though that cross_chain_msg_status could be SUCCESS or FAILED depending on if the message failed on the destination chain.
This could lead to a situation where a message fails to get processed on the destination chain, a callback is returned with cross_chain_msg_status == FAILED but the message is marked as SUCCESS.
That situation could be a user trying to bridge his tokens, the bridging fails so he doesnt receive his tokens on the destination chain, a callback is made and the message is marked as a SUCCESS even though it as not successfully executed.
And if we see the code of the handler.receive_cross_chain_callback function, well see that itd always return true as long as it doesnt revert:
The function just performs validation of the handlers, if the settlement contract calls it and returns true. These validation could all be true but the initial message could still be with a FAILED status.
This is not taken into account and could lead to a failed message being marked as a successful one.
The implementation on the solidity contract is correct:
As you can see, even if the call to the handler was successful, the status is updated with the CrossChainMsgStatus that was passed to the function and it is not automatically marked with SUCCESS.
This should be the case in the cairo function as well but right now the cross_chain_msg_status parameter is ignored.
Change this line from this:
to this:
To be consistent with the solidity implementation.
zvlwwj (Chakra) confirmed
0xsomeone (judge) commented:
