Broken NonceVoter Allows Observer to Halt the Chain
The NonceVoter function in ZetaChain's crosschain module does not implement the intended voting logic and instead directly sets chain nonces. A single authorized observer can change a chain's nonce, causing UpdateNonce to fail and halting critical cross-chain operations, potentially locking funds.
ciphermarco Follow with ChristiansWhoHack and zhaojie
Originally disclosed on Code4rena
Submitted by ciphermarco, also found by ChristiansWhoHack and zhaojie
As it is, NonceVoter does not count votes or perform any similar operations. A single observer can use it to change chain nonces. Although there is a comment pointing this function is deprecated, it critically influences the system with its broken implementation. Arbitrarily changing nonces for the connected chains can be used to completely break the functioning of the chain and cause loss of funds.
Proof of Concept
This function is restricted to validator observers (k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain)):
func (k msgServer) NonceVoter(goCtx context.Context, msg *types.MsgNonceVoter) (*types.MsgNonceVoterResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
chain := k.zetaObserverKeeper.GetParams(ctx).GetChainFromChainID(msg.ChainId)
if chain == nil {
return nil, observertypes.ErrSupportedChains
}
if ok := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain); !ok {
return nil, observertypes.ErrNotAuthorizedPolicy
}
// ... SNIP ...
After this check, the entire voting logic is essentially ignored, with a relevant part only drafted and commented, and the chain nonce is simply set:
k.SetChainNonces(ctx, chainNonce)
return &types.MsgNonceVoterResponse{}, nil
This can be easily tested inside one of the hosts in the smoke-tests:
# cd into repos/node
$ make start-smoketest
$ docker exec -it zetacore0 bash
# Inside zetacore0
# The operator key may be acquired with the command `zetacored keys list`
$ zetacored tx crosschain nonce-voter 18444 1337 --from ${operator_key} --fees "300azeta"
# Confirm the prompt with "y"
$ zetacored q crosschain list-chain-nonces
# OUTPUT:
ChainNonces:
- chain_id: "18444"
creator: ""
finalizedHeight: "57"
index: btc_regtest
nonce: "1337" # <--- Chain nonce
signers:
- zeta1t4n5yj0u3wjkjwum5exhgh5834gnylgs3apmw5
- chain_id: "1337"
creator: ""
finalizedHeight: "57"
index: goerli_localnet
nonce: "0"
signers: []
- chain_id: "101"
creator: ""
finalizedHeight: "57"
index: zeta_mainnet
nonce: "0"
signers: []
pagination:
next_key: null
total: "0"
After the above commands, you can also use the command zetacored q crosschain list-chain-nonces inside zetacored1 to check the 1337 nonce has been set.
p.NonceHigh != int64(nonce.Nonce)
One simple way to halt critical operations of the chain and cause funds to be stuck is to make the function UpdateNonce in cctx_utils.go fail. Luckily, there is a check that causes this function to fail and return an error, and all we need to do is to change the chain nonce:
// #nosec G701 always in range
if p.NonceHigh != int64(nonce.Nonce) {
return cosmoserrors.Wrap(types.ErrNonceMismatch, fmt.Sprintf("chain_id %d, high nonce %d, current nonce %d", receiveChainID, p.NonceHigh, nonce.Nonce))
}
All a faulty or compromised observer needs to do is to use NonceVoter to desynchronise the nonces for each chain, and this error will be consistently returned by UpdateNonce for all chains.
These are critical functions that depend on UpdateNonce:
Essentially, transactions will be halted and the funds stuck.
Tools Used
Code Editor, Docker.
Recommended Mitigation Steps
Implement the correct voting logic or remove this message server’s function from the code. In the codebase, it seems there is already another design choice for setting chain nonces that does not depend on this function, so the best mitigation is probably to remove this function altogether.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The NonceVoter message handler lacks the intended multi-observer voting logic and directly sets the chain nonce after only checking that the caller is an authorized observer.
Impact
A faulty or compromised observer could desynchronise nonces, causing UpdateNonce to fail for all chains and halting critical operations such as fund migration and cross-chain transaction processing, potentially locking funds.
What the attacker needed
Authorized observer role
The fix
The function should be removed or the correct voting logic implemented, as the codebase already has another design for setting chain nonces.
How it was found
- Start the local smoke-test environment and enter the zetacore0 container.
- Obtain the operator key and submit a nonce-voter transaction with a chosen chain ID and nonce.
- Query the chain nonces to confirm the new nonce is set.
- Optionally check another node to see the nonce propagated.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A blockchain bridge relies on observers to agree on transaction counts (nonces) between chains. Here, one observer could unilaterally change a nonce because the voting step was skipped. That mismatch then blocks the bridge's normal processing, potentially trapping funds.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.