Skip to content

ibc-transfer transfer CLI panics when called with fewer than required positional arguments #25837

@andressa-zignaly

Description

@andressa-zignaly

The ibc-transfer transfer CLI command panics with a runtime error when invoked with fewer than the required positional arguments, instead of failing gracefully with a validation error. This affects any Cosmos SDK–based chain using IBC-Go’s transfer CLI.

Environment

  • Cosmos SDK: v0.53.4
  • IBC-Go: v10.1.0
  • Cobra: v1.9.1
  • OS: macOS (arm64)
  • Chain type: Any Cosmos SDK–based chain with IBC enabled

Steps to Reproduce

Run the IBC transfer CLI command with fewer than 4 positional arguments.

Example (missing the receiver argument):

<chaind> tx ibc-transfer transfer \
  transfer \
  <src-channel> \
  2000ibc/<denom-hash> \
  --from <wallet-name> \
  --fees <fee-denom> \
  --chain-id <chain-id> \
  --node <rpc-endpoint> \
  -y

The ibc-transfer transfer command is defined to require 4 positional arguments:
[src-port] [src-channel] [receiver] [amount]

Actual Result
The CLI panics with a runtime error instead of returning a validation error:

panic: runtime error: index out of range [3] with length 3

goroutine 1 [running]:
github.com/cosmos/ibc-go/v10/modules/apps/transfer/client/cli.NewTransferTxCmd.func1(...)
    ibc-go/v10/modules/apps/transfer/client/cli/tx.go:57
github.com/spf13/cobra.(*Command).execute(...)
github.com/spf13/cobra.(*Command).Execute(...)
github.com/cosmos/cosmos-sdk/server/cmd.Execute(...)

Expected Result
The CLI should fail gracefully with a clear validation error, for example:
Error: accepts 4 arg(s), received 3

This is the standard behavior when using Cobra argument validation such as:
Args: cobra.ExactArgs(4)

Analysis

  • The panic occurs inside:
    ibc-go/v10/modules/apps/transfer/client/cli/tx.go:57

  • The command handler accesses args[3] (the 4th positional argument) without ensuring that the argument count has been validated.

  • This indicates that:

    • Argument validation is either missing, misconfigured, or bypassed.
    • The handler attempts to index positional arguments before Cobra enforces ExactArgs(4).

As a result, instead of returning a user-friendly error, the CLI crashes.

Impact

  • Affects all Cosmos SDK–based chains using this version of IBC-Go.
  • Leads to poor UX and unexpected node CLI crashes from simple user input errors.
  • Can break scripts or automation that rely on predictable CLI error handling.

Suggested Fix

  • Ensure NewTransferTxCmd enforces argument validation using cobra.ExactArgs(4).
  • Avoid accessing positional arguments before validation.
  • Add a regression test to confirm the command fails gracefully when provided with too few arguments.

Additional Context
This issue is reproducible across chains and is not chain-specific.
The bug appears to originate in the IBC-Go transfer CLI, not in downstream chain implementations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions