Submitted by 0xAsen, also found by shaflow2, ABAIKUNANBAEV, SBSecurity, and Sabit
https://github.com/code-423n4/2024-08-chakra/blob/d0d45ae1d26ca1b87034e67180fac07ce9642fd9/cairo/settlement/src/settlement.cairo#L356
https://github.com/code-423n4/2024-08-chakra/blob/d0d45ae1d26ca1b87034e67180fac07ce9642fd9/cairo/handler/src/handler_erc20.cairo#L135
When receiving a message via the settlement.cairo::receive_cross_chain_msg() function, a call is made to handler.receive_cross_chain_msg and the return value of that call is used to mark the message with status SUCCESS or FAILED
However, the way that the handler.receive_cross_chain_msg function is implemented, itll always return true, therefore marking every message as successful even if the message for some reason was a corrupted one.
And breaking one of the main invariants that states the message statuses should be tracked correctly.
Lets take a look at the code of the receive_cross_chain_msg function on the settlement.cairo contract, and specifically at the part where the call to handler.receive_cross_chain_msg is made:
As you can see, the status of the messages is based on the return value of this line: success = handler.receive_cross_chain_msg.
Lets see the handler.receive_cross_chain_msg function:
As you can see, as long as the function doesnt revert, itll always return true.
This shouldnt be the case and if for some reason the message is a corrupted one, it should get marked as FAILED as intended by the protocol.
The functionality is correctly implemented in the solidity version:
Implement the functionality like in the solidity handler function so it returns false if something goes wrong.
zvlwwj (Chakra) confirmed
