From bc4b59d43301e556c428875c82e40403eb1bfce3 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 4 Jul 2024 16:31:05 +0200 Subject: [PATCH] Use addresses for comparison --- x/wasm/ibc.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 }