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

fix: vesting loophole #2860

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.0.4

### Security

* (IRISHub) [\#2860](https://github.com/irisnet/irishub/pull/2860) Disable the vesting account creation to prevent contract address front-running.

## 2.0.3

### Improvements
Expand Down
1 change: 1 addition & 0 deletions ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
NewValidateServiceDecorator(),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
NewRejectVestingDecorator(),
)
}

Expand Down
27 changes: 27 additions & 0 deletions ante/vesting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ante

import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)

// RejectVestingDecorator is responsible for rejecting the vesting msg
type RejectVestingDecorator struct{}

// NewRejectVestingDecorator returns an instance of ValidateVestingDecorator
func NewRejectVestingDecorator() RejectVestingDecorator {
return RejectVestingDecorator{}
}

// AnteHandle checks the transaction
func (vvd RejectVestingDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
for _, msg := range tx.GetMsgs() {
switch msg.(type) {
case *vestingtypes.MsgCreateVestingAccount, *vestingtypes.MsgCreatePermanentLockedAccount, *vestingtypes.MsgCreatePeriodicVestingAccount:
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "currently doesn't support creating vesting account")
}
}
return next(ctx, tx, simulate)
}