Skip to content

Commit 463f184

Browse files
julienrbrtmmsqe
authored andcommitted
Merge pull request from GHSA-4j93-fm92-rp4m
* fix(x/auth/vesting): Add `BlockedAddr` check in `CreatePeriodicVestingAccount` * updates
1 parent 78c102b commit 463f184

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4141

4242
### Bug Fixes
4343

44+
* (x/auth/vesting) [GHSA-4j93-fm92-rp4m](#bug-fixes) Add `BlockedAddr` check in `CreatePeriodicVestingAccount`.
4445
* (baseapp) [#19177](https://github.com/cosmos/cosmos-sdk/pull/19177) Fix baseapp `DefaultProposalHandler` same-sender non-sequential sequence.
4546

4647
## [v0.47.8](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.8) - 2024-01-22

RELEASE_NOTES.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
## 🚀 Highlights
66

7-
This patch release includes a fix in baseapp in `DefaultProposalHandler` and <>.
7+
This patch release includes a fix in baseapp in `DefaultProposalHandler` and fixes [GHSA-4j93-fm92-rp4m](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-4j93-fm92-rp4m).
88

99
We recommended to upgrade to this patch release as soon as possible.
10+
When upgrading from <= v0.47.8, please ensure that 2/3 of the validator power upgrade to v0.47.9.
1011

1112
Curious? Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.47.9/CHANGELOG.md) for an exhaustive list of changes or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/v0.47.8...v0.47.9) from last release.
1213

x/auth/vesting/msg_server.go

+4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
154154
return nil, err
155155
}
156156

157+
if s.BankKeeper.BlockedAddr(to) {
158+
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress)
159+
}
160+
157161
if acc := ak.GetAccount(ctx, to); acc != nil {
158162
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress)
159163
}

x/auth/vesting/msg_server_test.go

+56
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ func (s *VestingTestSuite) TestCreateVestingAccount() {
8585
expErr: true,
8686
expErrMsg: "already exists",
8787
},
88+
"create for blocked account": {
89+
preRun: func() {
90+
s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil)
91+
s.bankKeeper.EXPECT().BlockedAddr(to1Addr).Return(true)
92+
},
93+
input: vestingtypes.NewMsgCreateVestingAccount(
94+
fromAddr,
95+
to1Addr,
96+
sdk.Coins{fooCoin},
97+
time.Now().Unix(),
98+
true,
99+
),
100+
expErr: true,
101+
expErrMsg: "not allowed to receive funds",
102+
},
88103
"create a valid delayed vesting account": {
89104
preRun: func() {
90105
s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil)
@@ -155,6 +170,22 @@ func (s *VestingTestSuite) TestCreatePermanentLockedAccount() {
155170
expErr: true,
156171
expErrMsg: "already exists",
157172
},
173+
"create for blocked account": {
174+
preRun: func() {
175+
toAcc := s.accountKeeper.NewAccountWithAddress(s.ctx, to1Addr)
176+
s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil)
177+
s.bankKeeper.EXPECT().BlockedAddr(to1Addr).Return(true)
178+
s.accountKeeper.SetAccount(s.ctx, toAcc)
179+
},
180+
input: vestingtypes.NewMsgCreatePermanentLockedAccount(
181+
fromAddr,
182+
to1Addr,
183+
sdk.Coins{fooCoin},
184+
),
185+
expErr: true,
186+
expErrMsg: "not allowed to receive funds",
187+
},
188+
158189
"create a valid permanent locked account": {
159190
preRun: func() {
160191
s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), fooCoin).Return(nil)
@@ -196,6 +227,7 @@ func (s *VestingTestSuite) TestCreatePeriodicVestingAccount() {
196227
{
197228
name: "create for existing account",
198229
preRun: func() {
230+
s.bankKeeper.EXPECT().BlockedAddr(to1Addr).Return(false)
199231
toAcc := s.accountKeeper.NewAccountWithAddress(s.ctx, to1Addr)
200232
s.accountKeeper.SetAccount(s.ctx, toAcc)
201233
},
@@ -213,10 +245,34 @@ func (s *VestingTestSuite) TestCreatePeriodicVestingAccount() {
213245
expErr: true,
214246
expErrMsg: "already exists",
215247
},
248+
{
249+
name: "create for blocked address",
250+
preRun: func() {
251+
s.bankKeeper.EXPECT().BlockedAddr(to2Addr).Return(true)
252+
},
253+
input: vestingtypes.NewMsgCreatePeriodicVestingAccount(
254+
fromAddr,
255+
to2Addr,
256+
time.Now().Unix(),
257+
[]vestingtypes.Period{
258+
{
259+
Length: 10,
260+
Amount: sdk.NewCoins(periodCoin),
261+
},
262+
{
263+
Length: 20,
264+
Amount: sdk.NewCoins(fooCoin),
265+
},
266+
},
267+
),
268+
expErr: true,
269+
expErrMsg: "not allowed to receive funds",
270+
},
216271
{
217272
name: "create a valid periodic vesting account",
218273
preRun: func() {
219274
s.bankKeeper.EXPECT().IsSendEnabledCoins(gomock.Any(), periodCoin.Add(fooCoin)).Return(nil)
275+
s.bankKeeper.EXPECT().BlockedAddr(to2Addr).Return(false)
220276
s.bankKeeper.EXPECT().SendCoins(gomock.Any(), fromAddr, to2Addr, gomock.Any()).Return(nil)
221277
},
222278
input: vestingtypes.NewMsgCreatePeriodicVestingAccount(

0 commit comments

Comments
 (0)