Open c4-bot-4 opened 11 months ago
DadeKuma marked the issue as primary issue
DadeKuma marked the issue as sufficient quality report
lumtis (sponsor) acknowledged
0xean marked the issue as satisfactory
0xean marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/node/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go#L100
Vulnerability details
Impact
The outbound transaction queue is potentially blocked by such "stuck" transactions, preventing other pending cctxs from being sent out.
Proof of Concept
The
AddToOutTxTracker
function, handling theMsgAddToOutTxTracker
message, adds a transaction hash associated with a pending cctx to the outbound transaction tracker, which is subsequently watched by observers to detect the transaction's inclusion and confirmation in a block. As a result, the pending cctx is marked asCctxStatus_OutboundMined
.This
MsgAddToOutTxTracker
message is sent by observers as soon as the outbound transaction is broadcast. See zetaclient/evm_signer.go#L585 and zetaclient/btc_signer.go#L360.However, the
AddToOutTxTracker
function only keeps track of a maximum of two different transaction hashes, as seen in line100
. Otherwise, themsg.TxHash
is discarded.This is problematic as an outbound cctx, uniquely identified by its nonce, can have multiple different transaction hashes caused by repeatedly increasing the gas price every epoch.
As soon as the gas price has been increased and observers broadcast the updated transaction (i.e., replace it in the mempool), the transaction hash will change. As a result, reporting the transaction hash to ZetaChain via the
AddTxHashToOutTxTracker
function call will not keep track of the new transaction hash.Consequently, the EVM client's
observeOutTx
and the BTC client'sobserveOutTx
function are not able to query the transaction by the available hashes found in the trackerHashList
. This results in the outbound cctx being repeatedly processed by the observers, unnecessarily "blocking" other pending cctxs from being sent out (due to limiting the amount of sent outbound cctx per the 3-second ticker).Only after such a "stuck" transaction is manually added to the outbound transaction tracker via the
AddTxHashToOutTxTracker
function by providing a block inclusion proof, the correct and up-to-date transaction hash is added to the tracker and the observers can finally confirm and conclude the cctx. However, this is a separate process and requires (manual) intervention, which might take some time until it is noticed.Tools Used
Manual review
Recommended mitigation steps
Consider keeping track of all transaction hashes associated with a pending cctx instead of limiting it to two hashes.
Assessed type
Other