Skip to content

Commit b190b7e

Browse files
Merge pull request #241 from terra-money/fix/authz-not-verfying-submsgs
fix: Fix MsgExec not verifying the validity of nested messages (cosmos#12184)
2 parents e2607c0 + 86ed1d5 commit b190b7e

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

CHANGELOG.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
103103
* (deps) [#14846](https://github.com/cosmos/cosmos-sdk/pull/14846) Bump btcd.
104104
* (deps) Bump Tendermint version to [v0.34.26](https://github.com/informalsystems/tendermint/releases/tag/v0.34.26).
105105
* (store) [#14189](https://github.com/cosmos/cosmos-sdk/pull/14189) Add config `iavl-lazy-loading` to enable lazy loading of iavl store, to improve start up time of archive nodes, add method `SetLazyLoading` to `CommitMultiStore` interface.
106-
* A new field has been added to the app.toml. This alllows nodes with larger databases to startup quicker
106+
* A new field has been added to the app.toml. This alllows nodes with larger databases to startup quicker
107107

108108
```toml
109109
# IAVLLazyLoading enable/disable the lazy loading of iavl store.
@@ -144,7 +144,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
144144

145145
* (deps) Bump Tendermint version to [v0.34.24](https://github.com/tendermint/tendermint/releases/tag/v0.34.24).
146146
* [#13651](https://github.com/cosmos/cosmos-sdk/pull/13651) Update `server/config/config.GetConfig` function.
147-
* [#14175](https://github.com/cosmos/cosmos-sdk/pull/14175) Add `server.DefaultBaseappOptions(appopts)` function to reduce boiler plate in root.go.
147+
* [#14175](https://github.com/cosmos/cosmos-sdk/pull/14175) Add `server.DefaultBaseappOptions(appopts)` function to reduce boiler plate in root.go.
148148

149149
### State Machine Breaking
150150

@@ -234,7 +234,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
234234

235235
ATTENTION:
236236

237-
This is a security release for the [Dragonberry security advisory](https://forum.cosmos.network/t/ibc-security-advisory-dragonberry/7702).
237+
This is a security release for the [Dragonberry security advisory](https://forum.cosmos.network/t/ibc-security-advisory-dragonberry/7702).
238238

239239
All users should upgrade immediately.
240240

@@ -293,7 +293,8 @@ replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8
293293
* (x/auth) [#13048](https://github.com/cosmos/cosmos-sdk/pull/13048) Add handling of AccountNumberStoreKeyPrefix to the simulation decoder.
294294
* (simapp) [#13108](https://github.com/cosmos/cosmos-sdk/pull/13108) Call `SetIAVLCacheSize` with the configured value in simapp.
295295
* [#13318](https://github.com/cosmos/cosmos-sdk/pull/13318) Keep the balance query endpoint compatible with legacy blocks.
296-
* [#13321](https://github.com/cosmos/cosmos-sdk/pull/13321) Add flag to disable fast node migration and usage.
296+
* [#13321](https://github.com/cosmos/cosmos-sdk/pull/13321) Add flag to disable fast node migration and usage.
297+
297298

298299
### Bug Fixes
299300

@@ -406,8 +407,8 @@ replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8
406407
* `NewMultiInfo`, `NewLedgerInfo` to `NewLegacyMultiInfo`, `newLegacyLedgerInfo` respectively. Move them into `legacy_info.go`.
407408
* `NewOfflineInfo` to `newLegacyOfflineInfo` and move it to `migration_test.go`.
408409
* Return:
409-
*`keyring.Record, error` in `SaveOfflineKey`, `SaveLedgerKey`, `SaveMultiSig`, `Key` and `KeyByAddress`.
410-
*`keyring.Record` instead of `Info` in `NewMnemonic` and `List`.
410+
*`keyring.Record, error` in `SaveOfflineKey`, `SaveLedgerKey`, `SaveMultiSig`, `Key` and `KeyByAddress`.
411+
*`keyring.Record` instead of `Info` in `NewMnemonic` and `List`.
411412
* Remove `algo` argument from :
412413
* `SaveOfflineKey`
413414
* Take `keyring.Record` instead of `Info` as first argument in:
@@ -591,7 +592,7 @@ replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8
591592
* (x/mint) [#12384](https://github.com/cosmos/cosmos-sdk/pull/12384) Ensure `GoalBonded` must be positive when performing `x/mint` parameter validation.
592593
* (x/auth) [#12261](https://github.com/cosmos/cosmos-sdk/pull/12261) Deprecate pagination in GetTxsEventRequest/Response in favor of page and limit to align with tendermint `SignClient.TxSearch`
593594
* (vesting) [#12190](https://github.com/cosmos/cosmos-sdk/pull/12190) Replace https://github.com/cosmos/cosmos-sdk/pull/12190 to use `NewBaseAccountWithAddress` in all vesting account message handlers.
594-
* (linting) [#12135](https://github.com/cosmos/cosmos-sdk/pull/12135/) Fix variable naming issues per enabled linters. Run gofumpt to ensure easy reviews of ongoing linting work.
595+
* (linting) [#12135](https://github.com/cosmos/cosmos-sdk/pull/12135/) Fix variable naming issues per enabled linters. Run gofumpt to ensure easy reviews of ongoing linting work.
595596
* (linting) [#12132](https://github.com/cosmos/cosmos-sdk/pull/12132) Change sdk.Int to math.Int, run `gofumpt -w -l .`, and `golangci-lint run ./... --fix`
596597
* (cli) [#12127](https://github.com/cosmos/cosmos-sdk/pull/12127) Fix the CLI not always taking into account `--fee-payer` and `--fee-granter` flags.
597598
* (migrations) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Fix v0.45->v0.46 in-place store migrations.
@@ -626,7 +627,7 @@ replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8
626627
* (x/feegrant) [\#10830](https://github.com/cosmos/cosmos-sdk/pull/10830) Expired allowances will be pruned from state.
627628
* (x/authz,x/feegrant) [\#11214](https://github.com/cosmos/cosmos-sdk/pull/11214) Fix Amino JSON encoding of authz and feegrant Msgs to be consistent with other modules.
628629
* (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time.
629-
* (x/gov) [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1.
630+
* (x/gov) [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1.
630631

631632
### Deprecated
632633

@@ -635,4 +636,4 @@ replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8
635636

636637
## Previous Versions
637638

638-
[CHANGELOG of previous versions](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md#v0460---2022-07-26).
639+
[CHANGELOG of previous versions](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md#v0460---2022-07-26).

x/authz/client/cli/tx.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ func NewCmdGrantAuthorization() *cobra.Command {
6060
fmt.Sprintf(`create a new grant authorization to an address to execute a transaction on your behalf:
6161
6262
Examples:
63-
$ %s tx %s grant cosmos1skjw.. send %s --spend-limit=1000stake --from=cosmos1skl..
63+
$ %s tx %s grant cosmos1skjw.. send --spend-limit=1000stake --from=cosmos1skl..
6464
$ %s tx %s grant cosmos1skjw.. generic --msg-type=/cosmos.gov.v1.MsgVote --from=cosmos1sk..
65-
`, version.AppName, authz.ModuleName, bank.SendAuthorization{}.MsgTypeURL(), version.AppName, authz.ModuleName),
65+
`, version.AppName, authz.ModuleName, version.AppName, authz.ModuleName),
6666
),
6767
Args: cobra.ExactArgs(2),
6868
RunE: func(cmd *cobra.Command, args []string) error {

x/authz/msgs.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ func (msg MsgExec) ValidateBasic() error {
222222
return sdkerrors.ErrInvalidRequest.Wrapf("messages cannot be empty")
223223
}
224224

225+
msgs, err := msg.GetMessages()
226+
if err != nil {
227+
return err
228+
}
229+
for _, msg := range msgs {
230+
if err = msg.ValidateBasic(); err != nil {
231+
return err
232+
}
233+
}
234+
225235
return nil
226236
}
227237

x/authz/msgs_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ func TestMsgExecAuthorized(t *testing.T) {
3030
}{
3131
{"nil grantee address", nil, []sdk.Msg{}, false},
3232
{"zero-messages test: should fail", grantee, []sdk.Msg{}, false},
33+
{"invalid nested msg", grantee, []sdk.Msg{
34+
&banktypes.MsgSend{
35+
Amount: sdk.NewCoins(sdk.NewInt64Coin("steak", 2)),
36+
FromAddress: "invalid_from_address",
37+
ToAddress: grantee.String(),
38+
},
39+
}, false},
3340
{"valid test: msg type", grantee, []sdk.Msg{
3441
&banktypes.MsgSend{
3542
Amount: sdk.NewCoins(sdk.NewInt64Coin("steak", 2)),

0 commit comments

Comments
 (0)