Skip to content

fix: add uint64 overflow guard in GetRevertGasLimit #4564

Open

Description

@kingpinXD

Context

HackenProof report: https://dashboard.hackenproof.com/manager/companies/zetachain/zetachain-blockchain-software/reports/ZCNode-212

Problem

GetRevertGasLimit() in x/crosschain/keeper/cctx_utils.go:72 calls .Uint64() on a math.Uint value that can store up to 256-bit integers. When this value exceeds 2^64, the Cosmos SDK's Uint64() method panics with "Uint64() out of bound".

The same pattern exists in gas_payment.go:152 where gas.GasLimit.Uint64() is called.

No server-side validation exists on RevertGasLimit:

  • NewRevertOptionsFromEVM (revert_options.go:42) converts *big.Int to math.Uint with no cap
  • MsgVoteInbound.ValidateBasic() performs no validation on RevertGasLimit

Current Protection

Both EVM and ZEVM gateway contracts enforce MAX_REVERT_GAS_LIMIT = 2,000,000 at the Solidity level, preventing values > 2M from entering the system through normal gateway calls. This is not currently exploitable.

Fix

Add .IsUint64() guard before calling .Uint64() as defense-in-depth:

// In GetRevertGasLimit (cctx_utils.go)
if !cctx.RevertOptions.RevertGasLimit.IsZero() {
    if !cctx.RevertOptions.RevertGasLimit.IsUint64() {
        return 0, errors.New("revert gas limit exceeds uint64 range")
    }
    return cctx.RevertOptions.RevertGasLimit.Uint64(), nil
}

Optionally also validate in MsgVoteInbound.ValidateBasic().

Severity

Low — latent defense-in-depth issue, not currently exploitable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions