Skip to content
DoS Audit finding Intermediate

A single malicious observer can exploit the infinite gas meter to grief ZetaChain blocks without proper gas compensation

The transaction ante handler applies an infinite gas meter to any transaction containing at least one observer-only message, even if other messages are present. A malicious observer could bundle many gas-heavy messages with such a message, pay negligible gas, and fill block space, potentially preventing other transactions from being processed.

berndartmueller Follow

Originally disclosed on Code4rena

Submitted by berndartmueller

ZetaChain blocks can be griefed by a single observer, possibly preventing other transactions from being processed.

Proof of Concept

A Cosmos SDK app’s ante handler verifies transactions (gas, messages,..) before further processing and before the individual messages are passed onto the respective handlers.

ZetaChain sets up the ante handler in the NewAnteHandler function and handles transactions differently depending on their type. For example, MsgEthereumTx Evmos EVM messages require different ante handlers than regular Cosmos SDK messages.

Specifically, regular Cosmos SDK transactions have their messages checked in lines 97-112 and if at least one of the messages is a MsgGasPriceVoter or MsgVoteOnObservedInboundTx message, an infinite transaction gas meter is used.

056: func NewAnteHandler(options ethante.HandlerOptions) (sdk.AnteHandler, error) {
... 		// [...]
092:
093: 		// handle as totally normal Cosmos SDK tx
094: 		switch tx.(type) {
095: 		case sdk.Tx:
096: 			found := false
097: 			for _, msg := range tx.GetMsgs() {
098: 				switch msg.(type) {
099: 				// treat these two msg types differently because they might call EVM which results in massive gas consumption
100: 				// For these two msg types, we don't check gas limit by using a different ante handler
101: 				case *cctxtypes.MsgGasPriceVoter, *cctxtypes.MsgVoteOnObservedInboundTx:
102: 					found = true
103: 					break
104: 				}
105: 			}
106: 			if found {
107: 				// this differs newCosmosAnteHandler only in that it doesn't check gas limit
108: 				// by using an Infinite Gas Meter.
109: 				anteHandler = newCosmosAnteHandlerNoGasLimit(options)
110: 			} else {
111: 				anteHandler = newCosmosAnteHandler(options)
112: 			}
... 		// [...]
119: }

The reasoning is that both the MsgGasPriceVoter and MsgVoteOnObservedInboundTx messages (exclusively limited to observers) interact with the internal zEVM (Evmos), which has a different gas model (EVM equivalent) than Cosmos SDK. To prevent out-of-gas errors, an infinite gas meter is used.

However, this is problematic as the code in line 97-112 only checks if at least one of the messages is a MsgGasPriceVoter or MsgVoteOnObservedInboundTx message. If the transaction also contains other messages, the same infinite transaction gas meter applies to them as well and the transaction will not run out of gas.

Consequently, a turned-malicious observer can craft a transaction that contains a MsgGasPriceVoter or MsgVoteOnObservedInboundTx message and a lot of other messages that consume a lot of gas. As the infinite transaction gas meter is used, the transaction will be processed without running out of gas. The observer only pays a negligible amount of gas (purposefully set very low) but is able to spam the network and fill up block space, possibly preventing other transactions from being processed if the block gas limit is reached (which is set by default to 10 million in CometBFT).

Nevertheless, this is a privilege escalation as single observes are not supposed to have such a significant impact on the ZetaChain’s block space, and thus, medium severity was chosen.

Recommended mitigation steps

Consider only using the infinite transaction gas meter if all of the transaction’s messages are of the type MsgGasPriceVoter or MsgVoteOnObservedInboundTx.

DadeKuma (Lookout) commented:

Bundling costly messages before a MsgGasPriceVoter (or MsgVoteOnObservedInboundTx) may result in infinite gas consumption.

lumtis (ZetaChain) confirmed


The original report as published on Code4rena, by berndartmueller. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 ante handler checks only whether at least one message is an observer message, rather than requiring all messages to be of that type before applying the infinite gas meter.

Impact

A single malicious observer could spam the network with low-cost, high-gas transactions, filling block space and possibly preventing other transactions from being processed if the block gas limit is reached.

What the attacker needed

Observer privileges

The fix

The infinite gas meter should only be used when all messages in the transaction are of the observer message types.

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.

In blockchain systems, each transaction must pay for the computational effort it uses, measured in 'gas'. ZetaChain gives observer messages unlimited gas so they don't fail, but it mistakenly gives that same unlimited gas to any other messages in the same transaction. A malicious observer can therefore include many expensive messages, pay almost nothing, and clog the network.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by berndartmueller

View all

97 more disclosed reports, best first.

More from ZetaChain

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.