Submitted by dontonka, also found by lsaudit
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/protocol-contracts/contracts/evm/ZetaConnector.eth.sol#L85 
https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/protocol-contracts/contracts/evm/ZetaConnector.non-eth.sol#L95
Observer take care of inbound/outbound CCTX in Zeta ecosystem. For EVM chains, it works with 3 smart contracts which are deployed on the external EVM chain:
In case of emergency, these contracts can be paused by calling their corresponding pause() function. The assumption would be that they are paused on both the inbound and outbound EVM chains, as otherwise there will be always inbounds CCTX coming in, and that will result more complex to manage. Since the 3 functions mention above are gated by whenNotPaused, whenever a contract is paused, it will prevent any inbounds cctx from coming in.
There is a key problem in the moment with this scenario: onRevert is gated with whenNotPaused while onReceive is not. This means whenever the contracts are paused (on both chains), the pending CCTX still need to be processed before any migration can happen (eg: migrating TSS). This is the specific reason why onReceive is not being gated with whenNotPaused, but since onRevert is gated, a revert in onReceive would kick-off the refund mecanism, which will call onRevert on the originating chain but that will always revert if the contract is also paused.
User funds can be lost in favor of Zeta protocol during a CCTX due to contracts being paused.
Lets consider the CCTX flow described in the whitepaper as follow for Cross-Chain Message Passing.
Lets consider a pending CCTX between BSC and ETH chains in a context of an emergency situation where contracts on both BSC and ETH are paused, but our CCTX had already generated his ZetaSent event, awaiting to be processed/voted/finalized by the Observers, so its pending, and now still need to be fully processed while the contracts are paused.
contractAddress, message]. (the message is arbitrarily encoded application
data in binary format.
3. ZetaChain observers (in zetaclient) pick up this event/memo and report to
zetacore, which verifies the inbound transaction.
4. zetacore modifies the CCTX (cross-chain tx) state variable with OutboundTxParams
which instructs the TSS signers (in zetaclient) to build, sign, and broadcast
external transaction.
5. The zetaclient TSS signers observe the OutboundTxParams in the CCTX, and
build outbound tx, enter into a TSS keysign ceremony to sign the transaction,
and then broadcast the signed transaction to the external blockchains. For
CCMP, the outbound transaction is mainly calling the user specified contract
with specified addresses and parameters.
6. The CCTX structure also tracks the stages/status of the cross-chain transaction.
7. Once the broadcasted transaction is included in one of the blocks (said to be
mined or confirmed), zetaclients will report such confirmation to zetacore,
which will update the CCTX status.
8. If the confirmed outbound transaction was successful, the CCTX status becomes OutboundMined, and the CCTX is considered in its terminal state and
will not be updated anymore. This CCTX processing is completed.
9. If the confirmed outbound transaction is failure (e.g. revert on Ethereum
chains), then the CCTX will updates it status to PendingRevert if possible, or
Aborted if revert is not possible. The CCTX processing is completed if it
goes to Aborted status.
10. If the new status is PendingRevert, a second OutboundTxParams should be
already in the CCTX, which instructs the zetaclients to create a Revert outbound tx to the incoming chain & contract, allowing the incoming contract to
implement a application level revert function to cleanup contract state.
11. The zetaclients will build the revert transaction, enter into TSS keysign ceremony to sign the transaction, and broadcast to the incoming blockchain (Chain
A in this case).
12. Once the revert transaction is confirmed on Chain A, the zetaclients will
report the transaction status to zetacore.
13. If the revert transaction is successful, the CCTX status becomes Reverted, and
the CCTX processing is completed.
14. If the revert transaction is failure, the CCTX status becomes Aborted, and the
CCTX processing is completed.
Whenever contracts are paused in case of emergency, in order to properly complete the pending CCTXs, the entire CCTX flow must be active, which include the refund mechanism.
By removing the whenNotPaused on onRevert function, that will resolve the problem, so I would recommend the following change in ZetaConnectorEth.sol and ZetaConnectorNonEth.sol
lumtis (ZetaChain) commented:
0xean (Judge) commented:
Note: See full discussion here.
