# GHSA-2M6R-Q6X4-4W5G: LegacyDec overflow panic in EVM dynamic fee checker crashes validators during mempool recheck

- 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): from 0.7.0, fixed in 0.7.4

## Description

## Summary

The dynamic fee checker in `cosmos/evm` computes the EIP-1559 effective gas price as `min(baseFee + tipCap, feeCap)`, adding an attacker-supplied priority tip cap to the base fee before taking the minimum. The tip cap is validated only for sign, so a value near the upper limit of `cosmossdk.io/math.LegacyDec` is accepted at submission time while the addition stays in range. When the base fee later rises, the mempool's recheck loop re-runs the ante handler over the pooled transaction at the new, higher base fee, the addition overflows `LegacyDec`, and the library panics. That panic is raised on a goroutine launched by `RecheckMempool.scheduleRecheckLoop` that has no recovery boundary, so the validator process dies instead of dropping the transaction.

This was demonstrated on a four-validator network running the app-side EVM mempool with the released `evmd v0.7.2`: a single crafted, signed transaction left the chain advancing, then killed all four validators (400 of 400 voting power) and halted the chain. A build from the development branch that already carries the queue-insert panic recovery reproduced the same halt, since that recovery sits on a different goroutine and cannot catch this panic. An attacker needs only an ordinary funded account; because the transaction's fee deduction never completes, the attack costs nothing beyond the fees used to nudge the base fee upward.

## Details

The dynamic fee checker in `ante/evm/fee_checker.go` reads `MaxPriorityPrice` (the EIP-1559 tip cap) from the transaction's `ExtensionOptionDynamicFeeTx` and validates only that it is not negative. Because `LegacyDec.Unmarshal` accepts any value up to the `cosmossdk.io/math` upper limit, and `IsInValidRange` treats exactly `upperLimit` as in range, a signed, funded transaction can carry `tipCap = upperLimit - baseFee_now` and be admitted: at submission `tipCap + baseFee_now == upperLimit`, no panic occurs, and `min(baseFee + tipCap, feeCap)` evaluates to `feeCap`, so the transaction is priced normally and gossips to peers.

The EIP-1559 helper `effectiveGasPriceLegacyDec` computed `LegacyMinDec(tipCap.Add(baseFee), feeCap)`, evaluating `tipCap.Add(baseFee)` first. If the base fee later rises above the value the tip cap was pinned to, `tipCap + baseFee` exceeds `LegacyDec`'s upper limit and `LegacyDec.Add` panics with "Int overflow" (by design of the math library; bounding inputs is the caller's responsibility).

The panic becomes fatal on the app-side ("Krakatoa") mempool's recheck path. `RecheckMempool.Start` launches `scheduleRecheckLoop` on a bare goroutine, which on each new block head launches `runRecheck`; `runRecheck` re-runs the full ante handler over every pooled transaction via `TxRechecker.RecheckCosmos`, using the new block's base fee. There is no `recover()` on this goroutine, and Go's `recover` only operates on its own goroutine, so neither the baseapp block-execution recovery middleware nor the queue-insert recover added by a prior fix can catch it. `SetUpContextDecorator`'s deferred handler converts only `ErrorOutOfGas` and re-panics everything else. The same arithmetic reached through block execution is recovered by baseapp; the recheck goroutine is not, so the whole process crashes. Note that `feeCap >= baseFee` is enforced before the helper runs, so the reordered computation is well-defined for all accepted transactions.

## Patches

The fix clamps `maxPriorityPrice` to `feeCap` in the fee checker before the effective-price computation, and rewrites `effectiveGasPriceLegacyDec` as `baseFee.Add(LegacyMinDec(tipCap, feeCap.Sub(baseFee)))`, which yields the same EIP-1559 result without ever forming the unbounded `baseFee + tipCap` sum. As defence in depth, `TxRechecker` now wraps ante-handler invocations in a `recover()`, converting any panic during recheck into an error that rejects the transaction instead of killing the process.

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

Chain operators must upgrade to **v0.7.4** (or later). Chains running the app-side EVM mempool should upgrade all validators; nodes that cannot upgrade immediately can set `mempool.type` back to CometBFT's built-in mempool (e.g. `flood`) in `config.toml`.

## Workarounds

Operators who cannot upgrade immediately can disable the app-side EVM mempool by setting `mempool.type` to a CometBFT mempool type (the default is `flood`) in each validator's `config.toml`, which removes the affected recheck path. There is no other workaround short of upgrading.

## References

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

## Credits

Originally reported through the Cosmos bug bounty program by gzeon.

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-2m6r-q6x4-4w5g

Page: https://cve.now/GHSA-2M6R-Q6X4-4W5G

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