diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs.go b/modules/apps/27-interchain-accounts/controller/types/msgs.go index b600942bf01..1187b579ff3 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs.go @@ -12,6 +12,8 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) +const MaximumOwnerLength = 2048 // maximum length of the owner in bytes + var ( _ sdk.Msg = (*MsgRegisterInterchainAccount)(nil) _ sdk.Msg = (*MsgSendTx)(nil) @@ -41,6 +43,10 @@ func (msg MsgRegisterInterchainAccount) ValidateBasic() error { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "owner address cannot be empty") } + if len(msg.Owner) > MaximumOwnerLength { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "owner addresss must not exceed %d bytes", MaximumOwnerLength) + } + return nil } diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 13ef2c9ae1a..33a02068464 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -64,6 +64,13 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { }, false, }, + { + "owner address is too long", + func() { + msg.Owner = ibctesting.GenerateString(types.MaximumOwnerLength + 1) + }, + false, + }, } for i, tc := range testCases {