diff --git a/x/wasm/ibc.go b/x/wasm/ibc.go index 3a237552e..b0311f522 100644 --- a/x/wasm/ibc.go +++ b/x/wasm/ibc.go @@ -2,7 +2,6 @@ package wasm import ( "math" - "strings" wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" @@ -440,15 +439,19 @@ func (i IBCHandler) IBCReceivePacketCallback( } func validateSender(contractAddr, senderAddr string) (sdk.AccAddress, error) { - // We only allow the contract that sent the message to receive source chain callbacks for it. - if !strings.EqualFold(contractAddr, senderAddr) { - return nil, errorsmod.Wrapf(types.ErrExecuteFailed, "contract address %s does not match packet sender %s", contractAddr, senderAddr) - } - contractAddress, err := sdk.AccAddressFromBech32(contractAddr) if err != nil { return nil, errorsmod.Wrapf(err, "contract address") } + senderAddress, err := sdk.AccAddressFromBech32(senderAddr) + if err != nil { + return nil, errorsmod.Wrapf(err, "packet sender address") + } + + // We only allow the contract that sent the message to receive source chain callbacks for it. + if !contractAddress.Equals(senderAddress) { + return nil, errorsmod.Wrapf(types.ErrExecuteFailed, "contract address %s does not match packet sender %s", contractAddr, senderAddress) + } return contractAddress, nil }