# GHSA-WM4F-QPXP-RCH4: Precompile call limit bypass via uint8 counter wraparound in x/vm StateDB

- Database: GitHub
- Severity: high (stated by ghsa, no CVSS score)
- Published: 2026-11-02
- Modified: 2026-11-02

## Affected versions

- github.com/cosmos/evm (Go): fixed in 0.6.4
- github.com/cosmos/evm (Go): from 0.7.0, fixed in 0.7.4

## Description

## Summary

Cosmos EVM limits the number of stateful precompile calls per transaction to 20, because each precompile call allocates a cached context. Both the counter and the limit constant were declared as `uint8`, and the counter was incremented before the limit check. Rejected calls therefore continued to advance the counter, and the 256th call wrapped it to zero, reopening 21 accepted precompile-call slots per 256 attempts. Reverted calls did not restore the counter, so the pattern could be repeated many times within a single transaction.

A single small transaction can combine this wraparound with low-cost malformed ICS20 calls (which advance the counter at near-zero required gas) to reopen arbitrarily many call slots, and each reopened slot can trigger a fresh 25,000,000-gas internal EVM execution whose cost is not charged to the outer transaction when the call fails during a post-execution state flush. In a four-validator test network, one such 917-byte transaction left all validators unable to finalize the block for a measured 125 seconds, and restarting the nodes did not restore liveness because each validator replayed the committed block through the application. This is a chain-halt / liveness failure reachable by any funded account where the ICS20 static precompile and permissionless ERC-20 registration are enabled.

## Details

The precompile call limiter tracks stateful precompile calls per transaction with a counter and limit that are both `uint8` (`types.MaxPrecompileCalls uint8 = 20`, `StateDB.precompileCallsCounter uint8`). `StateDB.AddPrecompileFn` appended its journal entry and incremented the counter *before* comparing against the limit, so calls 21 and onward were rejected but the counter kept advancing through 255. The 256th call wrapped `255 + 1` to zero and was accepted, and each additional 256 attempts opened another 21 accepted call slots. Because the precompile journal's `Revert` restores the multistore, events, and processed-event count but not the counter, reverted calls consumed no permanent state, and the composition could be repeated within one transaction.

Two behaviors made the reopened slots costly. The ICS20 precompile returns zero required gas for input shorter than four bytes, yet such calls still enter native-action setup and reach `AddPrecompileFn`, so they can advance the blocked counter at minimal cost. And a call involving a permissionlessly registered native ERC-20 executes the token's code under a fresh 25,000,000-gas internal EVM cap before the transfer keeper rejects a syntactically valid but nonexistent IBC v2 client; when a post-execution flush error then propagated, the already-measured internal gas was discarded before being charged to the outer transaction. Each accepted call could therefore execute roughly 24.9 million internal EVM gas while contributing almost nothing to the outer transaction's gas consumption. Because the work is deterministic consensus execution of a committed transaction, restarting validators does not restore liveness: each node replays the same block through the application.

## Patches

The fix widens `MaxPrecompileCalls` and the counter to `uint64` and moves the limit check before the increment, so rejected calls can no longer advance or wrap the counter back into the accepted range. The journal revert deliberately does not restore the counter, so reverted precompile calls still consume their quota.

- Fixed on `main`.
- Released in **[v0.6.4](https://github.com/cosmos/evm/releases/tag/v0.6.4)**.
- Released in **[v0.7.4](https://github.com/cosmos/evm/releases/tag/v0.7.4)**.

Chain operators must upgrade to **v0.6.4** or **v0.7.4** (or later).

## Workarounds

Disabling the ICS20 static precompile or permissionless ERC-20 registration removes the described route. Enforcing a finite consensus block-gas limit and per-transaction gas-wanted ceiling limits the blast radius but does not fix the counter wraparound. There is no complete workaround short of upgrading.

## References

- Releases: [v0.6.4](https://github.com/cosmos/evm/releases/tag/v0.6.4), [v0.7.4](https://github.com/cosmos/evm/releases/tag/v0.7.4)

## Credits

Originally reported through the Cosmos bug bounty program by sl90.

Please reach out to our security email, [security@cosmoslabs.io](mailto:security@cosmoslabs.io) to get further details, or via our bug bounty program [https://immunefi.com/bug-bounty/cosmos](https://immunefi.com/bug-bounty/cosmos/information/) to report known vulnerabilities.

## References

- https://github.com/cosmos/evm/security/advisories/GHSA-wm4f-qpxp-rch4

Page: https://cve.now/GHSA-WM4F-QPXP-RCH4

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
