Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(x/group): 2nd round audit changes #16982

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions x/group/keeper/proposal_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ func (s Keeper) doExecuteMsgs(ctx sdk.Context, router baseapp.MessageRouter, pro
// are equal to the given account address of group policy.
func ensureMsgAuthZ(msgs []sdk.Msg, groupPolicyAcc sdk.AccAddress, cdc codec.Codec) error {
for i := range msgs {
// In practice, GetSigners() should return a non-empty array without
// duplicates, so the code below is equivalent to:
// `msgs[i].GetSigners()[0] == groupPolicyAcc`
// but we prefer to loop through all GetSigners just to be sure.
// In practice, GetMsgV1Signers should return a non-empty array without duplicates.
signers, _, err := cdc.GetMsgV1Signers(msgs[i])
if err != nil {
return err
}

// The code below should be equivalent to: `signers[0] == groupPolicyAcc`
// But here, we loop through all the signers just to be sure.
for _, acct := range signers {
if !bytes.Equal(groupPolicyAcc, acct) {
return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "msg does not have group policy authorization; expected %s, got %s", groupPolicyAcc.String(), acct)
Expand Down