Submitted by berndartmueller (1, 2) also found by MevSec, and ChristiansWhoHack (1, 2, 3, 4)
Events such as ZetaReceived or ZetaReverted, supposed to be emitted by the connector contract, can be faked by the receiver contract that is called as part of the onReceive or onRevert call.
Worst case, a cctx can be purposefully caused to remain stuck in the PendingOutbound state, which blocks the outbound EVM transaction queue and prevents further outbound transactions from being sent.
The observers EVM client confirms sent outbound transaction within the IsSendOutTxProcessed function and sends the confirmation (i.e., MsgVoteOnObservedOutboundTx vote message) to ZetaChain to ultimately finalize and settle the cctx.
Specifically, outbound cctxs of type CoinType_Zeta are processed by checking the emitted events (logs) of the containing transaction. It is expected that either the ZetaReceived or ZetaReverted event is emitted by the connector contract.
However, in line 386 (and following), the events legitimacy is not verified by checking the emitter contract address.
Internally, the ParseZetaReceived function only parses the event and makes sure the events signature matches the expected one.
Thereafter, once the first matching ZetaReceived event is found and parsed, the confirmation is sent to ZetaChain, and the for loop is exited early via the return statement in line 421. As a result, the other legitimate ZetaReverted event, emitted by the connector contract, is ignored.
This fake ZetaReceived event can be very harmful to the system if it causes the cctx to not be finalized and stuck in the PendingOutbound state.
Concretely, this can be achieved by using the wrong internalSendHash value in the ZetaReceived event, which is used to uniquely identify the cctx. If the internalSendHash value does not match the cctxs index and instead, refers to a non-existent cctx, the MsgVoteOnObservedOutboundTx message fails and will never be finalized.
Such a cctx remains in the pending queue and will be repeatedly picked up by observers in the startSendScheduler function.
Finally, the impact of this vulnerability shows itself by blocking the outbound transactions due to the MaxLookaheadNonce check in zetacore_observer.go#L181-L185:
At one point, the stuck cctx will be the first item in the cctxList (i.e., cctxList[0]), while the next item, at position 1, will have a nonce that is greater than the stuck cctxs nonce plus the MaxLookaheadNonce value.
Basically, this lookahead nonce check acts as a throttle to limit the amount of sent outbound transactions per heartbeat (i.e., per ZetaChain block).
Subsequently, the break statement in line 184 early exits the for loop, skipping all other cctxs in the cctxList and preventing them from being sent to the external chain.
The following simple proof of concept demonstrates sending a cross-chain message and faking the ZetaReceived event to cause the cctx to remain pending.
Subsequently, the observers will repeatedly try to vote on it, but keep failing. In the end, this stuck cctx blocks the outbound transaction queue due to the maximum lookahead nonce check. As a result, no further outbound transactions are sent.
Consider carefully checking the emitter address of critical events, such as the ZetaReceived in evm_client.go#L386, the ZetaReverted event in evm_client.go#L423, and the Withdrawn event in evm_client.go#L490.
lumtis (ZetaChain) confirmed
