Skip to content

Commit

Permalink
fix wasm hook to disallow unknown fields
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Mar 6, 2024
1 parent 232113f commit f815b4d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/hook/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package hook
import (
"context"
"encoding/json"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand All @@ -20,8 +21,10 @@ func NewWasmBridgeHook(wasmKeeper *wasmkeeper.Keeper) WasmBridgeHook {
}

func (mbh WasmBridgeHook) Hook(ctx context.Context, sender sdk.AccAddress, msgBytes []byte) error {
msg := wasmtypes.MsgExecuteContract{}
err := json.Unmarshal(msgBytes, &msg)
var msg wasmtypes.MsgExecuteContract
decoder := json.NewDecoder(strings.NewReader(string(msgBytes)))
decoder.DisallowUnknownFields()
err := decoder.Decode(&msg)
if err != nil {
return err
}
Expand Down

0 comments on commit f815b4d

Please sign in to comment.